summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests/exception-in-catch-block.js
blob: 2a0fa6e1fc3e03cef598f376f5e597704674fb97 (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
test("Issue #3437, exception thrown in catch {} block", () => {
    var tryHasBeenExecuted = false;
    var catchHasBeenExecuted = false;
    var finallyHasBeenExecuted = false;
    expect(() => {
        try {
            tryHasBeenExecuted = true;
            foo();
            // execution must not reach this step
            expect().fail();
        } catch (e) {
            catchHasBeenExecuted = true;
            bar();
            // ...also not this step
            expect().fail();
        } finally {
            finallyHasBeenExecuted = true;
        }
        // ...or this step
        expect().fail();
    }).toThrow(ReferenceError, "'bar' is not defined");
    expect(tryHasBeenExecuted).toBeTrue();
    expect(catchHasBeenExecuted).toBeTrue();
    expect(finallyHasBeenExecuted).toBeTrue();
});