summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/for-of/generators-3.js
blob: 6472f4df290e23b3c8466344a994313229d3f96f (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);