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

Tests: Wrap test-bytecode-js source in an IIFE

Putting everything in the global scope will lead to mayhem and failing
tests with an actually correct implementation of scoping :^)
Also adds in a tiny debug log of the exception, otherwise we'd be
staring at failing tests with no info on what failed.
This commit is contained in:
Ali Mohammad Pur 2022-02-13 14:54:45 +03:30 committed by Linus Groh
parent 1bbfaf8627
commit 62ad33af93

View file

@ -25,7 +25,9 @@
#define EXPECT_NO_EXCEPTION(executable) \
auto executable = MUST(JS::Bytecode::Generator::generate(program)); \
auto result = bytecode_interpreter.run(*executable); \
EXPECT(!result.is_error());
EXPECT(!result.is_error()); \
if (result.is_error()) \
dbgln("Error: {}", MUST(result.throw_completion().value()->to_string(bytecode_interpreter.global_object())));
#define EXPECT_NO_EXCEPTION_WITH_OPTIMIZATIONS(executable) \
auto& passes = JS::Bytecode::Interpreter::optimization_pipeline(); \
@ -33,11 +35,13 @@
\
auto result_with_optimizations = bytecode_interpreter.run(*executable); \
\
EXPECT(!result_with_optimizations.is_error());
EXPECT(!result_with_optimizations.is_error()); \
if (result_with_optimizations.is_error()) \
dbgln("Error: {}", MUST(result_with_optimizations.throw_completion().value()->to_string(bytecode_interpreter.global_object())));
#define EXPECT_NO_EXCEPTION_ALL(source) \
SETUP_AND_PARSE(source) \
EXPECT_NO_EXCEPTION(executable) \
#define EXPECT_NO_EXCEPTION_ALL(source) \
SETUP_AND_PARSE("(() => {\n" source "\n})()") \
EXPECT_NO_EXCEPTION(executable) \
EXPECT_NO_EXCEPTION_WITH_OPTIMIZATIONS(executable)
TEST_CASE(empty_program)