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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 // The LHS of a for-loop is not bound to a particular scope until after the .next() method returns.
     3 var obj = {};
     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);
    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