Skip to content

Commit b937674

Browse files
committed
Work around gmp_pow behavior change
1 parent 75ffba9 commit b937674

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tests/MaxMind/Db/Test/Reader/DecoderTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,14 @@ public function generateLargeUint(int $bits): array
306306

307307
for ($power = 1; $power <= $bits / 8; ++$power) {
308308
if (\extension_loaded('gmp')) {
309-
$expected = gmp_strval(gmp_sub(gmp_pow('2', 8 * $power), '1'));
309+
// This is to work around the limit added to gmp_pow here:
310+
// https://github.com/php/php-src/commit/e0a0e216a909dc4ee4ea7c113a5f41d49525f02e
311+
$v = 1;
312+
for ($i = 0; $i < $power; $i++) {
313+
$v = gmp_mul($v, 256);
314+
}
315+
316+
$expected = gmp_strval(gmp_sub($v, '1'));
310317
} elseif (\extension_loaded('bcmath')) {
311318
$expected = bcsub(bcpow('2', (string) (8 * $power)), '1');
312319
} else {

0 commit comments

Comments
 (0)