1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:38:11 +00:00

LibJS: Convert Instruction::execute in bytecode to ThrowCompletionOr

This allows us to use TRY in these functions :^).
This commit is contained in:
davidot 2022-02-07 14:36:45 +01:00 committed by Linus Groh
parent de90d54be0
commit 8108fc7f9c
6 changed files with 238 additions and 294 deletions

View file

@ -120,3 +120,20 @@ TEST_CASE(loading_multiple_files)
EXPECT(!vm->exception());
}
}
TEST_CASE(catch_exception)
{
// FIXME: Currently it seems that try/catch with finally is broken so we test both at once.
EXPECT_NO_EXCEPTION_ALL("var hitCatch = false;\n"
"var hitFinally = false;\n"
"try {\n"
" a();\n"
"} catch (e) {\n"
" hitCatch = e instanceof ReferenceError;\n"
" !1\n" // This is here to fix the alignment issue until that is actually resolved.
"} finally {\n"
" hitFinally = true;\n"
"}\n"
"if (hitCatch !== true) throw new Exception('failed');\n"
"if (hitFinally !== true) throw new Exception('failed');");
}