Testing
QuickJS-ng has a comprehensive test suite to ensure correctness and ECMAScript compliance. This guide covers how to run tests and work with the test262 compliance suite.Running Tests
Basic Test Suite
Run the basic QuickJS test suite:tests.conf using the run-test262 tool.
Manual Test Execution
You can also run the test runner directly:Test262 Compliance Suite
Test262 is the official ECMAScript conformance test suite. QuickJS-ng runs this suite to ensure spec compliance.Running test262
To run the full test262 suite:- Initializes the test262 submodule if needed
- Runs all applicable test262 tests
- Reports pass/fail statistics
The test262 suite is extensive and may take several minutes to complete.
Fast test262 Subset
For quicker feedback during development, run a smaller subset:Updating test262 Results
After implementing a new feature that changes test262 results:Checking test262 Results
Verify that test262 results match expected outcomes:-E flag to check against expected results.
Specialized Tests
API Tests
Test the C API:Standalone Compilation Test
Test JavaScript-to-executable compilation:Examples Tests
If built with examples enabled:Microbenchmarks
Run performance microbenchmarks:tests/microbench.js to measure performance of common operations.
Platform-Specific Testing
Windows (MSVC)
Windows (MinGW)
Emscripten
WASI
CI Test Matrix
The continuous integration pipeline tests QuickJS-ng across:Operating Systems
- Ubuntu Linux (latest, 24.04)
- macOS (latest)
- Windows (latest, Server 2019)
- FreeBSD
- OpenBSD
- Cygwin
Architectures
- x86 (32-bit)
- x64 (64-bit)
- ARM64
- RISC-V (riscv64)
- s390x
Build Configurations
- Debug builds
- Release builds
- Shared library builds
- Example builds
- Amalgamated builds
Compilers
- GCC
- Clang
- MSVC (Visual Studio 2022)
- MinGW (mingw32, mingw64, ucrt64, clang64)
- TCC (Tiny C Compiler)
- Clang-CL
Sanitizers
- AddressSanitizer (ASan)
- UndefinedBehaviorSanitizer (UBSan)
- MemorySanitizer (MSan)
- ThreadSanitizer (TSan, separate workflow)
Special Builds
- Emscripten (WebAssembly)
- WASI
- Android (arm64-v8a)
- iOS
- Parserless builds
- mimalloc integration
Test Runner Options
Therun-test262 tool supports several options:
Common Options
-c <file>- Use configuration file-m- Run in multi-threaded mode-a- Run all tests-u- Update test results-E- Check expected results-t <threads>- Number of threads (default: auto)
Configuration Files
tests.conf- Basic QuickJS test suitetest262.conf- Full test262 suitetest262-fast.conf- Fast test262 subset
Writing Tests
Test File Format
QuickJS tests are JavaScript files that throw exceptions on failure:Adding Tests
- Create a new
.jsfile in thetests/directory - Add test cases that throw on failure
- Add the test to the appropriate
.conffile - Run the test suite to verify
Debugging Test Failures
Run a Single Test
Enable Debug Output
Use Sanitizers
Build with sanitizers to catch memory errors:Valgrind
Run tests under Valgrind for memory debugging:Performance Testing
View Engine Statistics
Benchmark Suite
Run the microbenchmark suite:- Arithmetic operations
- Function calls
- Object creation
- Array operations
- String manipulation
- Regular expressions
Best Practices
- Always run
make testbefore submitting pull requests - Run test262 for changes affecting ECMAScript compliance
- Test on multiple platforms when making platform-specific changes
- Use sanitizers during development to catch memory errors early
- Add tests for bug fixes to prevent regressions
- Add tests for new features to ensure they work correctly
- Update test262 results when implementing new ECMAScript features