1--TEST-- 2range() programattic errors for the $step parameter 3--INI-- 4precision=14 5--FILE-- 6<?php 7echo "Step cannot be 0\n"; 8try { 9 var_dump( range(1.0, 7.0, 0.0) ); 10} catch (\ValueError $e) { 11 echo $e->getMessage(), "\n"; 12} 13try { 14 var_dump( range(1, 7, 0) ); 15} catch (\ValueError $e) { 16 echo $e->getMessage(), "\n"; 17} 18try { 19 var_dump( range('A', 'H', 0) ); 20} catch (\ValueError $e) { 21 echo $e->getMessage(), "\n"; 22} 23try { 24 var_dump( range('A', 'H', 0.0) ); 25} catch (\ValueError $e) { 26 echo $e->getMessage(), "\n"; 27} 28echo "Step cannot be INF\n"; 29try { 30 var_dump( range(1.0, 7.0, 10.0**400) ); 31} catch (\ValueError $e) { 32 echo $e->getMessage(), "\n"; 33} 34try { 35 var_dump( range(1, 7, 10.0**400) ); 36} catch (\ValueError $e) { 37 echo $e->getMessage(), "\n"; 38} 39try { 40 var_dump( range('A', 'H', 10.0**400) ); 41} catch (\ValueError $e) { 42 echo $e->getMessage(), "\n"; 43} 44echo "Step cannot be NAN\n"; 45try { 46 var_dump( range(1.0, 7.0, fdiv(0, 0)) ); 47} catch (\ValueError $e) { 48 echo $e->getMessage(), "\n"; 49} 50try { 51 var_dump( range(1, 7, fdiv(0, 0)) ); 52} catch (\ValueError $e) { 53 echo $e->getMessage(), "\n"; 54} 55try { 56 var_dump( range('A', 'H', fdiv(0, 0)) ); 57} catch (\ValueError $e) { 58 echo $e->getMessage(), "\n"; 59} 60 61echo "Step must be within the range of input parameters\n"; 62echo "-- Testing ( (low < high) && (high-low < step) ) --\n"; 63try { 64 var_dump( range(1.0, 7.0, 6.5) ); 65} catch (\ValueError $e) { 66 echo $e->getMessage(), "\n"; 67} 68 69echo "-- Testing ( (low > high) && (low-high < step) ) --\n"; 70try { 71 var_dump( range(7.0, 1.0, 6.5) ); 72} catch (\ValueError $e) { 73 echo $e->getMessage(), "\n"; 74} 75 76echo "-- Testing ( (low < high) && (high-low < step) ) for characters --\n"; 77try { 78 var_dump(range('a', 'z', 100)); 79} catch (\ValueError $e) { 80 echo $e->getMessage(), "\n"; 81} 82 83echo "-- Testing ( (low > high) && (low-high < step) ) for characters --\n"; 84try { 85 var_dump(range('z', 'a', 100)); 86} catch (\ValueError $e) { 87 echo $e->getMessage(), "\n"; 88} 89 90echo "Step must not be negative for increasing ranges\n"; 91try { 92 var_dump(range('a', 'c', -1)); 93} catch (\ValueError $e) { 94 echo $e->getMessage(), "\n"; 95} 96try { 97 var_dump(range(1, 3, -1)); 98} catch (\ValueError $e) { 99 echo $e->getMessage(), "\n"; 100} 101try { 102 var_dump(range(1.5, 3.5, -1.5)); 103} catch (\ValueError $e) { 104 echo $e->getMessage(), "\n"; 105} 106 107?> 108--EXPECTF-- 109Step cannot be 0 110range(): Argument #3 ($step) cannot be 0 111range(): Argument #3 ($step) cannot be 0 112range(): Argument #3 ($step) cannot be 0 113range(): Argument #3 ($step) cannot be 0 114Step cannot be INF 115range(): Argument #3 ($step) must be a finite number, INF provided 116range(): Argument #3 ($step) must be a finite number, INF provided 117range(): Argument #3 ($step) must be a finite number, INF provided 118Step cannot be NAN 119range(): Argument #3 ($step) must be a finite number, NAN provided 120range(): Argument #3 ($step) must be a finite number, NAN provided 121range(): Argument #3 ($step) must be a finite number, NAN provided 122Step must be within the range of input parameters 123-- Testing ( (low < high) && (high-low < step) ) -- 124range(): Argument #3 ($step) must be less than the range spanned by argument #1 ($start) and argument #2 ($end) 125-- Testing ( (low > high) && (low-high < step) ) -- 126range(): Argument #3 ($step) must be less than the range spanned by argument #1 ($start) and argument #2 ($end) 127-- Testing ( (low < high) && (high-low < step) ) for characters -- 128range(): Argument #3 ($step) must be less than the range spanned by argument #1 ($start) and argument #2 ($end) 129-- Testing ( (low > high) && (low-high < step) ) for characters -- 130range(): Argument #3 ($step) must be less than the range spanned by argument #1 ($start) and argument #2 ($end) 131Step must not be negative for increasing ranges 132range(): Argument #3 ($step) must be greater than 0 for increasing ranges 133range(): Argument #3 ($step) must be greater than 0 for increasing ranges 134range(): Argument #3 ($step) must be greater than 0 for increasing ranges 135