1--TEST-- 2Test range() function (errors) 3--INI-- 4precision=14 5--FILE-- 6<?php 7 8echo "\n*** Testing error conditions ***\n"; 9 10echo "\n-- Testing ( (low < high) && (step = 0) ) --"; 11var_dump( range(1, 2, 0) ); 12var_dump( range("a", "b", 0) ); 13 14echo "\n\n-- Testing ( (low > high) && (step = 0) ) --"; 15var_dump( range(2, 1, 0) ); 16var_dump( range("b", "a", 0) ); 17 18echo "\n\n-- Testing ( (low < high) && (high-low < step) ) --"; 19var_dump( range(1.0, 7.0, 6.5) ); 20 21echo "\n\n-- Testing ( (low > high) && (low-high < step) ) --"; 22var_dump( range(7.0, 1.0, 6.5) ); 23 24echo "\n-- Testing Invalid number of arguments --"; 25var_dump( range() ); // No.of args = 0 26var_dump( range(1) ); // No.of args < expected 27var_dump( range(1,2,3,4) ); // No.of args > expected 28var_dump( range(-1, -2, 2) ); 29var_dump( range("a", "j", "z") ); 30var_dump( range(0, 1, "140962482048819216326.24") ); 31var_dump( range(0, 1, "140962482048819216326.24.") ); 32 33echo "\n-- Testing Invalid steps --"; 34$step_arr = array( "string", NULL, FALSE, "", "\0" ); 35 36foreach( $step_arr as $step ) { 37 var_dump( range( 1, 5, $step ) ); 38} 39 40echo "Done\n"; 41?> 42--EXPECTF-- 43*** Testing error conditions *** 44 45-- Testing ( (low < high) && (step = 0) ) -- 46Warning: range(): step exceeds the specified range in %s on line %d 47bool(false) 48 49Warning: range(): step exceeds the specified range in %s on line %d 50bool(false) 51 52 53-- Testing ( (low > high) && (step = 0) ) -- 54Warning: range(): step exceeds the specified range in %s on line %d 55bool(false) 56 57Warning: range(): step exceeds the specified range in %s on line %d 58bool(false) 59 60 61-- Testing ( (low < high) && (high-low < step) ) -- 62Warning: range(): step exceeds the specified range in %s on line %d 63bool(false) 64 65 66-- Testing ( (low > high) && (low-high < step) ) -- 67Warning: range(): step exceeds the specified range in %s on line %d 68bool(false) 69 70-- Testing Invalid number of arguments -- 71Warning: range() expects at least 2 parameters, 0 given in %s on line %d 72bool(false) 73 74Warning: range() expects at least 2 parameters, 1 given in %s on line %d 75bool(false) 76 77Warning: range() expects at most 3 parameters, 4 given in %s on line %d 78bool(false) 79 80Warning: range(): step exceeds the specified range in %s on line %d 81bool(false) 82 83Warning: range(): Invalid range string - must be numeric in %s on line %d 84bool(false) 85 86Warning: range(): step exceeds the specified range in %s on line %d 87bool(false) 88 89Warning: range(): Invalid range string - must be numeric in %s on line %d 90bool(false) 91 92-- Testing Invalid steps -- 93Warning: range(): Invalid range string - must be numeric in %s on line %d 94bool(false) 95 96Warning: range(): step exceeds the specified range in %s on line %d 97bool(false) 98 99Warning: range(): step exceeds the specified range in %s on line %d 100bool(false) 101 102Warning: range(): Invalid range string - must be numeric in %s on line %d 103bool(false) 104 105Warning: range(): Invalid range string - must be numeric in %s on line %d 106bool(false) 107Done 108