Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: test/mjsunit/regress/regress-2506.js

Issue 671913002: harmony-scoping: Allow 'const' iteration variables in strict mode. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« test/cctest/test-parsing.cc ('K') | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 'use strict';
rossberg 2014/10/23 09:44:54 Nit: empty line before.
Dmitry Lomov (no reviews) 2014/10/23 10:33:34 Done.
7
8 // Top-level code
9 let s = 0;
10 let f = [undefined, undefined, undefined]
11 for (const x of [1,2,3]) {
12 s += x;
13 f[x-1] = function() { return x; }
14 }
15 assertEquals(6, s);
16 assertEquals(1, f[0]());
17 assertEquals(2, f[1]());
18 assertEquals(3, f[2]());
19
20 let x = 1;
21 s = 0;
22 for (const x of [x, x+1, x+2]) {
23 s += x;
24 }
25 assertEquals(6, s);
26
27 s = 0;
28 var q = 1;
29 for (const q of [q, q+1, q+2]) {
30 s += q;
31 }
32 assertEquals(6, s);
33
34 let z = 1;
35 s = 0;
36 for (const x = 1; z < 2; z++) {
37 s += x + z;
38 }
39 assertEquals(2, s);
40
41
42 s = "";
43 for (const x in [1,2,3]) {
44 s += x;
45 }
46 assertEquals("012", s);
47
48 assertThrows(function() { for(const x in [1,2,3]) { x++ } }, SyntaxError);
49
50 // Function scope
51 (function() {
52 let s = 0;
53 for (const x of [1,2,3]) {
54 s += x;
55 }
56 assertEquals(6, s);
57
58 let x = 1;
59 s = 0;
60 for (const x of [x, x+1, x+2]) {
61 s += x;
62 }
63 assertEquals(6, s);
64
65 s = 0;
66 var q = 1;
67 for (const q of [q, q+1, q+2]) {
68 s += q;
69 }
70 assertEquals(6, s);
71
72 s = "";
73 for (const x in [1,2,3]) {
74 s += x;
75 }
76 assertEquals("012", s);
77 }());
OLDNEW
« test/cctest/test-parsing.cc ('K') | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698