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:
parent
1bbfaf8627
commit
62ad33af93
1 changed files with 9 additions and 5 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue