xref: /PHP-7.4/ext/gmp/tests/gmp_pow.phpt (revision 782352c5)
1--TEST--
2gmp_pow() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8var_dump(gmp_strval(gmp_pow(2,10)));
9var_dump(gmp_strval(gmp_pow(-2,10)));
10var_dump(gmp_strval(gmp_pow(-2,11)));
11var_dump(gmp_strval(gmp_pow("2",10)));
12var_dump(gmp_strval(gmp_pow("2",0)));
13var_dump(gmp_strval(gmp_pow("2",-1)));
14var_dump(gmp_strval(gmp_pow("-2",10)));
15var_dump(gmp_strval(gmp_pow(20,10)));
16var_dump(gmp_strval(gmp_pow(50,10)));
17var_dump(gmp_strval(gmp_pow(50,-5)));
18
19$n = gmp_init("20");
20var_dump(gmp_strval(gmp_pow($n,10)));
21$n = gmp_init("-20");
22var_dump(gmp_strval(gmp_pow($n,10)));
23
24var_dump(gmp_pow(2,10,1));
25var_dump(gmp_pow(2));
26var_dump(gmp_pow());
27var_dump(gmp_pow(array(), array()));
28var_dump(gmp_pow(2,array()));
29var_dump(gmp_pow(array(),10));
30
31echo "Done\n";
32?>
33--EXPECTF--
34string(4) "1024"
35string(4) "1024"
36string(5) "-2048"
37string(4) "1024"
38string(1) "1"
39
40Warning: gmp_pow(): Negative exponent not supported in %s on line %d
41string(1) "0"
42string(4) "1024"
43string(14) "10240000000000"
44string(17) "97656250000000000"
45
46Warning: gmp_pow(): Negative exponent not supported in %s on line %d
47string(1) "0"
48string(14) "10240000000000"
49string(14) "10240000000000"
50
51Warning: gmp_pow() expects exactly 2 parameters, 3 given in %s on line %d
52NULL
53
54Warning: gmp_pow() expects exactly 2 parameters, 1 given in %s on line %d
55NULL
56
57Warning: gmp_pow() expects exactly 2 parameters, 0 given in %s on line %d
58NULL
59
60Warning: gmp_pow() expects parameter 2 to be int, array given in %s on line %d
61NULL
62
63Warning: gmp_pow() expects parameter 2 to be int, array given in %s on line %d
64NULL
65
66Warning: gmp_pow(): Unable to convert variable to GMP - wrong type in %s on line %d
67bool(false)
68Done
69