js/src/jit-test/tests/for-of/array-iterator-changing.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 // Array iterators reflect changes to elements of the underlying array.
     3 load(libdir + "asserts.js");
     4 load(libdir + "iteration.js");
     6 var arr = [0, 1, 2];
     7 var it = arr[std_iterator]();
     8 arr[0] = 1000;
     9 arr[2] = 2000;
    10 assertIteratorNext(it, 1000);
    11 assertIteratorNext(it, 1);
    12 assertIteratorNext(it, 2000);
    13 assertIteratorDone(it, undefined);
    15 // test that .keys() and .entries() have the same behaviour
    17 arr = [0, 1, 2];
    18 var ki = arr.keys();
    19 var ei = arr.entries();
    20 arr[0] = 1000;
    21 arr[2] = 2000;
    22 assertIteratorNext(ki, 0);
    23 assertIteratorNext(ei, [0, 1000]);
    24 assertIteratorNext(ki, 1);
    25 assertIteratorNext(ei, [1, 1]);
    26 assertIteratorNext(ki, 2);
    27 assertIteratorNext(ei, [2, 2000]);
    28 assertIteratorDone(ki, undefined);
    29 assertIteratorDone(ei, undefined);

mercurial