Forráskód Böngészése

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.
Ali Mohammad Pur 3 éve
szülő
commit
62ad33af93
1 módosított fájl, 9 hozzáadás és 5 törlés
  1. 9 5
      Tests/LibJS/test-bytecode-js.cpp

+ 9 - 5
Tests/LibJS/test-bytecode-js.cpp

@@ -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)