summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2022-02-12 19:54:08 +0330
committerLinus Groh <mail@linusgroh.de>2022-02-13 14:41:33 +0000
commit75aa900b830a3e72dbc59229c44a6c0b88d99230 (patch)
tree6572353b81b80f31bd58266d7d22bdf46a6cb5f4 /Tests
parent3a5f7cb524bb061bae07ba0554ef1edcd34c502b (diff)
downloadserenity-75aa900b830a3e72dbc59229c44a6c0b88d99230.zip
LibJS: Make ASTNode::generate_bytecode() fallible
Instead of crashing on the spot, return a descriptive error that will eventually continue its days as a javascript "InternalError" exception. This should make random crashes with BC less likely.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/LibJS/test-bytecode-js.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/Tests/LibJS/test-bytecode-js.cpp b/Tests/LibJS/test-bytecode-js.cpp
index d6f0c8792d..7f20a1a38f 100644
--- a/Tests/LibJS/test-bytecode-js.cpp
+++ b/Tests/LibJS/test-bytecode-js.cpp
@@ -22,9 +22,9 @@
auto const& program = script->parse_node(); \
JS::Bytecode::Interpreter bytecode_interpreter(ast_interpreter->global_object(), ast_interpreter->realm());
-#define EXPECT_NO_EXCEPTION(executable) \
- auto executable = JS::Bytecode::Generator::generate(program); \
- auto result = bytecode_interpreter.run(*executable); \
+#define EXPECT_NO_EXCEPTION(executable) \
+ auto executable = MUST(JS::Bytecode::Generator::generate(program)); \
+ auto result = bytecode_interpreter.run(*executable); \
EXPECT(!result.is_error());
#define EXPECT_NO_EXCEPTION_WITH_OPTIMIZATIONS(executable) \
@@ -54,7 +54,7 @@ TEST_CASE(if_statement_fail)
{
SETUP_AND_PARSE("if (true) throw new Exception('failed');");
- auto executable = JS::Bytecode::Generator::generate(program);
+ auto executable = MUST(JS::Bytecode::Generator::generate(program));
auto result = bytecode_interpreter.run(*executable);
EXPECT(result.is_error());
}
@@ -112,7 +112,7 @@ TEST_CASE(loading_multiple_files)
auto test_file_script = test_file_script_or_error.release_value();
auto const& test_file_program = test_file_script->parse_node();
- auto executable = JS::Bytecode::Generator::generate(test_file_program);
+ auto executable = MUST(JS::Bytecode::Generator::generate(test_file_program));
auto result = bytecode_interpreter.run(*executable);
EXPECT(!result.is_error());
}