OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 // | |
5 // Flags: --harmony-scoping | |
6 | |
7 "use strict"; | |
8 | |
9 // Simplest case | |
10 var count = 0; | |
11 for (let x = 0; x < 10;) { | |
12 x++; | |
13 count++; | |
14 continue; | |
15 } | |
16 assertEquals(10, count); | |
17 | |
18 // Labeled | |
19 count = 0; | |
20 label: for (let x = 0; x < 10;) { | |
21 while (true) { | |
22 x++; | |
23 count++; | |
24 continue label; | |
25 } | |
26 } | |
27 assertEquals(10, count); | |
28 | |
29 // Simple and labeled | |
30 count = 0; | |
31 label: for (let x = 0; x < 10;) { | |
32 x++; | |
33 count++; | |
34 continue label; | |
35 } | |
36 assertEquals(10, count); | |
37 | |
38 // Shadowing loop variable in same scope as continue | |
39 count = 0; | |
40 for (let x = 0; x < 10;) { | |
41 x++; | |
42 count++; | |
43 { | |
44 let x = "hello"; | |
45 continue; | |
46 } | |
47 } | |
48 assertEquals(10, count); | |
49 | |
50 // Nested let-bound for loops, inner continue | |
51 count = 0; | |
52 for (let x = 0; x < 10;) { | |
53 x++; | |
54 for (let y = 0; y < 2;) { | |
55 y++; | |
56 count++; | |
57 continue; | |
58 } | |
59 } | |
60 assertEquals(20, count); | |
61 | |
62 // Nested let-bound for loops, outer continue | |
63 count = 0; | |
64 for (let x = 0; x < 10;) { | |
65 x++; | |
66 for (let y = 0; y < 2;) { | |
67 y++; | |
68 count++; | |
69 } | |
70 continue; | |
71 } | |
72 assertEquals(20, count); | |
73 | |
74 // Nested let-bound for loops, labeled continue | |
75 count = 0; | |
76 outer: for (let x = 0; x < 10;) { | |
77 x++; | |
78 for (let y = 0; y < 2;) { | |
79 y++; | |
80 count++; | |
81 if (y == 2) continue outer; | |
82 } | |
83 } | |
84 assertEquals(20, count); | |
OLD | NEW |