opencode/packages/codemode-rust/test262
Sebastian Herrlinger 6d7e96a399 refactor(codemode): make the Rust crate the language layer only
The crate becomes the Rust implementation of the reference's language layer (`src/language/`): its public API is
the Rust form of `Language` (`Runtime::make` with `globals(run)`, modules, limits and translation; `HostFunction`
for `Host.fn` with sync, async and sync-thenable types, idempotent, constructible and takes-functions;
`DurableFunction`; `Namespace`; `Failure` for `Host.fail` and `Host.missing`; `Run` with its metadata; programs,
suspend and resume; snapshots). Code Mode (tools, schemas, the catalog, `search`, OpenAPI, hooks, max tool calls,
extensions) is removed, and the language files move from `src/language/` to `src/`.

Host calls follow the reference's language runtime: arguments cross under the runtime's translation (functions and
promises fail the call unless dropped or awaited), a function from a result crosses back only to a function that
takes functions, async and durable calls start at the next handover, sync work can block (`Returned::Block`) or
stay pending (`Returned::Pending`), and a suspend is refused while a call that can't be detached runs. Namespace
paths carry their root label, and their `keys` may fail. Snapshots save the run's metadata and its calls by global
path, and restart them by resolving that path again.

The replays define the generators' host globals (`conformance/reference.rs` shares `tools` with
`conformance/reference.ts`): the cases, `host.json`, `boundary.json` and `streaming.json`. `tests/host.rs` mirrors
the reference's `test/language.test.ts`; the API tests are ported, and the Code Mode tests are removed.
2026-11-19 01:54:11 +01:00
..
src refactor(codemode): make the Rust crate the language layer only 2026-11-19 01:54:11 +01:00
Cargo.toml test(codemode): add a test262 parity runner for the Rust port 2026-11-18 18:53:57 +01:00
README.md test(codemode): check test262 parity in both directions 2026-11-18 18:54:08 +01:00
reference-gaps.txt fix(codemode): reject circular values and Promise.race([]) like the reference 2026-11-18 18:56:09 +01:00
reference.ts test(codemode): check test262 parity in both directions 2026-11-18 18:54:08 +01:00
run.sh test(codemode): check test262 parity in both directions 2026-11-18 18:54:08 +01:00
rust-skipped.txt feat(codemode): hold huge sparse arrays 2026-11-18 18:56:11 +01:00

test262 parity

Runs the reference's pinned test262 file set (../codemode/test/test262) with the reference's semantics and checks the failures against rust-skipped.txt.

bash test262/run.sh                 # what CI runs
bash test262/run.sh built-ins/Array # one directory, by path prefix
bash test262/run.sh --write         # regenerate both gap lists from the current outcomes
  • run.sh clones tc39/test262 at the reference manifest's revision into a cache directory (TEST262_CHECKOUT), then runs the reference's own script/sync-test262.ts into target/test262 (TEST262_FILES). The file set and its filters are the reference's, unchanged.
  • src/main.rs runs each file like the reference's run.ts: "use strict" and the one-line assert prelude prepended on the same line, the host harness ($assert checks, Test262Error, compareArray, $DONE, $DONOTEVALUATE) from the crate's test262 feature, a 5 s timeout, negative tests judged by phase, and async tests drained and judged by $DONE.
  • Parity runs both ways, with one list per direction. Both may only shrink.
    • rust-skipped.txt lists the files that fail here but pass in the reference, each with a reason category. CI fails when an unlisted file fails, and when a listed file passes.
    • reference-gaps.txt lists the files in the reference's skipped.txt that pass here: gaps on the TypeScript side. Each category starts with real (Rust has the behaviour, TypeScript lacks it) or accident (Rust passes through a looser check where the reference is deliberately strict; Rust should match the reference). CI fails when an unlisted file passes, when a listed file fails here or leaves the reference's skipped.txt, and when reference.ts, which runs the listed files through the reference's own run.ts, sees one pass.
  • --write regenerates both lists. It keeps the categories already in reference-gaps.txt and marks new entries uncategorised, with the reference's reason, for a person to judge.