summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/for-of/throw-during-nested-break.js
blob: 64e2d182b27a610daf69b3f4032367b86d060a59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var progress = "";

function* wrapNoThrow() {
    let iter = {
        [Symbol.iterator]() { return this; },
        next() { return { value: 10, iter: false }; },
        return() { progress += " throw"; throw "nonsense"; }
    };
    for (const i of iter)
        yield i;
}

function foo() {
    try {
        var badIter = wrapNoThrow();
        loop: for (var i of badIter) {
            progress += "outerloop";
            try {
                for (i of [1,2,3]) {
                    progress += " innerloop";
                    break loop;
                }
            } catch (e) { progress += " BAD CATCH"; }
        }
    } catch (e) { progress += " goodcatch"; }
}

foo();
assertEq(progress, "outerloop innerloop throw goodcatch");