OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // Flags: --strong-mode --harmony_rest_parameters --harmony_arrow_functions | |
6 | |
7 (function DeclarationAfterUse() { | |
rossberg
2015/02/23 13:45:26
More tests would be great, both positive and negat
marja
2015/02/24 13:29:35
Added some tests here, probably not everything you
| |
8 assertThrows("'use strong'; x; let x = 0;", ReferenceError); | |
9 assertThrows("function f() { 'use strong'; x; let x = 0; } f();", | |
10 ReferenceError); | |
11 assertThrows("'use strong'; function f() { x; } let x = 0; f();", | |
12 ReferenceError); | |
13 assertThrows("function f() { 'use strong'; x; } var x = 0; f();", | |
14 ReferenceError); | |
15 // Errors are also detected when the declaration and the use are in the same | |
16 // eval scope. | |
17 assertThrows("'use strong'; eval('x; let x = 0;')", ReferenceError); | |
18 })(); | |
19 | |
20 | |
21 (function UsesWhichAreFine() { | |
22 "use strong"; | |
23 | |
24 let var1 = 0; | |
25 var1; | |
26 | |
27 for (let var2 = 0; var2 < 1; var2++) { | |
28 var2; | |
29 } | |
30 | |
31 let var3 = 5; | |
32 for (; var3 < 10; ++var3) { } | |
33 | |
34 let arr = [1, 2]; | |
35 for (let i of arr) { | |
36 i; | |
37 } | |
38 | |
39 try { | |
40 throw "error"; | |
41 } catch (e) { | |
42 e; | |
43 } | |
44 | |
45 function func1() { func1; this; } | |
46 func1(); | |
47 func1; | |
48 | |
49 function * func2() { func2; this; } | |
50 func2(); | |
51 func2; | |
52 | |
53 function func4(p, ...rest) { p; rest; this; func2; } | |
54 func4(); | |
55 | |
56 let func5 = (p1, p2) => { p1; p2 }; | |
57 func5(); | |
58 | |
59 (function eval1() { | |
60 let var4 = 0; // Declaration position will be something large. | |
61 // But use position will be something small, however, this is not an error, | |
62 // since the use is inside an eval scope. | |
63 eval("var4;"); | |
64 })(); | |
65 })(); | |
OLD | NEW |