xref: /PHP-8.2/ext/gmp/tests/gmp_com.phpt (revision e9f783fc)
1--TEST--
2gmp_com() basic tests
3--EXTENSIONS--
4gmp
5--FILE--
6<?php
7
8var_dump(gmp_strval(gmp_com(0)));
9var_dump(gmp_strval(gmp_com("0")));
10try {
11    var_dump(gmp_strval(gmp_com("test")));
12} catch (\ValueError $e) {
13    echo $e->getMessage() . \PHP_EOL;
14}
15var_dump(gmp_strval(gmp_com("2394876545678")));
16var_dump(gmp_strval(gmp_com("-111")));
17var_dump(gmp_strval(gmp_com(874653)));
18var_dump(gmp_strval(gmp_com(-9876)));
19
20$n = gmp_init("98765467");
21var_dump(gmp_strval(gmp_com($n)));
22$n = gmp_init("98765463337");
23var_dump(gmp_strval(gmp_com($n)));
24
25try {
26    var_dump(gmp_strval(gmp_com(array())));
27} catch (\TypeError $e) {
28    echo $e->getMessage() . \PHP_EOL;
29}
30
31echo "Done\n";
32?>
33--EXPECT--
34string(2) "-1"
35string(2) "-1"
36gmp_com(): Argument #1 ($num) is not an integer string
37string(14) "-2394876545679"
38string(3) "110"
39string(7) "-874654"
40string(4) "9875"
41string(9) "-98765468"
42string(12) "-98765463338"
43gmp_com(): Argument #1 ($num) must be of type GMP|string|int, array given
44Done
45