Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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: --harmony-scoping | 5 // Flags: --harmony-scoping --harmony-classes |
| 6 | 6 |
| 7 function CheckError(source) { | 7 function CheckError(source) { |
| 8 var exception = null; | 8 var exception = null; |
| 9 try { | 9 try { |
| 10 eval(source); | 10 eval(source); |
| 11 } catch (e) { | 11 } catch (e) { |
| 12 exception = e; | 12 exception = e; |
| 13 } | 13 } |
| 14 assertNotNull(exception); | 14 assertNotNull(exception); |
| 15 assertEquals( | 15 assertEquals( |
| 16 "Lexical declarations are currently only allowed in strict mode", | 16 "Block-scoped declarations (let, const, function, class) not yet supported outside strict mode", |
| 17 exception.message); | 17 exception.message); |
| 18 } | 18 } |
| 19 | 19 |
| 20 | 20 |
| 21 function CheckOk(source) { | 21 function CheckOk(source) { |
| 22 eval(source); | 22 eval(source); |
| 23 } | 23 } |
| 24 | 24 |
| 25 CheckError("let x = 1;"); | 25 CheckError("let x = 1;"); |
| 26 CheckError("{ let x = 1; }"); | 26 CheckError("{ let x = 1; }"); |
| 27 CheckError("function f() { let x = 1; }"); | 27 CheckError("function f() { let x = 1; }"); |
| 28 CheckError("for (let x = 1; x < 1; x++) {}"); | 28 CheckError("for (let x = 1; x < 1; x++) {}"); |
| 29 CheckError("for (let x of []) {}"); | 29 CheckError("for (let x of []) {}"); |
| 30 CheckError("for (let x in []) {}"); | 30 CheckError("for (let x in []) {}"); |
| 31 CheckError("class C {}"); | |
| 32 CheckError("class C extends Array {}"); | |
| 33 CheckError("1, class {};"); | |
|
arv (Not doing code reviews)
2014/11/19 16:51:04
I assume your intention was to test class expressi
rossberg
2014/11/19 17:23:43
No, the "1," in front causes it to be parsed as a
arv (Not doing code reviews)
2014/11/19 17:43:09
Ooops
The 1 was lost in the noise.
| |
| 34 CheckError("1, class extends Array {};"); | |
| 35 CheckError("1, class C {};"); | |
| 36 CheckError("1, class C exends Array {};"); | |
| 31 | 37 |
| 32 CheckOk("let = 1;"); | 38 CheckOk("let = 1;"); |
| 33 CheckOk("{ let = 1; }"); | 39 CheckOk("{ let = 1; }"); |
| 34 CheckOk("function f() { let = 1; }"); | 40 CheckOk("function f() { let = 1; }"); |
| 35 CheckOk("for (let = 1; let < 1; let++) {}"); | 41 CheckOk("for (let = 1; let < 1; let++) {}"); |
| OLD | NEW |