Files
aji/tests/conformance/README.md
T
dev 179dee3c3a Phase 6A: .aji layer 7 (task scopes, spawn/join, channels)
- scope s { … }: task.scope.begin, task.scope.end at every normal exit
  (scope ends generalized: borrow.end or task.scope.end, innermost first)
- task.spawn(s, f, args): call-like; named linear values moved (E7003);
  lent borrows are bound first (inline borrow E7006); scope operand E7005
- task.join/cancel/cancelled; task<T>, sender<T>, receiver<T>, scope types
- channels: make<T>, dup, send, recv, close_sender, close_receiver; send,
  recv and close_receiver are outcome matches; endpoints by name, borrowed
  for the operation and ended on every edge (written `mut tx`: E7006)
- outcome rebinding: a value coming back under the name of a variable of
  its type becomes the variable's value (pending(r))
- joins carry live variables only (pruned SSA): a linear value consumed
  before a join does not travel to it; ordered after-walk over the
  enclosing statement or tail, sibling arms not counted
- parser: a keyword after `.` is a member name (task.cancelled)
- conformance equivalence ignores schedule.choices (quantum counts AIR
  instructions)
- tests: 10 run tests with AIR equivalence (Phase 3 programs), 12 rejects
  (E4301, E4101 x2, E4002, E2001, E3101, E3002, E7006 x2, E7003, E0006,
  E7005); Quick Reference tasks/channels programs now pass
- spec 15 §4/§6/§7, grammar, quick reference, bundle notes, plan
2026-10-05 17:55:30 +03:00

59 lines
3.7 KiB
Markdown

# Conformance suite
Run with `zig build conformance` (add `-- --json` for JSON Lines, `-- --filter <substring>` to narrow).
## Layout
```text
tests/conformance/
phase<N>/accept/*.air modules a conforming verifier MUST accept
phase<N>/reject/*.air modules a conforming verifier MUST reject
phase<N>/run/*.air modules that MUST verify and produce a given run record
```
`phase<N>` is the implementation phase (`docs/plan/README.md`) that first requires the test to pass.
## Test header
Every test starts with a block of `;` lines. Keys:
| Key | Required | Value |
|---|---|---|
| `expect` | yes | `accept`; `reject` followed by one or more codes from `docs/reference/error-codes.md`; or `run` |
| `result` | with `run` | expected `value` of the run record as canonical JSON, e.g. `42` or `{"x":1}` |
| `trap` | with `run` | expected trap code, e.g. `T0003` |
| `not_instantiated` | with `run` | expected `reason` of a `not_instantiated` record (spec 05 §10.2) |
| `grant` | no, repeatable | `<parameter>=<kind>[:<scope>]` binding for a capability parameter of `@main` |
| `blocked` | with `run` | the run must end with the environment outcome `blocked` |
| `stdin` | no | input for `io.stdin_read`; escapes `\n`, `\t`, `\\`, `\xHH` |
| `vfs` | no, repeatable | `<path>=<text>`: initial file in the deterministic file system (same escapes) |
| `seed` | no | seed of the deterministic random source |
| `stdout` / `stderr` | no | expected captured output (same escapes) |
| `file` | no, repeatable | `<path>=<text>`: expected contents of a file written by the run |
| `fuel` | no | instruction limit for `run` tests (spec 11 §7.1); default 1 000 000. Running out is a `FAIL`, never a pass |
| `equivalent` | no, `.aji` `run` tests only | path, relative to `tests/conformance`, of a reference AIR program. Both are run with this test's world and grants; their run records must be byte-identical (for a trap, the trap code must match, since the record carries the AIR location; `schedule.choices` is not compared, since the scheduler's quantum counts AIR instructions and the lowered program may have a different instruction stream). The AIR texts may differ |
| `phase` | yes | implementation phase number |
| `spec` | yes | spec section that justifies the expectation |
A key is a single lowercase word; header lines without a `key:` prefix are free-form description. The runner blanks the header before handing the module to the pipeline, so line numbers in diagnostics are unchanged and the AIR grammar does not need to know about test metadata.
`run` executes `@main` twice and fails if the two run records differ (spec 11); otherwise it compares the record with `result` or `trap`. Exactly one of them is required.
`reject` compares the exact multiset of error codes. Listing a code twice means two diagnostics with that code are expected.
## Outcomes
| Outcome | Meaning |
|---|---|
| `PASS` | result matches `expect` |
| `FAIL` | result differs, or the header is malformed; the run exits 1 |
| `PENDING` | the test's `phase` is later than `aji.implemented_phase` and its module declares a feature the toolchain does not support yet |
## Rules
- Every verifier rule gets at least one `accept` and one `reject` test (AGENTS.md, testing policy).
- **Names are permanent and describe the rule** (`resource_use_after_move.air`, `borrow_use_after_end.air`). A name is never reused for a different rule; the corpus doubles as an executable specification.
- One defect per `reject` test. A test that triggers several unrelated errors is hard to repair against.
- Keep tests minimal: the smallest module that exhibits the rule.
- Tests are written in text AIR format 0 (`docs/reference/air-text.ebnf`) and start with the four-line module header.