|
1 // |reftest| skip -- obsolete test |
|
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 /* |
|
8 * |
|
9 * Date: 30 Jan 2002 |
|
10 * Revised: 10 Apr 2002 |
|
11 * Revised: 14 July 2002 |
|
12 * |
|
13 * SUMMARY: JS should error on |for(i in undefined)|, |for(i in null)| |
|
14 * See http://bugzilla.mozilla.org/show_bug.cgi?id=121744 |
|
15 * |
|
16 * ECMA-262 3rd Edition Final spec says such statements should error. See: |
|
17 * |
|
18 * Section 12.6.4 The for-in Statement |
|
19 * Section 9.9 ToObject |
|
20 * |
|
21 * |
|
22 * BUT: SpiderMonkey has decided NOT to follow this; it's a bug in the spec. |
|
23 * See http://bugzilla.mozilla.org/show_bug.cgi?id=131348 |
|
24 * |
|
25 * UPDATE: Rhino has also decided not to follow the spec on this. |
|
26 * See http://bugzilla.mozilla.org/show_bug.cgi?id=136893 |
|
27 * |
|
28 |
|
29 |--------------------------------------------------------------------| |
|
30 | | |
|
31 | So for now, adding an early return for this test so it won't run. | |
|
32 | | |
|
33 |--------------------------------------------------------------------| |
|
34 |
|
35 * |
|
36 */ |
|
37 //----------------------------------------------------------------------------- |
|
38 var UBound = 0; |
|
39 var BUGNUMBER = 121744; |
|
40 var summary = 'JS should error on |for(i in undefined)|, |for(i in null)|'; |
|
41 var TEST_PASSED = 'TypeError'; |
|
42 var TEST_FAILED = 'Generated an error, but NOT a TypeError!'; |
|
43 var TEST_FAILED_BADLY = 'Did not generate ANY error!!!'; |
|
44 var status = ''; |
|
45 var statusitems = []; |
|
46 var actual = ''; |
|
47 var actualvalues = []; |
|
48 var expect= ''; |
|
49 var expectedvalues = []; |
|
50 |
|
51 /* |
|
52 * AS OF 14 JULY 2002, DON'T RUN THIS TEST IN EITHER RHINO OR SPIDERMONKEY - |
|
53 */ |
|
54 quit(); |
|
55 |
|
56 |
|
57 status = inSection(1); |
|
58 expect = TEST_PASSED; |
|
59 actual = TEST_FAILED_BADLY; |
|
60 /* |
|
61 * OK, this should generate a TypeError |
|
62 */ |
|
63 try |
|
64 { |
|
65 for (var i in undefined) |
|
66 { |
|
67 print(i); |
|
68 } |
|
69 } |
|
70 catch(e) |
|
71 { |
|
72 if (e instanceof TypeError) |
|
73 actual = TEST_PASSED; |
|
74 else |
|
75 actual = TEST_FAILED; |
|
76 } |
|
77 addThis(); |
|
78 |
|
79 |
|
80 |
|
81 status = inSection(2); |
|
82 expect = TEST_PASSED; |
|
83 actual = TEST_FAILED_BADLY; |
|
84 /* |
|
85 * OK, this should generate a TypeError |
|
86 */ |
|
87 try |
|
88 { |
|
89 for (var i in null) |
|
90 { |
|
91 print(i); |
|
92 } |
|
93 } |
|
94 catch(e) |
|
95 { |
|
96 if (e instanceof TypeError) |
|
97 actual = TEST_PASSED; |
|
98 else |
|
99 actual = TEST_FAILED; |
|
100 } |
|
101 addThis(); |
|
102 |
|
103 |
|
104 |
|
105 status = inSection(3); |
|
106 expect = TEST_PASSED; |
|
107 actual = TEST_FAILED_BADLY; |
|
108 /* |
|
109 * Variable names that cannot be looked up generate ReferenceErrors; however, |
|
110 * property names like obj.ZZZ that cannot be looked up are set to |undefined| |
|
111 * |
|
112 * Therefore, this should indirectly test | for (var i in undefined) | |
|
113 */ |
|
114 try |
|
115 { |
|
116 for (var i in this.ZZZ) |
|
117 { |
|
118 print(i); |
|
119 } |
|
120 } |
|
121 catch(e) |
|
122 { |
|
123 if(e instanceof TypeError) |
|
124 actual = TEST_PASSED; |
|
125 else |
|
126 actual = TEST_FAILED; |
|
127 } |
|
128 addThis(); |
|
129 |
|
130 |
|
131 |
|
132 status = inSection(4); |
|
133 expect = TEST_PASSED; |
|
134 actual = TEST_FAILED_BADLY; |
|
135 /* |
|
136 * The result of an unsuccessful regexp match is the null value |
|
137 * Therefore, this should indirectly test | for (var i in null) | |
|
138 */ |
|
139 try |
|
140 { |
|
141 for (var i in 'bbb'.match(/aaa/)) |
|
142 { |
|
143 print(i); |
|
144 } |
|
145 } |
|
146 catch(e) |
|
147 { |
|
148 if(e instanceof TypeError) |
|
149 actual = TEST_PASSED; |
|
150 else |
|
151 actual = TEST_FAILED; |
|
152 } |
|
153 addThis(); |
|
154 |
|
155 |
|
156 |
|
157 //----------------------------------------------------------------------------- |
|
158 test(); |
|
159 //----------------------------------------------------------------------------- |
|
160 |
|
161 |
|
162 |
|
163 function addThis() |
|
164 { |
|
165 statusitems[UBound] = status; |
|
166 actualvalues[UBound] = actual; |
|
167 expectedvalues[UBound] = expect; |
|
168 UBound++; |
|
169 } |
|
170 |
|
171 |
|
172 function test() |
|
173 { |
|
174 enterFunc('test'); |
|
175 printBugNumber(BUGNUMBER); |
|
176 printStatus(summary); |
|
177 |
|
178 for (var i=0; i<UBound; i++) |
|
179 { |
|
180 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
|
181 } |
|
182 |
|
183 exitFunc ('test'); |
|
184 } |