xref: /PHP-7.2/ext/gmp/tests/gmp_pown.phpt (revision 17ccbeec)
1--TEST--
2gmp_powm() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8var_dump(gmp_strval(gmp_powm(0,1,10)));
9var_dump(gmp_strval(gmp_powm(5,1,10)));
10var_dump(gmp_strval(gmp_powm(-5,1,-10)));
11var_dump(gmp_strval(gmp_powm(-5,1,10)));
12var_dump(gmp_strval(gmp_powm(-5,11,10)));
13var_dump(gmp_strval(gmp_powm("77",3,1000)));
14
15$n = gmp_init(11);
16var_dump(gmp_strval(gmp_powm($n,3,1000)));
17$e = gmp_init(7);
18var_dump(gmp_strval(gmp_powm($n,$e,1000)));
19$m = gmp_init(900);
20var_dump(gmp_strval(gmp_powm($n,$e,$m)));
21
22var_dump(gmp_powm(5, 11, 0));
23var_dump(gmp_powm(5, "11", gmp_init(0)));
24
25var_dump(gmp_powm(array(),$e,$m));
26var_dump(gmp_powm($n,array(),$m));
27var_dump(gmp_powm($n,$e,array()));
28var_dump(gmp_powm(array(),array(),array()));
29var_dump(gmp_powm(array(),array()));
30var_dump(gmp_powm(array()));
31var_dump(gmp_powm());
32
33$n = gmp_init("-5");
34var_dump(gmp_powm(10, $n, 10));
35
36$n = gmp_init("0");
37var_dump(gmp_powm(10, $n, 10));
38
39echo "Done\n";
40?>
41--EXPECTF--
42string(1) "0"
43string(1) "5"
44string(1) "5"
45string(1) "5"
46string(1) "5"
47string(3) "533"
48string(3) "331"
49string(3) "171"
50string(3) "371"
51
52Warning: gmp_powm(): Modulus may not be zero in %s on line %d
53bool(false)
54
55Warning: gmp_powm(): Modulus may not be zero in %s on line %d
56bool(false)
57
58Warning: gmp_powm(): Unable to convert variable to GMP - wrong type in %s on line %d
59bool(false)
60
61Warning: gmp_powm(): Unable to convert variable to GMP - wrong type in %s on line %d
62bool(false)
63
64Warning: gmp_powm(): Unable to convert variable to GMP - wrong type in %s on line %d
65bool(false)
66
67Warning: gmp_powm(): Unable to convert variable to GMP - wrong type in %s on line %d
68bool(false)
69
70Warning: gmp_powm() expects exactly 3 parameters, 2 given in %s on line %d
71NULL
72
73Warning: gmp_powm() expects exactly 3 parameters, 1 given in %s on line %d
74NULL
75
76Warning: gmp_powm() expects exactly 3 parameters, 0 given in %s on line %d
77NULL
78
79Warning: gmp_powm(): Second parameter cannot be less than 0 in %s on line %d
80bool(false)
81object(GMP)#%d (1) {
82  ["num"]=>
83  string(1) "1"
84}
85Done
86