Skip to content

Commit

Permalink
build: execute official test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-anders committed Mar 29, 2024
1 parent 6f9ccde commit 262ba17
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Run tests (release)
run: cargo test --release --verbose
# https://github.com/munificent/craftinginterpreters/issues/993#issuecomment-1613917808
- name: Execute official test suite
run: |
wget https://storage.googleapis.com/dart-archive/channels/stable/release/2.12.0/sdk/dartsdk-linux-x64-release.zip
unzip dartsdk-linux-x64-release.zip
# This is the one test where rlox actually reports error like clox instead of jlox.
sed '2d;1s/3/2/' ext/craftinginterpreters/test/unexpected_character.lox -i
cargo build --features strict && (cd ext/craftinginterpreters && ../../dart-sdk/bin/dart tool/bin/test.dart jlox --interpreter ../../target/debug/rlox)
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Nothing special here, simply use `cargo build --release` to build the interprete
## Testing

Rlox currently passes all function tests of the [official test
suite](https://github.com/munificent/craftinginterpreters/tree/master/test). There are a few tests that fail because
rlox will report different errors than clox, namely `function/body_must_be_block.lox`,
`function/missing_comma_in_parameters.lox` and `class/local_inherit_self.lox`. This is caused by slight differences in
the way I implemented parser synchronization when encountering an error.
suite](https://github.com/munificent/craftinginterpreters/tree/master/test).
While the general architecture follows clox, the error reporting and syncrhonization actually resembles jlox (the
java-implementation from the book's first part). Thus the official test suite needs to be run in "jlox" mode.
There's a single test that fails because in this case rlox actually behaves like clox, namely `unexpected_character.rlox`.

There are also some unit tests and benchmark, they can be run via the usual `cargo test` and `cargo bench` commands.

0 comments on commit 262ba17

Please sign in to comment.