diff options
author | George Peter Banyard <girgias@php.net> | 2020-09-13 00:43:00 +0200 |
---|---|---|
committer | George Peter Banyard <girgias@php.net> | 2020-09-14 13:40:07 +0200 |
commit | 31ef94cd4223718dafb2334c8b46db54b7f24a82 (patch) | |
tree | 97b033d80e4379d68f83134ccc2273632da2b0dc /tests | |
parent | bf515649ff7840f7180b02b04ada8bc8587c70c6 (diff) | |
download | php-git-31ef94cd4223718dafb2334c8b46db54b7f24a82.tar.gz |
Convert Division by 0 warnings to Error per the Engine Warning RFC
Closes GH-6125
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lang/operators/divide_basiclong_64bit.phpt | 42 | ||||
-rw-r--r-- | tests/lang/operators/divide_variationStr.phpt | 26 |
2 files changed, 37 insertions, 31 deletions
diff --git a/tests/lang/operators/divide_basiclong_64bit.phpt b/tests/lang/operators/divide_basiclong_64bit.phpt index 358d068843..65ab5b69a2 100644 --- a/tests/lang/operators/divide_basiclong_64bit.phpt +++ b/tests/lang/operators/divide_basiclong_64bit.phpt @@ -23,10 +23,14 @@ $otherVals = array(0, 1, -1, 7, 9, 65, -44, MAX_32Bit, MAX_64Bit); error_reporting(E_ERROR); foreach ($longVals as $longVal) { - foreach($otherVals as $otherVal) { - echo "--- testing: $longVal / $otherVal ---\n"; - var_dump($longVal/$otherVal); - } + foreach($otherVals as $otherVal) { + echo "--- testing: $longVal / $otherVal ---\n"; + try { + var_dump($longVal/$otherVal); + } catch (\Throwable $e) { + echo get_class($e) . ': ' . $e->getMessage() . \PHP_EOL; + } + } } foreach ($otherVals as $otherVal) { @@ -39,7 +43,7 @@ foreach ($otherVals as $otherVal) { ?> --EXPECT-- --- testing: 9223372036854775807 / 0 --- -float(INF) +DivisionByZeroError: Division by zero --- testing: 9223372036854775807 / 1 --- int(9223372036854775807) --- testing: 9223372036854775807 / -1 --- @@ -57,7 +61,7 @@ float(4294967298) --- testing: 9223372036854775807 / 9223372036854775807 --- int(1) --- testing: -9223372036854775808 / 0 --- -float(-INF) +DivisionByZeroError: Division by zero --- testing: -9223372036854775808 / 1 --- int(-9223372036854775808) --- testing: -9223372036854775808 / -1 --- @@ -75,7 +79,7 @@ float(-4294967298) --- testing: -9223372036854775808 / 9223372036854775807 --- float(-1) --- testing: 2147483647 / 0 --- -float(INF) +DivisionByZeroError: Division by zero --- testing: 2147483647 / 1 --- int(2147483647) --- testing: 2147483647 / -1 --- @@ -93,7 +97,7 @@ int(1) --- testing: 2147483647 / 9223372036854775807 --- float(2.328306435454494E-10) --- testing: -2147483648 / 0 --- -float(-INF) +DivisionByZeroError: Division by zero --- testing: -2147483648 / 1 --- int(-2147483648) --- testing: -2147483648 / -1 --- @@ -111,7 +115,7 @@ float(-1.0000000004656613) --- testing: -2147483648 / 9223372036854775807 --- float(-2.3283064365386963E-10) --- testing: 9223372034707292160 / 0 --- -float(INF) +DivisionByZeroError: Division by zero --- testing: 9223372034707292160 / 1 --- int(9223372034707292160) --- testing: 9223372034707292160 / -1 --- @@ -129,7 +133,7 @@ float(4294967297) --- testing: 9223372034707292160 / 9223372036854775807 --- float(0.9999999997671694) --- testing: -9223372034707292160 / 0 --- -float(-INF) +DivisionByZeroError: Division by zero --- testing: -9223372034707292160 / 1 --- int(-9223372034707292160) --- testing: -9223372034707292160 / -1 --- @@ -147,7 +151,7 @@ float(-4294967297) --- testing: -9223372034707292160 / 9223372036854775807 --- float(-0.9999999997671694) --- testing: 2147483648 / 0 --- -float(INF) +DivisionByZeroError: Division by zero --- testing: 2147483648 / 1 --- int(2147483648) --- testing: 2147483648 / -1 --- @@ -165,7 +169,7 @@ float(1.0000000004656613) --- testing: 2147483648 / 9223372036854775807 --- float(2.3283064365386963E-10) --- testing: -2147483649 / 0 --- -float(-INF) +DivisionByZeroError: Division by zero --- testing: -2147483649 / 1 --- int(-2147483649) --- testing: -2147483649 / -1 --- @@ -183,7 +187,7 @@ float(-1.0000000009313226) --- testing: -2147483649 / 9223372036854775807 --- float(-2.3283064376228985E-10) --- testing: 4294967294 / 0 --- -float(INF) +DivisionByZeroError: Division by zero --- testing: 4294967294 / 1 --- int(4294967294) --- testing: 4294967294 / -1 --- @@ -201,7 +205,7 @@ int(2) --- testing: 4294967294 / 9223372036854775807 --- float(4.656612870908988E-10) --- testing: 4294967295 / 0 --- -float(INF) +DivisionByZeroError: Division by zero --- testing: 4294967295 / 1 --- int(4294967295) --- testing: 4294967295 / -1 --- @@ -219,7 +223,7 @@ float(2.0000000004656613) --- testing: 4294967295 / 9223372036854775807 --- float(4.6566128719931904E-10) --- testing: 4294967293 / 0 --- -float(INF) +DivisionByZeroError: Division by zero --- testing: 4294967293 / 1 --- int(4294967293) --- testing: 4294967293 / -1 --- @@ -237,7 +241,7 @@ float(1.9999999995343387) --- testing: 4294967293 / 9223372036854775807 --- float(4.656612869824786E-10) --- testing: 9223372036854775806 / 0 --- -float(INF) +DivisionByZeroError: Division by zero --- testing: 9223372036854775806 / 1 --- int(9223372036854775806) --- testing: 9223372036854775806 / -1 --- @@ -255,7 +259,7 @@ int(4294967298) --- testing: 9223372036854775806 / 9223372036854775807 --- float(1) --- testing: 9.2233720368548E+18 / 0 --- -float(INF) +DivisionByZeroError: Division by zero --- testing: 9.2233720368548E+18 / 1 --- float(9.223372036854776E+18) --- testing: 9.2233720368548E+18 / -1 --- @@ -273,7 +277,7 @@ float(4294967298) --- testing: 9.2233720368548E+18 / 9223372036854775807 --- float(1) --- testing: -9223372036854775807 / 0 --- -float(-INF) +DivisionByZeroError: Division by zero --- testing: -9223372036854775807 / 1 --- int(-9223372036854775807) --- testing: -9223372036854775807 / -1 --- @@ -291,7 +295,7 @@ float(-4294967298) --- testing: -9223372036854775807 / 9223372036854775807 --- int(-1) --- testing: -9.2233720368548E+18 / 0 --- -float(-INF) +DivisionByZeroError: Division by zero --- testing: -9.2233720368548E+18 / 1 --- float(-9.223372036854776E+18) --- testing: -9.2233720368548E+18 / -1 --- diff --git a/tests/lang/operators/divide_variationStr.phpt b/tests/lang/operators/divide_variationStr.phpt index be7118edbd..6c62972ffd 100644 --- a/tests/lang/operators/divide_variationStr.phpt +++ b/tests/lang/operators/divide_variationStr.phpt @@ -17,6 +17,8 @@ foreach ($strVals as $strVal) { var_dump($strVal/$otherVal); } catch (\TypeError $e) { echo $e->getMessage() . \PHP_EOL; + } catch (\DivisionByZeroError $e) { + echo $e->getMessage() . \PHP_EOL; } } } @@ -25,7 +27,7 @@ foreach ($strVals as $strVal) { ?> --EXPECT-- --- testing: '0'/'0' --- -float(NAN) +Division by zero --- testing: '0'/'65' --- int(0) --- testing: '0'/'-44' --- @@ -53,7 +55,7 @@ float(0) --- testing: '0'/'a5.9' --- Unsupported operand types: string / string --- testing: '65'/'0' --- -float(INF) +Division by zero --- testing: '65'/'65' --- int(1) --- testing: '65'/'-44' --- @@ -81,7 +83,7 @@ float(19.11764705882353) --- testing: '65'/'a5.9' --- Unsupported operand types: string / string --- testing: '-44'/'0' --- -float(-INF) +Division by zero --- testing: '-44'/'65' --- float(-0.676923076923077) --- testing: '-44'/'-44' --- @@ -109,7 +111,7 @@ float(-12.941176470588236) --- testing: '-44'/'a5.9' --- Unsupported operand types: string / string --- testing: '1.2'/'0' --- -float(INF) +Division by zero --- testing: '1.2'/'65' --- float(0.01846153846153846) --- testing: '1.2'/'-44' --- @@ -137,7 +139,7 @@ float(0.35294117647058826) --- testing: '1.2'/'a5.9' --- Unsupported operand types: string / string --- testing: '-7.7'/'0' --- -float(-INF) +Division by zero --- testing: '-7.7'/'65' --- float(-0.11846153846153847) --- testing: '-7.7'/'-44' --- @@ -193,7 +195,7 @@ Unsupported operand types: string / string --- testing: 'abc'/'a5.9' --- Unsupported operand types: string / string --- testing: '123abc'/'0' --- -float(INF) +Division by zero --- testing: '123abc'/'65' --- float(1.8923076923076922) --- testing: '123abc'/'-44' --- @@ -221,7 +223,7 @@ float(36.1764705882353) --- testing: '123abc'/'a5.9' --- Unsupported operand types: string / string --- testing: '123e5'/'0' --- -float(INF) +Division by zero --- testing: '123e5'/'65' --- float(189230.76923076922) --- testing: '123e5'/'-44' --- @@ -249,7 +251,7 @@ float(3617647.0588235296) --- testing: '123e5'/'a5.9' --- Unsupported operand types: string / string --- testing: '123e5xyz'/'0' --- -float(INF) +Division by zero --- testing: '123e5xyz'/'65' --- float(189230.76923076922) --- testing: '123e5xyz'/'-44' --- @@ -277,7 +279,7 @@ float(3617647.0588235296) --- testing: '123e5xyz'/'a5.9' --- Unsupported operand types: string / string --- testing: ' 123abc'/'0' --- -float(INF) +Division by zero --- testing: ' 123abc'/'65' --- float(1.8923076923076922) --- testing: ' 123abc'/'-44' --- @@ -305,7 +307,7 @@ float(36.1764705882353) --- testing: ' 123abc'/'a5.9' --- Unsupported operand types: string / string --- testing: '123 abc'/'0' --- -float(INF) +Division by zero --- testing: '123 abc'/'65' --- float(1.8923076923076922) --- testing: '123 abc'/'-44' --- @@ -333,7 +335,7 @@ float(36.1764705882353) --- testing: '123 abc'/'a5.9' --- Unsupported operand types: string / string --- testing: '123abc '/'0' --- -float(INF) +Division by zero --- testing: '123abc '/'65' --- float(1.8923076923076922) --- testing: '123abc '/'-44' --- @@ -361,7 +363,7 @@ float(36.1764705882353) --- testing: '123abc '/'a5.9' --- Unsupported operand types: string / string --- testing: '3.4a'/'0' --- -float(INF) +Division by zero --- testing: '3.4a'/'65' --- float(0.052307692307692305) --- testing: '3.4a'/'-44' --- |