Skip to content

Commit 1ef87ac

Browse files
committed
fix tests on 32 bits attempt.
note: using consistent "style" for test on purpose.
1 parent 7f432a1 commit 1ef87ac

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

ext/gmp/tests/gmp_pow.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
gmp_pow() basic tests
33
--EXTENSIONS--
44
gmp
5+
--SKIPIF--
6+
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?>
57
--FILE--
68
<?php
79

ext/gmp/tests/gmp_pow_32bits.phpt

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
--TEST--
2+
gmp_pow() basic tests
3+
--EXTENSIONS--
4+
gmp
5+
--SKIPIF--
6+
<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?>
7+
--FILE--
8+
<?php
9+
10+
var_dump(gmp_strval(gmp_pow(2,10)));
11+
var_dump(gmp_strval(gmp_pow(-2,10)));
12+
var_dump(gmp_strval(gmp_pow(-2,11)));
13+
var_dump(gmp_strval(gmp_pow("2",10)));
14+
var_dump(gmp_strval(gmp_pow("2",0)));
15+
try {
16+
gmp_pow("2", -1);
17+
} catch (ValueError $exception) {
18+
echo $exception->getMessage() . "\n";
19+
}
20+
var_dump(gmp_strval(gmp_pow("-2",10)));
21+
try {
22+
gmp_pow(20,10);
23+
} catch (ValueError $exception) {
24+
echo $exception->getMessage() . "\n";
25+
}
26+
try {
27+
gmp_pow(50,10)));
28+
} catch (ValueError $exception) {
29+
echo $exception->getMessage() . "\n";
30+
}
31+
try {
32+
gmp_pow(50,-5);
33+
} catch (ValueError $exception) {
34+
echo $exception->getMessage() . "\n";
35+
}
36+
try {
37+
$n = gmp_init("20");
38+
gmp_pow($n,10);
39+
} catch (ValueError $exception) {
40+
echo $exception->getMessage() . "\n";
41+
}
42+
try {
43+
$n = gmp_init("-20");
44+
gmp_pow($n,10);
45+
} catch (ValueError $exception) {
46+
echo $exception->getMessage() . "\n";
47+
}
48+
try {
49+
var_dump(gmp_pow(2,array()));
50+
} catch (TypeError $e) {
51+
echo $e->getMessage(), "\n";
52+
}
53+
54+
try {
55+
var_dump(gmp_pow(array(),10));
56+
} catch (\TypeError $e) {
57+
echo $e->getMessage() . \PHP_EOL;
58+
}
59+
60+
echo "Done\n";
61+
?>
62+
--EXPECT--
63+
string(4) "1024"
64+
string(4) "1024"
65+
string(5) "-2048"
66+
string(4) "1024"
67+
string(1) "1"
68+
gmp_pow(): Argument #2 ($exponent) must be greater than or equal to 0
69+
string(4) "1024"
70+
base and exponent overflow
71+
base and exponent overflow
72+
gmp_pow(): Argument #2 ($exponent) must be greater than or equal to 0
73+
base and exponent overflow
74+
base and exponent overflow
75+
gmp_pow(): Argument #2 ($exponent) must be of type int, array given
76+
gmp_pow(): Argument #1 ($num) must be of type GMP|string|int, array given
77+
Done

0 commit comments

Comments
 (0)