ladybird/Libraries/LibJS/Tests/exception-in-catch-block.js
Linus Groh ec43f73b74 LibJS: Extract most of Interpreter's run() into execute_statement()
Interpreter::run() was so far being used both as the "public API entry
point" for running a JS::Program as well as internally to execute
JS::Statement|s of all kinds - this is now more distinctly separated.
A program as returned by the parser is still going through run(), which
is responsible for creating the initial global call frame, but all other
statements are executed via execute_statement() directly.

Fixes #3437, a regression introduced by adding ASSERT(!exception()) to
run() without considering the effects that would have on internal usage.
2020-09-12 09:31:16 +02:00

25 lines
816 B
JavaScript

test("Issue #1992, 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();
});