xref: /PHP-8.2/ext/gmp/tests/gmp_mod.phpt (revision e9f783fc)
1--TEST--
2gmp_mod tests()
3--EXTENSIONS--
4gmp
5--FILE--
6<?php
7
8try {
9    var_dump(gmp_mod("",""));
10} catch (\ValueError $e) {
11    echo $e->getMessage() . \PHP_EOL;
12}
13var_dump(gmp_mod(0,1));
14var_dump(gmp_mod(0,-1));
15
16try {
17    var_dump(gmp_mod(-1,0));
18} catch (\DivisionByZeroError $e) {
19    echo $e->getMessage() . \PHP_EOL;
20}
21
22try {
23    var_dump(gmp_mod(array(), array()));
24} catch (\TypeError $e) {
25    echo $e->getMessage() . \PHP_EOL;
26}
27
28$a = gmp_init("-100000000");
29$b = gmp_init("353467");
30
31var_dump(gmp_mod($a, $b));
32
33echo "Done\n";
34?>
35--EXPECT--
36gmp_mod(): Argument #1 ($num1) is not an integer string
37object(GMP)#2 (1) {
38  ["num"]=>
39  string(1) "0"
40}
41object(GMP)#2 (1) {
42  ["num"]=>
43  string(1) "0"
44}
45Modulo by zero
46gmp_mod(): Argument #1 ($num1) must be of type GMP|string|int, array given
47object(GMP)#4 (1) {
48  ["num"]=>
49  string(5) "31161"
50}
51Done
52