js/src/jit-test/tests/for-of/arrays-shrinking-1.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/for-of/arrays-shrinking-1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,13 @@
     1.4 +// A for-of loop over an array stops at the new end of the array if it shrinks during iteration.
     1.5 +
     1.6 +function ispal(arr) {
     1.7 +    for (var v of arr) {
     1.8 +        if (v !== arr.pop())
     1.9 +            return false;
    1.10 +    }
    1.11 +    return true;
    1.12 +}
    1.13 +
    1.14 +assertEq(ispal([1, 2, 3, 4, 3, 2, 1]), true);
    1.15 +assertEq(ispal([1, 2, 3, 3, 2, 1]), true);
    1.16 +assertEq(ispal([1, 2, 3, 4, 2, 1]), false);

mercurial