xref: /PHP-7.4/ext/gmp/tests/gmp_abs.phpt (revision 782352c5)
1--TEST--
2gmp_abs() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8var_dump(gmp_strval(gmp_abs("")));
9var_dump(gmp_strval(gmp_abs("0")));
10var_dump(gmp_strval(gmp_abs(0)));
11var_dump(gmp_strval(gmp_abs(-111111111111111111111)));
12var_dump(gmp_strval(gmp_abs("111111111111111111111")));
13var_dump(gmp_strval(gmp_abs("-111111111111111111111")));
14var_dump(gmp_strval(gmp_abs("0000")));
15var_dump(gmp_strval(gmp_abs("09876543")));
16var_dump(gmp_strval(gmp_abs("-099987654")));
17
18var_dump(gmp_abs());
19var_dump(gmp_abs(1,2));
20var_dump(gmp_abs(array()));
21
22echo "Done\n";
23?>
24--EXPECTF--
25Warning: gmp_abs(): Unable to convert variable to GMP - string is not an integer in %s on line %d
26string(1) "0"
27string(1) "0"
28string(1) "0"
29
30Warning: gmp_abs(): Unable to convert variable to GMP - wrong type in %s on line %d
31string(1) "0"
32string(21) "111111111111111111111"
33string(21) "111111111111111111111"
34string(1) "0"
35
36Warning: gmp_abs(): Unable to convert variable to GMP - string is not an integer in %s on line %d
37string(1) "0"
38
39Warning: gmp_abs(): Unable to convert variable to GMP - string is not an integer in %s on line %d
40string(1) "0"
41
42Warning: gmp_abs() expects exactly 1 parameter, 0 given in %s on line %d
43NULL
44
45Warning: gmp_abs() expects exactly 1 parameter, 2 given in %s on line %d
46NULL
47
48Warning: gmp_abs(): Unable to convert variable to GMP - wrong type in %s on line %d
49bool(false)
50Done
51