@@ -7,37 +7,82 @@ precision=14
7
7
8
8
echo "\n*** Testing error conditions *** \n" ;
9
9
10
- echo "\n-- Testing ( (low < high) && (step = 0) ) -- " ;
11
- var_dump ( range (1 , 2 , 0 ) );
12
- var_dump ( range ("a " , "b " , 0 ) );
10
+ echo "\n-- Testing ( (low < high) && (step = 0) ) -- \n" ;
11
+ try {
12
+ var_dump ( range (1 , 2 , 0 ) );
13
+ } catch (\Error $ e ) {
14
+ echo $ e ->getMessage (), "\n" ;
15
+ }
13
16
14
- echo "\n\n-- Testing ( (low > high) && (step = 0) ) -- " ;
15
- var_dump ( range (2 , 1 , 0 ) );
16
- var_dump ( range ("b " , "a " , 0 ) );
17
+ try {
18
+ var_dump ( range ("a " , "b " , 0 ) );
19
+ } catch (\Error $ e ) {
20
+ echo $ e ->getMessage (), "\n" ;
21
+ }
17
22
18
- echo "\n\n-- Testing ( (low < high) && (high-low < step) ) -- " ;
19
- var_dump ( range (1.0 , 7.0 , 6.5 ) );
23
+ echo "\n\n-- Testing ( (low > high) && (step = 0) ) -- \n" ;
24
+ try {
25
+ var_dump ( range (2 , 1 , 0 ) );
26
+ } catch (\Error $ e ) {
27
+ echo $ e ->getMessage (), "\n" ;
28
+ }
20
29
21
- echo "\n\n-- Testing ( (low > high) && (low-high < step) ) -- " ;
22
- var_dump ( range (7.0 , 1.0 , 6.5 ) );
30
+ try {
31
+ var_dump ( range ("b " , "a " , 0 ) );
32
+ } catch (\Error $ e ) {
33
+ echo $ e ->getMessage (), "\n" ;
34
+ }
35
+
36
+ echo "\n\n-- Testing ( (low < high) && (high-low < step) ) -- \n" ;
37
+ try {
38
+ var_dump ( range (1.0 , 7.0 , 6.5 ) );
39
+ } catch (\Error $ e ) {
40
+ echo $ e ->getMessage (), "\n" ;
41
+ }
42
+
43
+ echo "\n\n-- Testing ( (low > high) && (low-high < step) ) -- \n" ;
44
+ try {
45
+ var_dump ( range (7.0 , 1.0 , 6.5 ) );
46
+ } catch (\Error $ e ) {
47
+ echo $ e ->getMessage (), "\n" ;
48
+ }
49
+
50
+ echo "\n-- Testing other conditions -- \n" ;
51
+ try {
52
+ var_dump ( range (-1 , -2 , 2 ) );
53
+ } catch (\Error $ e ) {
54
+ echo $ e ->getMessage (), "\n" ;
55
+ }
23
56
24
- echo "\n-- Testing other conditions -- " ;
25
- var_dump ( range (-1 , -2 , 2 ) );
26
57
try {
27
58
var_dump ( range ("a " , "j " , "z " ) );
28
59
} catch (TypeError $ e ) {
29
60
echo $ e ->getMessage (), "\n" ;
61
+ } catch (\Error $ e ) {
62
+ echo $ e ->getMessage (), "\n" ;
63
+ }
64
+
65
+ try {
66
+ var_dump ( range (0 , 1 , "140962482048819216326.24 " ) );
67
+ } catch (\Error $ e ) {
68
+ echo $ e ->getMessage (), "\n" ;
69
+ }
70
+
71
+ try {
72
+ var_dump ( range (0 , 1 , "140962482048819216326.24. " ) );
73
+ } catch (\Error $ e ) {
74
+ echo $ e ->getMessage (), "\n" ;
30
75
}
31
- var_dump ( range (0 , 1 , "140962482048819216326.24 " ) );
32
- var_dump ( range (0 , 1 , "140962482048819216326.24. " ) );
33
76
34
- echo "\n-- Testing Invalid steps -- " ;
77
+ echo "\n-- Testing Invalid steps -- \n " ;
35
78
$ step_arr = array ( "string " , NULL , FALSE , "" , "\0" );
36
79
37
80
foreach ( $ step_arr as $ step ) {
38
81
try {
39
82
var_dump ( range ( 1 , 5 , $ step ) );
40
- } catch (TypeError $ e ) {
83
+ } catch (\TypeError $ e ) {
84
+ echo $ e ->getMessage (), "\n" ;
85
+ } catch (\Error $ e ) {
41
86
echo $ e ->getMessage (), "\n" ;
42
87
}
43
88
}
@@ -48,50 +93,34 @@ echo "Done\n";
48
93
*** Testing error conditions ***
49
94
50
95
-- Testing ( (low < high) && (step = 0) ) --
51
- Warning: range(): step exceeds the specified range in %s on line %d
52
- bool(false)
53
-
54
- Warning: range(): step exceeds the specified range in %s on line %d
55
- bool(false)
96
+ step exceeds the specified range
97
+ step exceeds the specified range
56
98
57
99
58
100
-- Testing ( (low > high) && (step = 0) ) --
59
- Warning: range(): step exceeds the specified range in %s on line %d
60
- bool(false)
61
-
62
- Warning: range(): step exceeds the specified range in %s on line %d
63
- bool(false)
101
+ step exceeds the specified range
102
+ step exceeds the specified range
64
103
65
104
66
105
-- Testing ( (low < high) && (high-low < step) ) --
67
- Warning: range(): step exceeds the specified range in %s on line %d
68
- bool(false)
106
+ step exceeds the specified range
69
107
70
108
71
109
-- Testing ( (low > high) && (low-high < step) ) --
72
- Warning: range(): step exceeds the specified range in %s on line %d
73
- bool(false)
110
+ step exceeds the specified range
74
111
75
112
-- Testing other conditions --
76
- Warning: range(): step exceeds the specified range in %s on line %d
77
- bool(false)
113
+ step exceeds the specified range
78
114
range() expects parameter 3 to be int or float, string given
79
-
80
- Warning: range(): step exceeds the specified range in %s on line %d
81
- bool(false)
115
+ step exceeds the specified range
82
116
83
117
Notice: A non well formed numeric value encountered in %s on line %d
118
+ step exceeds the specified range
84
119
85
- Warning: range(): step exceeds the specified range in %s on line %d
86
- bool(false)
87
-
88
- -- Testing Invalid steps --range() expects parameter 3 to be int or float, string given
89
-
90
- Warning: range(): step exceeds the specified range in %s on line %d
91
- bool(false)
92
-
93
- Warning: range(): step exceeds the specified range in %s on line %d
94
- bool(false)
120
+ -- Testing Invalid steps --
121
+ range() expects parameter 3 to be int or float, string given
122
+ step exceeds the specified range
123
+ step exceeds the specified range
95
124
range() expects parameter 3 to be int or float, string given
96
125
range() expects parameter 3 to be int or float, string given
97
126
Done
0 commit comments