From b937674e7f981e0faf9090a036c8c89d1a38861a Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 14 Nov 2024 14:05:39 -0800 Subject: [PATCH] Work around gmp_pow behavior change --- tests/MaxMind/Db/Test/Reader/DecoderTest.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/MaxMind/Db/Test/Reader/DecoderTest.php b/tests/MaxMind/Db/Test/Reader/DecoderTest.php index d2ebdeb..e935452 100644 --- a/tests/MaxMind/Db/Test/Reader/DecoderTest.php +++ b/tests/MaxMind/Db/Test/Reader/DecoderTest.php @@ -306,7 +306,14 @@ public function generateLargeUint(int $bits): array for ($power = 1; $power <= $bits / 8; ++$power) { if (\extension_loaded('gmp')) { - $expected = gmp_strval(gmp_sub(gmp_pow('2', 8 * $power), '1')); + // This is to work around the limit added to gmp_pow here: + // https://github.com/php/php-src/commit/e0a0e216a909dc4ee4ea7c113a5f41d49525f02e + $v = 1; + for ($i = 0; $i < $power; $i++) { + $v = gmp_mul($v, 256); + } + + $expected = gmp_strval(gmp_sub($v, '1')); } elseif (\extension_loaded('bcmath')) { $expected = bcsub(bcpow('2', (string) (8 * $power)), '1'); } else {