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