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