| Index: test/mjsunit/harmony/block-for.js
|
| diff --git a/test/mjsunit/harmony/block-for.js b/test/mjsunit/harmony/block-for.js
|
| index e84f0d2fee852ce05c0e797d59b98b8dbd0c3260..2c112467bb708a14f265feb68abd8a0c38f836dd 100644
|
| --- a/test/mjsunit/harmony/block-for.js
|
| +++ b/test/mjsunit/harmony/block-for.js
|
| @@ -102,7 +102,7 @@ assertThrows("function foo() { 'use strict'; for (let x, y = 4 in {}) { } }", Sy
|
| assertThrows("function foo() { 'use strict'; for (let x = 3, y = 4 in {}) { } }", SyntaxError);
|
|
|
|
|
| -// In a normal for statement the iteration variable is not
|
| +// In a normal for statement the iteration variable is
|
| // freshly allocated for each iteration.
|
| function closures1() {
|
| let a = [];
|
| @@ -110,7 +110,7 @@ function closures1() {
|
| a.push(function () { return i; });
|
| }
|
| for (let j = 0; j < 5; ++j) {
|
| - assertEquals(5, a[j]());
|
| + assertEquals(j, a[j]());
|
| }
|
| }
|
| closures1();
|
| @@ -123,13 +123,45 @@ function closures2() {
|
| b.push(function () { return j; });
|
| }
|
| for (let k = 0; k < 5; ++k) {
|
| - assertEquals(5, a[k]());
|
| - assertEquals(15, b[k]());
|
| + assertEquals(k, a[k]());
|
| + assertEquals(k + 10, b[k]());
|
| }
|
| }
|
| closures2();
|
|
|
|
|
| +function closure_in_for_init() {
|
| + let a = [];
|
| + for (let i = 0, f = function() { return i }; i < 5; ++i) {
|
| + a.push(f);
|
| + }
|
| + for (let k = 0; k < 5; ++k) {
|
| + assertEquals(0, a[k]());
|
| + }
|
| +}
|
| +closure_in_for_init();
|
| +
|
| +
|
| +function closure_in_for_cond() {
|
| + let a = [];
|
| + for (let i = 0; a.push(function () { return i; }), i < 5; ++i) { }
|
| + for (let k = 0; k < 5; ++k) {
|
| + assertEquals(k, a[k]());
|
| + }
|
| +}
|
| +closure_in_for_next();
|
| +
|
| +
|
| +function closure_in_for_next() {
|
| + let a = [];
|
| + for (let i = 0; i < 5; a.push(function () { return i; }), ++i) { }
|
| + for (let k = 0; k < 5; ++k) {
|
| + assertEquals(k + 1, a[k]());
|
| + }
|
| +}
|
| +closure_in_for_next();
|
| +
|
| +
|
| // In a for-in statement the iteration variable is fresh
|
| // for earch iteration.
|
| function closures3(x) {
|
|
|