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

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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