Automatically pass --as-module to the js binary when the test input
file has a .mjs extension. This allows us to write AST and bytecode
tests for module-only syntax like import and export statements.
Instead of hardcoding the path to Build/debug/bin/js, detect the build
directory from the script's location. The script is copied to
bin/test-js-bytecode during build, so the build directory is one level
up from the script.
This allows the bytecode tests to run correctly regardless of which
build preset is being used.
This adds a new `test-js-bytecode` target which ensures that codegen
changes do not impact emitted bytecode IR, or if it does, it is known
and the tests are updated accordingly.
Similar to the LibWeb tests, the tests are stored in the following
format:
* `Libraries/LibJS/Bytecode/Tests/input`: Input `.js` files
* `Libraries/LibJS/Bytecode/Tests/expected`: Expected `.txt` bytecode
* `Libraries/LibJS/Bytecode/Tests/output`: Emitted `.txt` bytecode
The `output` dir is git-ignored, but stores the output so you can diff
and inspect failed tests more easily.
There is only one test so far, which is a baseline test that should not
change dramatically unless we change the bytecode output format.