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