OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --strong-mode --harmony_rest_parameters --harmony_arrow_functions --ha rmony_classes --harmony-computed-property-names | 5 // Flags: --strong-mode --harmony_rest_parameters --harmony_arrow_functions --ha rmony_classes --harmony-computed-property-names |
6 | 6 |
7 // Note that it's essential for these tests that the reference is inside dead | 7 // Note that it's essential for these tests that the reference is inside dead |
8 // code (because we already produce ReferenceErrors for run-time unresolved | 8 // code (because we already produce ReferenceErrors for run-time unresolved |
9 // variables and don't want to confuse those with strong mode errors). But the | 9 // variables and don't want to confuse those with strong mode errors). But the |
10 // errors should *not* be inside lazy, unexecuted functions, since lazy parsing | 10 // errors should *not* be inside lazy, unexecuted functions, since lazy parsing |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 | 99 |
100 assertThrowsHelper( | 100 assertThrowsHelper( |
101 "'use strong'; if (false) { let C = class C2 { constructor() { C; } } }", | 101 "'use strong'; if (false) { let C = class C2 { constructor() { C; } } }", |
102 ReferenceError); | 102 ReferenceError); |
103 | 103 |
104 assertThrowsHelper( | 104 assertThrowsHelper( |
105 "'use strong'; if (false) { let C = class C2 { method() { C; } } }", | 105 "'use strong'; if (false) { let C = class C2 { method() { C; } } }", |
106 ReferenceError); | 106 ReferenceError); |
107 | 107 |
108 assertThrowsHelper( | 108 assertThrowsHelper( |
109 "'use strong'; if (false) { " + | |
110 "let C = class C2 { *generator_method() { C; } } }", | |
111 ReferenceError); | |
112 | |
113 assertThrowsHelper( | |
109 "'use strong'; if (false) { let C = class C2 { " + | 114 "'use strong'; if (false) { let C = class C2 { " + |
110 "static a() { return 'A'; } [C.a()]() { return 'B'; } }; }", | 115 "static a() { return 'A'; } [C.a()]() { return 'B'; } }; }", |
111 ReferenceError); | 116 ReferenceError); |
112 | 117 |
113 assertThrowsHelper( | 118 assertThrowsHelper( |
114 "'use strong'; if (false) { let C = class C2 { " + | 119 "'use strong'; if (false) { let C = class C2 { " + |
115 "static a() { return 'A'; } [C2.a()]() { return 'B'; } }; }", | 120 "static a() { return 'A'; } [C2.a()]() { return 'B'; } }; }", |
116 ReferenceError); | 121 ReferenceError); |
117 | 122 |
118 assertThrowsHelper( | 123 assertThrowsHelper( |
(...skipping 19 matching lines...) Expand all Loading... | |
138 "[(new (class D { m() { C2; return 'A'; } })).m()]() " + | 143 "[(new (class D { m() { C2; return 'A'; } })).m()]() " + |
139 "{ return 'B'; } } }", | 144 "{ return 'B'; } } }", |
140 ReferenceError); | 145 ReferenceError); |
141 | 146 |
142 assertThrowsHelper( | 147 assertThrowsHelper( |
143 "'use strong'; if (false) { let C = class C2 { " + | 148 "'use strong'; if (false) { let C = class C2 { " + |
144 "[(new (class D { m() { C; return 'A'; } })).m()]() " + | 149 "[(new (class D { m() { C; return 'A'; } })).m()]() " + |
145 "{ return 'B'; } } }", | 150 "{ return 'B'; } } }", |
146 ReferenceError); | 151 ReferenceError); |
147 | 152 |
148 // Methods inside object literals are not sufficiently distinguished from | 153 assertThrowsHelper( |
149 // methods inside classes. | 154 "'use strong'; if (false) { let C = class C2 { " + |
150 // https://code.google.com/p/v8/issues/detail?id=3948 | 155 "[({m() { C2; return 'A'; }}).m()]() " + |
151 // assertThrowsHelper( | 156 "{ return 'B'; } } }", |
152 // "'use strong'; if (false) { let C = class C2 { " + | 157 ReferenceError); |
153 // "[({m() { C2; return 'A'; }}).m()]() " + | |
154 // "{ return 'B'; } } }", | |
155 // ReferenceError); | |
156 | 158 |
157 assertThrowsHelper( | 159 assertThrowsHelper( |
158 "'use strong'; if (false) { let C = class C2 { " + | 160 "'use strong'; if (false) { let C = class C2 { " + |
159 "[({m() { C; return 'A'; }}).m()]() " + | 161 "[({m() { C; return 'A'; }}).m()]() " + |
160 "{ return 'B'; } } }", | 162 "{ return 'B'; } } }", |
161 ReferenceError); | 163 ReferenceError); |
162 | 164 |
163 // assertThrowsHelper( | 165 assertThrowsHelper( |
164 // "'use strong';\n" + | 166 "'use strong';\n" + |
165 // "if (false) {\n" + | 167 "if (false) {\n" + |
arv (Not doing code reviews)
2015/03/10 16:49:06
unindent
arv (Not doing code reviews)
2015/03/10 16:49:06
unindent
| |
166 // " class COuter {\n" + | 168 " class COuter {\n" + |
167 // " m() {\n" + | 169 " m() {\n" + |
168 // " class CInner {\n" + | 170 " class CInner {\n" + |
169 // " [({ m() { CInner; return 'A'; } }).m()]() {\n" + | 171 " [({ m() { CInner; return 'A'; } }).m()]() {\n" + |
170 // " return 'B';\n" + | 172 " return 'B';\n" + |
171 // " }\n" + | 173 " }\n" + |
172 // " }\n" + | 174 " }\n" + |
173 // " }\n" + | 175 " }\n" + |
174 // " }\n" + | 176 " }\n" + |
175 // "}", | 177 "}", |
176 // ReferenceError); | 178 ReferenceError); |
177 })(); | 179 })(); |
178 | 180 |
179 | 181 |
180 (function UsesWhichAreFine() { | 182 (function UsesWhichAreFine() { |
181 "use strong"; | 183 "use strong"; |
182 | 184 |
183 let var1 = 0; | 185 let var1 = 0; |
184 var1; | 186 var1; |
185 | 187 |
186 let var2a = 0, var2b = var2a + 1, var2c = 2 + var2b; | 188 let var2a = 0, var2b = var2a + 1, var2c = 2 + var2b; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 let var7 = 0; // Declaration position will be something large. | 236 let var7 = 0; // Declaration position will be something large. |
235 // But use position will be something small, however, this is not an error, | 237 // But use position will be something small, however, this is not an error, |
236 // since the use is inside an eval scope. | 238 // since the use is inside an eval scope. |
237 eval("var7;"); | 239 eval("var7;"); |
238 })(); | 240 })(); |
239 | 241 |
240 | 242 |
241 class C1 { constructor() { C1; } }; new C1(); | 243 class C1 { constructor() { C1; } }; new C1(); |
242 let C2 = class C3 { constructor() { C3; } }; new C2(); | 244 let C2 = class C3 { constructor() { C3; } }; new C2(); |
243 | 245 |
244 class C4 { method() { C4; } }; new C4(); | 246 class C4 { method() { C4; } *generator_method() { C4; } }; new C4(); |
245 let C5 = class C6 { method() { C6; } }; new C5(); | 247 let C5 = class C6 { method() { C6; } *generator_method() { C6; } }; new C5(); |
246 | 248 |
247 class C7 { static method() { C7; } }; new C7(); | 249 class C7 { static method() { C7; } }; new C7(); |
248 let C8 = class C9 { static method() { C9; } }; new C8(); | 250 let C8 = class C9 { static method() { C9; } }; new C8(); |
249 | 251 |
250 class C10 { get x() { C10; } }; new C10(); | 252 class C10 { get x() { C10; } }; new C10(); |
251 let C11 = class C12 { get x() { C12; } }; new C11(); | 253 let C11 = class C12 { get x() { C12; } }; new C11(); |
252 | 254 |
253 // Regression test for unnamed classes. | 255 // Regression test for unnamed classes. |
254 let C12 = class { m() { var1; } }; | 256 let C13 = class { m() { var1; } }; |
255 | 257 |
256 class COuter { | 258 class COuter { |
257 m() { | 259 m() { |
258 class CInner { | 260 class CInner { |
259 // Here we can refer to COuter but not to CInner (see corresponding | 261 // Here we can refer to COuter but not to CInner (see corresponding |
260 // assertion test): | 262 // assertion test): |
261 [({ m() { COuter; return 'A'; } }).m()]() { return 'B'; } | 263 [({ m() { COuter; return 'A'; } }).m()]() { return 'B'; } |
262 // And here we can refer to both: | 264 // And here we can refer to both: |
263 n() { COuter; CInner; } | 265 n() { COuter; CInner; } |
264 } | 266 } |
265 return new CInner(); | 267 return new CInner(); |
266 } | 268 } |
267 } | 269 } |
268 (new COuter()).m().n(); | 270 (new COuter()).m().n(); |
271 | |
272 // Making sure the check which is supposed to prevent "object literal inside | |
273 // computed property name references the class name" is not too generic: | |
274 class C14 { m() { let obj = { n() { C14 } }; obj.n(); } }; (new C14()).m(); | |
269 })(); | 275 })(); |
OLD | NEW |