summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/for-of/generators-3.js
blob: 1d4cdccbef2e6aabcb4b9fef4687662c6b4dfe55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Nested for-of loops can use the same generator-iterator.

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

var r = range(10);
for (var a of r)
    for (var b of r)
        for (var c of r)
            for (var d of r)
                ;

assertEq(a, 0);
assertEq(b, 1);
assertEq(c, 2);
assertEq(d, 9);