xref: /PHP-8.4/ext/gmp/tests/gmp_jacobi.phpt (revision e9f783fc)
1--TEST--
2gmp_jacobi() basic tests
3--EXTENSIONS--
4gmp
5--FILE--
6<?php
7
8for ($i = -1; $i < 10; $i++) {
9    var_dump(gmp_strval(gmp_jacobi(($i*$i)-1, 3)));
10}
11
12var_dump(gmp_strval(gmp_jacobi(7, 23)));
13var_dump(gmp_strval(gmp_jacobi("733535124", "1234123423434535623")));
14var_dump(gmp_strval(gmp_jacobi(3, "1234123423434535623")));
15
16$n = "123123";
17$n1 = "1231231";
18
19var_dump(gmp_strval(gmp_jacobi($n, $n1)));
20var_dump(gmp_strval(gmp_jacobi($n, 3)));
21var_dump(gmp_strval(gmp_jacobi(3, $n1)));
22
23try {
24    var_dump(gmp_jacobi(3, array()));
25} catch (\TypeError $e) {
26    echo $e->getMessage() . \PHP_EOL;
27}
28try {
29    var_dump(gmp_jacobi(array(), 3));
30} catch (\TypeError $e) {
31    echo $e->getMessage() . \PHP_EOL;
32}
33try {
34    var_dump(gmp_jacobi(array(), array()));
35} catch (\TypeError $e) {
36    echo $e->getMessage() . \PHP_EOL;
37}
38
39echo "Done\n";
40?>
41--EXPECT--
42string(1) "0"
43string(2) "-1"
44string(1) "0"
45string(1) "0"
46string(2) "-1"
47string(1) "0"
48string(1) "0"
49string(2) "-1"
50string(1) "0"
51string(1) "0"
52string(2) "-1"
53string(2) "-1"
54string(1) "0"
55string(1) "0"
56string(2) "-1"
57string(1) "0"
58string(2) "-1"
59gmp_jacobi(): Argument #2 ($num2) must be of type GMP|string|int, array given
60gmp_jacobi(): Argument #1 ($num1) must be of type GMP|string|int, array given
61gmp_jacobi(): Argument #1 ($num1) must be of type GMP|string|int, array given
62Done
63