1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 01:02:25 +01:00
Files
archived-php-src/ext/standard/tests/array/range_errors.phpt
2019-03-11 11:32:20 +01:00

96 lines
2.4 KiB
PHP

--TEST--
Test range() function (errors)
--INI--
precision=14
--FILE--
<?php
echo "\n*** Testing error conditions ***\n";
echo "\n-- Testing ( (low < high) && (step = 0) ) --";
var_dump( range(1, 2, 0) );
var_dump( range("a", "b", 0) );
echo "\n\n-- Testing ( (low > high) && (step = 0) ) --";
var_dump( range(2, 1, 0) );
var_dump( range("b", "a", 0) );
echo "\n\n-- Testing ( (low < high) && (high-low < step) ) --";
var_dump( range(1.0, 7.0, 6.5) );
echo "\n\n-- Testing ( (low > high) && (low-high < step) ) --";
var_dump( range(7.0, 1.0, 6.5) );
echo "\n-- Testing other conditions --";
var_dump( range(-1, -2, 2) );
var_dump( range("a", "j", "z") );
var_dump( range(0, 1, "140962482048819216326.24") );
var_dump( range(0, 1, "140962482048819216326.24.") );
echo "\n-- Testing Invalid steps --";
$step_arr = array( "string", NULL, FALSE, "", "\0" );
foreach( $step_arr as $step ) {
var_dump( range( 1, 5, $step ) );
}
echo "Done\n";
?>
--EXPECTF--
*** Testing error conditions ***
-- Testing ( (low < high) && (step = 0) ) --
Warning: range(): step exceeds the specified range in %s on line %d
bool(false)
Warning: range(): step exceeds the specified range in %s on line %d
bool(false)
-- Testing ( (low > high) && (step = 0) ) --
Warning: range(): step exceeds the specified range in %s on line %d
bool(false)
Warning: range(): step exceeds the specified range in %s on line %d
bool(false)
-- Testing ( (low < high) && (high-low < step) ) --
Warning: range(): step exceeds the specified range in %s on line %d
bool(false)
-- Testing ( (low > high) && (low-high < step) ) --
Warning: range(): step exceeds the specified range in %s on line %d
bool(false)
-- Testing other conditions --
Warning: range(): step exceeds the specified range in %s on line %d
bool(false)
Warning: range(): Invalid range string - must be numeric in %s on line %d
bool(false)
Warning: range(): step exceeds the specified range in %s on line %d
bool(false)
Warning: range(): Invalid range string - must be numeric in %s on line %d
bool(false)
-- Testing Invalid steps --
Warning: range(): Invalid range string - must be numeric in %s on line %d
bool(false)
Warning: range(): step exceeds the specified range in %s on line %d
bool(false)
Warning: range(): step exceeds the specified range in %s on line %d
bool(false)
Warning: range(): Invalid range string - must be numeric in %s on line %d
bool(false)
Warning: range(): Invalid range string - must be numeric in %s on line %d
bool(false)
Done