- src/interp/machine.zig: format-0 interpreter on the air64 target; checked/wrapping arithmetic, shifts, casts, aggregates, calls with a 1024-frame limit, traps as records with T0xxx codes - aji run: prints one JSON run record; exit code 4 on trap - conformance runner: `expect: run` with `result:`/`trap:`, every run executed twice and compared byte-for-byte; header keys must be single lowercase words - Phase 0 corpus: 3 accept, 19 reject, 15 run tests (41 total)
2.3 KiB
Testing
Non-normative. How the reference implementation is tested. Policy (what must be tested) is in AGENTS.md; this file covers the mechanics.
Test levels
| Level | Where | Run | Purpose |
|---|---|---|---|
| Unit | test blocks in src/, tools/ |
zig build test |
internal data structures, helpers, registry ↔ docs sync |
| Conformance | tests/conformance/ |
zig build conformance |
spec behavior: accept/reject, later run output and traps |
| Reference programs | tests/programs/ (from P2) |
zig build conformance |
the six programs in plan/conformance-suite.md |
| Litmus | tests/litmus/ (from P5) |
zig build litmus |
memory-model outcomes allowed/forbidden |
| Schedule stress | via runner flags (from P3) | zig build conformance -- --schedules=N |
randomized and systematic interleavings |
| Native parity | (from P7) | zig build parity |
interpreter and native backend agree on the whole corpus |
Unit and conformance exist today; conformance covers accept, reject and run tests.
Conformance tests
Format and outcomes: tests/conformance/README.md.
Adding a verifier rule:
- Write the rule in the spec, with its code in
docs/reference/error-codes.mdandsrc/diag.zig. - Add the smallest
rejecttest that violates only that rule. - Add an
accepttest that is as close as possible to the reject test but legal. The pair documents exactly where the boundary is. - Implement until both pass.
Planned header extensions (added by the phase that needs them):
| Key | Phase | Meaning |
|---|---|---|
expect: run + result: / trap: |
P0 (implemented) | module must verify; run record must match |
stdout: |
P2 | expected output, \n-escaped (needs io.write) |
seed: / schedules: |
P3 | deterministic scheduler seed / number of randomized schedules |
profile: |
P2 | runtime profile (hosted, deterministic, …) |
Determinism checks
Every run test is executed twice by the runner from P0-12 onward and the outputs (stdout, trap record, trace hash) compared byte-for-byte. Concurrency tests additionally run under the stress modes listed in plan/conformance-suite.md.
Diagnostics as API
Diagnostic JSON is a stable interface. Snapshot tests on the full JSON (not only the code) belong in unit tests next to the pass that emits them, so field renames are caught.