xref: /PHP-8.0/ext/gmp/tests/gmp_prob_prime.phpt (revision 25198277)
1--TEST--
2gmp_prob_prime() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8var_dump(gmp_prob_prime(10));
9var_dump(gmp_prob_prime("7"));
10var_dump(gmp_prob_prime(17));
11var_dump(gmp_prob_prime(-31));
12var_dump(gmp_prob_prime("172368715471481723"));
13
14var_dump(gmp_prob_prime(10));
15var_dump(gmp_prob_prime("7"));
16var_dump(gmp_prob_prime(17));
17var_dump(gmp_prob_prime(-31));
18var_dump(gmp_prob_prime("172368715471481723"));
19
20for ($i = -1; $i < 12; $i++) {
21    var_dump(gmp_prob_prime((773*$i)-($i*7)-1, $i));
22    $n = gmp_init("23476812735411");
23    var_dump(gmp_prob_prime(gmp_add($n, $i-1), $i));
24}
25
26$n = gmp_init("19481923");
27var_dump(gmp_prob_prime($n));
28$n = gmp_init(0);
29var_dump(gmp_prob_prime($n));
30
31try {
32    var_dump(gmp_prob_prime(array()));
33} catch (\TypeError $e) {
34    echo $e->getMessage() . \PHP_EOL;
35}
36
37echo "Done\n";
38?>
39--EXPECT--
40int(0)
41int(2)
42int(2)
43int(2)
44int(0)
45int(0)
46int(2)
47int(2)
48int(2)
49int(0)
50int(0)
51int(0)
52int(0)
53int(0)
54int(0)
55int(0)
56int(2)
57int(0)
58int(2)
59int(0)
60int(0)
61int(0)
62int(0)
63int(0)
64int(0)
65int(0)
66int(0)
67int(0)
68int(0)
69int(0)
70int(0)
71int(0)
72int(0)
73int(0)
74int(0)
75int(0)
76int(0)
77int(0)
78gmp_prob_prime(): Argument #1 ($num) must be of type GMP|string|int, array given
79Done
80