test: split PHP 8.5 numeric warnings

debug/ci-class-id-cache
韩天峰 1 hour ago
parent 74274f8328
commit 7973f99f47
  1. 6
      tests/compiler/basic/pow-int-overflow-native-type.phpt
  2. 20
      tests/compiler/basic/pow-int-overflow-warning-php85.phpt
  3. 6
      tests/compiler/float_edge/edge-cases.phpt
  4. 18
      tests/compiler/float_edge/nan-string-warning-php85.phpt

@ -5,9 +5,13 @@ pow int overflow
use native_types;
function main()
{
// PHP 8.5 warns when the overflowing float is narrowed to a native int.
// This test covers the resulting value; a version-specific companion test
// covers the warning so this expectation remains stable on PHP 8.4/8.5.
error_reporting(E_ERROR);
$a = 2 ** 80;
echo $a, PHP_EOL;
}
?>
--EXPECT--
0
0

@ -0,0 +1,20 @@
--TEST--
PHP 8.5 warns when pow overflow is narrowed to a native int
--SKIPIF--
<?php
if (PHP_VERSION_ID < 80500) {
die('skip requires PHP 8.5 or newer');
}
?>
--FILE--
<?php
use native_types;
function main(): void
{
$value = 2 ** 80;
echo $value, PHP_EOL;
}
?>
--EXPECTF--
Warning: The float %s is not representable as an int, cast occurred in %s on line %d
0

@ -3,6 +3,7 @@ Float edge cases: NAN, INF, -INF
--FILE--
<?php
function main(): void {
error_reporting(E_ERROR);
var_dump(NAN);
var_dump(INF);
var_dump(-INF);
@ -13,7 +14,10 @@ function main(): void {
var_dump(is_infinite(1.5));
var_dump(is_finite(INF));
var_dump(is_finite(1.5));
echo NAN . "\n";
// Keep the NAN-to-string conversion at runtime so error_reporting() can
// suppress PHP 8.5's new warning in this cross-version value test.
$nan = NAN;
echo $nan . "\n";
echo INF . "\n";
echo -INF . "\n";
var_dump(INF + INF);

@ -0,0 +1,18 @@
--TEST--
PHP 8.5 warns when NAN is coerced to string
--SKIPIF--
<?php
if (PHP_VERSION_ID < 80500) {
die('skip requires PHP 8.5 or newer');
}
?>
--FILE--
<?php
function main(): void
{
echo NAN . "\n";
}
?>
--EXPECTF--
Warning: unexpected NAN value was coerced to string in %s on line %d
NAN
Loading…
Cancel
Save