1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/for-of/semantics-10.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,31 @@ 1.4 +// The LHS of a for-loop is not bound to a particular scope until after the .next() method returns. 1.5 + 1.6 +var obj = {}; 1.7 + 1.8 +// Test 1 1.9 +function g() { 1.10 + obj.x = 0; 1.11 + yield 1; 1.12 +} 1.13 +var x = 2, n = 0; 1.14 +with (obj) { 1.15 + for (x of g()) // g().next() inserts a binding for x on obj 1.16 + n++; 1.17 +} 1.18 +assertEq(x, 2); 1.19 +assertEq(obj.x, 1); 1.20 +assertEq(n, 1); 1.21 + 1.22 +// Test 2 1.23 +function h() { 1.24 + delete obj.x; 1.25 + yield 3; 1.26 +} 1.27 +n = 0; 1.28 +with (obj) { 1.29 + for (x of h()) // h().next() deletes the binding for x on obj 1.30 + n++; 1.31 +} 1.32 +assertEq(x, 3); 1.33 +assertEq("x" in obj, false); 1.34 +assertEq(n, 1);