Temporal's primary test suite is the Temporal test262 test
suite. There is an open issue / PR to extract
the tests from test262 into a format that temporal_rs can run
against in native Rust.
In the meantime, there are two primary ways to test:
-
Map the test into a Rust version in the
testmodule intemporal_rs. (Ex: Duration's tests) -
Implement the feature in a relevant ECMAScript interpreter / engine, and run the engine through the test suite.
Testing with Boa can be completed fairly easily. First and definitely not least, implement the feature in Boa. Boa's Temporal builtin can be found here.
Once implemented, the builtin Temporal test suite can be run with the command:
cargo run --bin boa_tester -- run -vv --console -s test/built-ins/TemporalThe intl402 Temporal test suite can be run with:
cargo run --bin boa_tester -- run -vv --console -s test/intl402/TemporalThe test suite can be further specified by qualifying the path. In order
to run the tests for ZonedDateTime.prototype.add, run:
cargo run --bin boa_tester -- run -vv --console -s test/built-ins/Temporal/ZonedDateTime/prototype/addWhen debugging a specific test, the test output can be viewed by running
the test in verbose mode (-vvv):
cargo run --bin boa_tester -- run -vvv --console -s test/built-ins/Temporal/Instant/compare/argument-string-limits.jsRunning the above command will output whether the test failed or passed, and the test failure output if failed.
Getting last commit on 'HEAD' branch
Loading the test suite...
Test loaded, starting...
`/home/user/Projects/boa/test262/test/built-ins/Temporal/Instant/compare/argument-string-limits.js`: starting
`/home/user/Projects/boa/test262/test/built-ins/Temporal/Instant/compare/argument-string-limits.js`: Failed
`/home/user/Projects/boa/test262/test/built-ins/Temporal/Instant/compare/argument-string-limits.js`: result text
Uncaught RangeError: Instant nanoseconds are not within a valid epoch range.Any ECMAScript implementation implementing temporal_rs will require
some level of glue code in order to move from the implementation to
temporal_rs. So when debugging, it is important to determine that the
error falls in temporal_rs.