js/src/jit-test/tests/for-of/semantics-10.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:eda0a37e012d
1 // The LHS of a for-loop is not bound to a particular scope until after the .next() method returns.
2
3 var obj = {};
4
5 // Test 1
6 function g() {
7 obj.x = 0;
8 yield 1;
9 }
10 var x = 2, n = 0;
11 with (obj) {
12 for (x of g()) // g().next() inserts a binding for x on obj
13 n++;
14 }
15 assertEq(x, 2);
16 assertEq(obj.x, 1);
17 assertEq(n, 1);
18
19 // Test 2
20 function h() {
21 delete obj.x;
22 yield 3;
23 }
24 n = 0;
25 with (obj) {
26 for (x of h()) // h().next() deletes the binding for x on obj
27 n++;
28 }
29 assertEq(x, 3);
30 assertEq("x" in obj, false);
31 assertEq(n, 1);

mercurial