summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/for-of/arrays-shrinking-1.js
blob: b7210c29c0770e603888b8654e676daf2d16d39f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
// A for-of loop over an array stops at the new end of the array if it shrinks during iteration.

function ispal(arr) {
    for (var v of arr) {
        if (v !== arr.pop())
            return false;
    }
    return true;
}

assertEq(ispal([1, 2, 3, 4, 3, 2, 1]), true);
assertEq(ispal([1, 2, 3, 3, 2, 1]), true);
assertEq(ispal([1, 2, 3, 4, 2, 1]), false);