xref: /PHP-8.0/ext/gmp/tests/gmp_legendre.phpt (revision 25198277)
1--TEST--
2gmp_legendre() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8for ($i = -1; $i < 10; $i++) {
9    var_dump(gmp_strval(gmp_legendre(($i*$i)-1, 3)));
10}
11
12var_dump(gmp_strval(gmp_legendre(7, 23)));
13var_dump(gmp_strval(gmp_legendre("733535124", "1234123423434535623")));
14var_dump(gmp_strval(gmp_legendre(3, "1234123423434535623")));
15
16$n = "123123";
17$n1 = "1231231";
18
19var_dump(gmp_strval(gmp_legendre($n, $n1)));
20var_dump(gmp_strval(gmp_legendre($n, 3)));
21var_dump(gmp_strval(gmp_legendre(3, $n1)));
22
23try {
24    var_dump(gmp_legendre(3, array()));
25} catch (\TypeError $e) {
26    echo $e->getMessage() . \PHP_EOL;
27}
28try {
29    var_dump(gmp_legendre(array(), 3));
30} catch (\TypeError $e) {
31    echo $e->getMessage() . \PHP_EOL;
32}
33try {
34    var_dump(gmp_legendre(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_legendre(): Argument #2 ($num2) must be of type GMP|string|int, array given
60gmp_legendre(): Argument #1 ($num1) must be of type GMP|string|int, array given
61gmp_legendre(): Argument #1 ($num1) must be of type GMP|string|int, array given
62Done
63