summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/for-of/generators-2.js
blob: c804fa8dae02cf62cc1c2229dc0ad3571e4a7a74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Generator-iterators are consumed the first time they are iterated.

function range(n) {
    for (var i = 0; i < n; i++)
        yield i;
}

var r = range(10);
var i = 0;
for (var x in r)
    assertEq(x, i++);
assertEq(i, 10);
for (var y in r)
    throw "FAIL";
assertEq(y, undefined);