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