From cd05b56a6f7d4f03a80f86c15248eda995b1762e Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Fri, 11 Sep 2020 17:40:06 +0200 Subject: Promote some warnings in BCMath to Errors Also do a bit of refactoring at the same time. Closes GH-6105 --- ext/bcmath/tests/bcpow_error1.phpt | 11 +++++++---- ext/bcmath/tests/bcpow_error2.phpt | 11 +++++++---- ext/bcmath/tests/bcpowmod.phpt | 14 ++++++++------ ext/bcmath/tests/bcpowmod_negative_exponent.phpt | 2 +- ext/bcmath/tests/bcpowmod_zero_modulus.phpt | 2 +- ext/bcmath/tests/bcsqrt_error1.phpt | 2 +- ext/bcmath/tests/bug72093.phpt | 12 +++++++----- ext/bcmath/tests/bug75178.phpt | 21 +++++++++++++-------- ext/bcmath/tests/bug78878.phpt | 8 ++++++-- 9 files changed, 51 insertions(+), 32 deletions(-) (limited to 'ext/bcmath/tests') diff --git a/ext/bcmath/tests/bcpow_error1.phpt b/ext/bcmath/tests/bcpow_error1.phpt index 822b70eb86..38d9bda181 100644 --- a/ext/bcmath/tests/bcpow_error1.phpt +++ b/ext/bcmath/tests/bcpow_error1.phpt @@ -6,8 +6,11 @@ if (!extension_loaded('bcmath')) die('skip bcmath extension is not available'); ?> --FILE-- getMessage() . \PHP_EOL; +} ?> ---EXPECTF-- -Warning: bcpow(): Non-zero scale in exponent in %s on line %d -string(4) "1.00" +--EXPECT-- +bcpow(): Argument #2 ($exponent) cannot have a fractional part diff --git a/ext/bcmath/tests/bcpow_error2.phpt b/ext/bcmath/tests/bcpow_error2.phpt index 95c3f80b08..d6271b18eb 100644 --- a/ext/bcmath/tests/bcpow_error2.phpt +++ b/ext/bcmath/tests/bcpow_error2.phpt @@ -6,8 +6,11 @@ if (!extension_loaded('bcmath')) die('skip bcmath extension is not available'); ?> --FILE-- getMessage() . \PHP_EOL; +} ?> ---EXPECTF-- -Warning: bcpow(): Exponent too large in %s on line %d -string(4) "1.00" +--EXPECT-- +bcpow(): Argument #2 ($exponent) is too large diff --git a/ext/bcmath/tests/bcpowmod.phpt b/ext/bcmath/tests/bcpowmod.phpt index 5f0fa8a93b..c171e2d4a1 100644 --- a/ext/bcmath/tests/bcpowmod.phpt +++ b/ext/bcmath/tests/bcpowmod.phpt @@ -6,11 +6,13 @@ bcpowmod() - Raise an arbitrary precision number to another, reduced by a specif bcmath.scale=0 --FILE-- --EXPECT-- -4 --4 -790 +string(1) "4" +string(2) "-4" +string(3) "790" +string(1) "1" diff --git a/ext/bcmath/tests/bcpowmod_negative_exponent.phpt b/ext/bcmath/tests/bcpowmod_negative_exponent.phpt index a72b39548b..518f9eb0a9 100644 --- a/ext/bcmath/tests/bcpowmod_negative_exponent.phpt +++ b/ext/bcmath/tests/bcpowmod_negative_exponent.phpt @@ -13,4 +13,4 @@ try { } ?> --EXPECT-- -bcpowmod(): Argument #2 ($exponent) must be greater than 0 +bcpowmod(): Argument #2 ($exponent) must be greater than or equal to 0 diff --git a/ext/bcmath/tests/bcpowmod_zero_modulus.phpt b/ext/bcmath/tests/bcpowmod_zero_modulus.phpt index 0b810969c6..bc30dc0afd 100644 --- a/ext/bcmath/tests/bcpowmod_zero_modulus.phpt +++ b/ext/bcmath/tests/bcpowmod_zero_modulus.phpt @@ -7,7 +7,7 @@ Gabriel Caruso (carusogabriel34@gmail.com) --FILE-- getMessage(), PHP_EOL; } diff --git a/ext/bcmath/tests/bcsqrt_error1.phpt b/ext/bcmath/tests/bcsqrt_error1.phpt index bbc69f3952..83c85183f4 100644 --- a/ext/bcmath/tests/bcsqrt_error1.phpt +++ b/ext/bcmath/tests/bcsqrt_error1.phpt @@ -14,4 +14,4 @@ try { } ?> --EXPECT-- -Square root of negative number +bcsqrt(): Argument #1 ($operand) must be greater than or equal to 0 diff --git a/ext/bcmath/tests/bug72093.phpt b/ext/bcmath/tests/bug72093.phpt index 7111bf6e3a..3a6405d04a 100644 --- a/ext/bcmath/tests/bug72093.phpt +++ b/ext/bcmath/tests/bug72093.phpt @@ -11,10 +11,12 @@ try { } catch (\ValueError $e) { echo $e->getMessage() . \PHP_EOL; } -var_dump(bcpowmod(1, 1.2, 1, 1)); +try { + var_dump(bcpowmod(1, 1.2, 1, 1)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} ?> ---EXPECTF-- +--EXPECT-- bcpowmod(): Argument #4 ($scale) must be between 0 and 2147483647 - -Warning: bcpowmod(): Non-zero scale in exponent in %s on line %d -string(3) "0.0" +bcpowmod(): Argument #2 ($exponent) cannot have a fractional part diff --git a/ext/bcmath/tests/bug75178.phpt b/ext/bcmath/tests/bug75178.phpt index 2b7ab4b2c6..4804452384 100644 --- a/ext/bcmath/tests/bug75178.phpt +++ b/ext/bcmath/tests/bug75178.phpt @@ -6,12 +6,17 @@ if (!extension_loaded('bcmath')) die('skip bcmath extension is not available'); ?> --FILE-- getMessage() . \PHP_EOL; +} +try { + var_dump(bcpowmod('4', '4', '3.1', 3)); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; +} ?> ---EXPECTF-- -Warning: bcpowmod(): Non-zero scale in base in %s on line %d -string(5) "1.000" - -Warning: bcpowmod(): Non-zero scale in modulus in %s on line %d -string(5) "1.000" +--EXPECT-- +bcpowmod(): Argument #1 ($base) cannot have a fractional part +bcpowmod(): Argument #3 ($modulus) cannot have a fractional part diff --git a/ext/bcmath/tests/bug78878.phpt b/ext/bcmath/tests/bug78878.phpt index 066d411c90..7edc666f75 100644 --- a/ext/bcmath/tests/bug78878.phpt +++ b/ext/bcmath/tests/bug78878.phpt @@ -6,7 +6,11 @@ if (!extension_loaded('bcmath')) die('skip bcmath extension not available'); ?> --FILE-- getMessage() . \PHP_EOL; +} ?> --EXPECT-- -0 +bcpowmod(): Argument #3 ($modulus) cannot have a fractional part -- cgit v1.2.1