xref: /PHP-7.4/ext/gmp/tests/gmp_fact.phpt (revision 782352c5)
1--TEST--
2gmp_fact() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8var_dump(gmp_strval(gmp_fact(0)));
9var_dump(gmp_strval(gmp_fact("")));
10var_dump(gmp_strval(gmp_fact("0")));
11var_dump(gmp_strval(gmp_fact("-1")));
12var_dump(gmp_strval(gmp_fact(-1)));
13var_dump(gmp_strval(gmp_fact(1.1)));
14var_dump(gmp_strval(gmp_fact(20)));
15var_dump(gmp_strval(gmp_fact("50")));
16var_dump(gmp_strval(gmp_fact("10")));
17var_dump(gmp_strval(gmp_fact("0000")));
18
19$n = gmp_init(12);
20var_dump(gmp_strval(gmp_fact($n)));
21$n = gmp_init(-10);
22var_dump(gmp_strval(gmp_fact($n)));
23
24var_dump(gmp_fact());
25var_dump(gmp_fact(1,1));
26var_dump(gmp_fact(array()));
27var_dump(gmp_strval(gmp_fact(array())));
28
29echo "Done\n";
30?>
31--EXPECTF--
32string(1) "1"
33string(1) "1"
34string(1) "1"
35
36Warning: gmp_fact(): Number has to be greater than or equal to 0 in %s on line %d
37string(1) "0"
38
39Warning: gmp_fact(): Number has to be greater than or equal to 0 in %s on line %d
40string(1) "0"
41
42Warning: gmp_fact(): Number has to be an integer in %s on line %d
43string(1) "1"
44string(19) "2432902008176640000"
45string(65) "30414093201713378043612608166064768844377641568960512000000000000"
46string(7) "3628800"
47string(1) "1"
48string(9) "479001600"
49
50Warning: gmp_fact(): Number has to be greater than or equal to 0 in %s on line %d
51string(1) "0"
52
53Warning: gmp_fact() expects exactly 1 parameter, 0 given in %s on line %d
54NULL
55
56Warning: gmp_fact() expects exactly 1 parameter, 2 given in %s on line %d
57NULL
58
59Warning: gmp_fact(): Number has to be an integer in %s on line %d
60object(GMP)#%d (1) {
61  ["num"]=>
62  string(1) "1"
63}
64
65Warning: gmp_fact(): Number has to be an integer in %s on line %d
66string(1) "1"
67Done
68