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") );
30
31echo "\n-- Testing Invalid steps --";
32$step_arr = array( "string", NULL, FALSE, "", "\0" );
33
34foreach( $step_arr as $step ) {
35  var_dump( range( 1, 5, $step ) );
36}
37
38echo "Done\n";
39?>
40--EXPECTF--
41*** Testing error conditions ***
42
43-- Testing ( (low < high) && (step = 0) ) --
44Warning: range(): step exceeds the specified range in %s on line %d
45bool(false)
46
47Warning: range(): step exceeds the specified range in %s on line %d
48bool(false)
49
50
51-- Testing ( (low > high) && (step = 0) ) --
52Warning: range(): step exceeds the specified range in %s on line %d
53bool(false)
54
55Warning: range(): step exceeds the specified range in %s on line %d
56bool(false)
57
58
59-- Testing ( (low < high) && (high-low < step) ) --
60Warning: range(): step exceeds the specified range in %s on line %d
61bool(false)
62
63
64-- Testing ( (low > high) && (low-high < step) ) --
65Warning: range(): step exceeds the specified range in %s on line %d
66bool(false)
67
68-- Testing Invalid number of arguments --
69Warning: range() expects at least 2 parameters, 0 given in %s on line %d
70bool(false)
71
72Warning: range() expects at least 2 parameters, 1 given in %s on line %d
73bool(false)
74
75Warning: range() expects at most 3 parameters, 4 given in %s on line %d
76bool(false)
77
78Warning: range(): step exceeds the specified range in %s on line %d
79bool(false)
80
81Warning: range(): step exceeds the specified range in %s on line %d
82bool(false)
83
84-- Testing Invalid steps --
85Warning: range(): step exceeds the specified range in %s on line %d
86bool(false)
87
88Warning: range(): step exceeds the specified range in %s on line %d
89bool(false)
90
91Warning: range(): step exceeds the specified range in %s on line %d
92bool(false)
93
94Warning: range(): step exceeds the specified range in %s on line %d
95bool(false)
96
97Warning: range(): step exceeds the specified range in %s on line %d
98bool(false)
99Done
100