summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/for-of/semantics-04.js
blob: df7036de7af4a8cef5979c605d004d0aaa29ad6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Giving an Array an own .iterator property affects for-of.

load(libdir + "asserts.js");
load(libdir + "iteration.js");

var a = [];
a[Symbol.iterator] = function* () {
    yield 'o';
    yield 'k';
};
var s = '';
for (var v of a)
    s += v;
assertEq(s, 'ok');

a[Symbol.iterator] = undefined;
assertThrowsInstanceOf(function () { for (var v of a) ; }, TypeError);