summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/for-of/semantics-03.js
blob: 069b7fa749d47458a8f959d20c276b77f46c5dda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
// Replacing Array.prototype.iterator with a generator affects for-of behavior.

load(libdir + "iteration.js");

Array.prototype[Symbol.iterator] = function* () {
    for (var i = this.length; --i >= 0; )
        yield this[i];
};

var s = '';
for (var v of ['a', 'b', 'c', 'd'])
    s += v;
assertEq(s, 'dcba');