xref: /PHP-5.4/ext/gmp/tests/016.phpt (revision eb5bd09c)
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(array(),$e,$m));
23var_dump(gmp_powm($n,array(),$m));
24var_dump(gmp_powm($n,$e,array()));
25var_dump(gmp_powm(array(),array(),array()));
26var_dump(gmp_powm(array(),array()));
27var_dump(gmp_powm(array()));
28var_dump(gmp_powm());
29
30$n = gmp_init("-5");
31var_dump(gmp_powm(10, $n, 10));
32
33$n = gmp_init("0");
34var_dump(gmp_powm(10, $n, 10));
35
36echo "Done\n";
37?>
38--EXPECTF--
39string(1) "0"
40string(1) "5"
41string(1) "5"
42string(1) "5"
43string(1) "5"
44string(3) "533"
45string(3) "331"
46string(3) "171"
47string(3) "371"
48
49Warning: gmp_powm(): Unable to convert variable to GMP - wrong type in %s on line %d
50bool(false)
51
52Warning: gmp_powm(): Unable to convert variable to GMP - wrong type in %s on line %d
53bool(false)
54
55Warning: gmp_powm(): Unable to convert variable to GMP - wrong type 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() expects exactly 3 parameters, 2 given in %s on line %d
62NULL
63
64Warning: gmp_powm() expects exactly 3 parameters, 1 given in %s on line %d
65NULL
66
67Warning: gmp_powm() expects exactly 3 parameters, 0 given in %s on line %d
68NULL
69
70Warning: gmp_powm(): Second parameter cannot be less than 0 in %s on line %d
71bool(false)
72resource(%d) of type (GMP integer)
73Done
74