Implement parsing, evaluation, lexical this capture, and new rejection for arrow functions. Covers expression bodies, block bodies, zero/single/ multi-param forms, and backtracking disambiguation from grouping parens. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7.8 KiB
Test262 Roadmap
What needs to be built to run real Test262 conformance tests.
Current State
We have a custom JS262 harness (tests/js262_harness.rs) with 127 hand-written tests that
mimic Test262 patterns. The real Test262 suite has 50,000+ tests. To run even a subset, the
interpreter must support the features that Test262's own harness files (assert.js, sta.js)
require, plus the syntax used in the test files themselves.
Tier 1: Test262 Harness Requirements
These features are used by assert.js and sta.js — the support files that every Test262
test includes. All of these must work before any real Test262 test can run.
| Feature | Used For | Parser | Interpreter | Effort |
|---|---|---|---|---|
try / catch / finally |
assert.throws() wraps test code in try/catch |
Done | Done | Medium |
throw statement |
sta.js throws Test262Error on failure |
Done | Done | Small |
Logical && / || |
Short-circuit guards in assertions | Done | Done | Small |
Object literals { k: v } |
Building error message objects | Done | Done | Medium |
Property assignment obj.prop = v |
assert.sameValue = function ... |
Done (dot only) | Done (host + plain objects) | — |
| Prototype chain | Test262Error.prototype.toString = ... |
N/A | Missing | Large |
this keyword |
Constructor bodies: this.message = msg |
Done | Done | — |
switch / case |
assert._toString type formatting |
Done | Done | Medium |
Template literals `${x}` |
Assertion error messages | Done | Done | — |
new + constructor functions |
new Test262Error(msg) |
Done | Partial (host only) | Extend to JS functions |
String methods (.name, .call) |
Object.prototype.toString.call() |
Done | Done | Medium |
Minimum viable slice
To run the simplest Test262 tests, implement in this order:
Donethrow— trivial addition to parser + interpreterDonetry/catch— parser + interpreter control flowLogical operatorsDone&&/||— parser + short-circuit evalObject literals — parser + runtime plain-object typeDoneDonethiskeyword — parser + interpreter bindingDoneswitch/case— parser + interpreter control flowTemplate literals — tokenizer + parser + string interpolation evalDone
After these 7 features, we can shim assert.js and sta.js and run Test262 tests that
only use basic syntax (variable declarations, functions, if/else, comparisons).
Tier 2: Common Test File Features
Most Test262 tests go beyond basic syntax. These features unlock large swaths of the suite.
| Feature | % of Test262 tests using it | Parser | Interpreter | Effort |
|---|---|---|---|---|
for loops |
~60% | Done | Done | Medium |
for...in / for...of |
~25% | Missing | Missing | Medium |
while / do...while |
~15% | Done | Done | Small |
Array literals [1,2,3] |
~50% | Done | Done | Medium |
Computed member obj[key] |
~40% | Done | Done | Small |
Arrow functions => |
~30% | Done | Done | Medium |
Ternary ? : |
~20% | Missing | Missing | Small |
Compound assignment += etc. |
~20% | Done | Done | Small |
Increment/decrement ++/-- |
~15% | Done | Done | Small |
| Destructuring | ~10% | Missing | Missing | Large |
Spread / rest ... |
~10% | Missing | Missing | Medium |
class declarations |
~10% | Missing | Missing | Large |
Recommended implementation order
After Tier 1 is complete:
Doneforloops — unlocks the most testsArray literals + computed member — tightly coupled, unlock array testsDoneArrow functions — widely used in modern test262 testsDoneDonewhile/do...while— small effort, moderate test coverage- Ternary
? :— trivial parser change Compound assignment / increment-decrement — small parser + desugarDone
Tier 3: Richer Runtime
These require more substantial runtime work beyond parsing and basic interpretation.
| Feature | What it unlocks | Effort |
|---|---|---|
| Plain JS objects (not just host) | Object literal basics work; no enumeration/prototype yet | Medium |
Prototype chain / Object.create |
Inheritance tests, method resolution | Large |
JSON.stringify / JSON.parse |
Harness error messages, JSON tests | Medium |
String.prototype methods |
.length, .charAt(), .slice(), .indexOf() |
Medium |
Array.prototype methods |
.push(), .pop(), .map(), .forEach() |
Large |
RegExp |
Regex literal tests, string matching | Very Large |
| Closures over mutable state | Counter patterns, module-like scoping | Medium |
Strict mode ("use strict") |
Half of Test262 tests run in both sloppy and strict | Medium |
Symbol, WeakMap, Proxy |
Advanced ES6+ tests | Very Large |
Integration Plan
Phase A: Shim the Harness (after Tier 1) — Done
AddDonemode = "test262"to the JS262 manifest schemaBefore running each test, prepend the contents ofDonesta.jsandassert.jsMapDoneTest262Errorexceptions to test failure outcomes- ~
Vendor a curated subset ofDone50 basic Test262 tests intotests/external/js262/test262/ Add manifest entries withDonemode = "test262"and feature tags from Test262 metadata
Phase A Results
- 50 real Test262 tests vendored from
tc39/test262 - 35 pass (70%), 15 known_fail (30%)
- Feature areas covered: ASI (5), block-scope (20), comments (5), directive-prologue (5), expressions (15)
- Known-fail breakdown: ASI gaps (2), label syntax (2), function declarations in blocks (2), strict mode (5), other parser gaps (4)
- New JS feature added during Phase A: function property support (
fn.prop = val,fn.prop,fn.method())
Phase B: Expand Coverage (after Tiers 1+2)
- Vendor ~500 tests covering variables, expressions, functions, control flow
- Use Test262's
featuresmetadata to filter to supported features only - Script the manifest generation: parse Test262 YAML frontmatter → TOML entries
- Track pass rate as a project metric
Phase C: Continuous Integration
- Vendor full Test262 suite (or download on CI)
- Run supported-feature subset on every PR
- Run full suite nightly, track known-fail count trending down
- Target: 90%+ pass rate on ES5.1 subset as first major milestone
Quick Reference: Feature Gap Summary
Blocking Test262 harness (must fix first):
, this, switchtemplate literals, string methods / — Prototype chain remains..name / .call()
Blocking large test coverage: (none — arrow functions now implemented)
Already implemented:
var/let/const, if/else, functions (declaration + expression + new),
typeof, ===/!==/==/!=, arithmetic, string concat, ! (not),
object literals, try/catch/finally, throw, &&/||,
string methods (.length, .charAt(), .indexOf(), .slice(), etc.),
Function.name, Function.prototype.call(), Object.prototype.toString.call(),
for/while/do-while loops, break/continue, ++/--, +=/-=/*=,
function properties (fn.prop = val, fn.method()),
array literals ([1,2,3]), computed member access (obj[key]),
array methods (.push(), .pop(), .join(), .indexOf(), .slice(), .concat()),
Promises, setTimeout, queueMicrotask, DOM bindings, event dispatch
JS262 conformance: 127 tests, 121 pass, 5 known_fail. Test262: 50 vendored, 35 pass (70%) — Phase A complete. See docs/js_conformance_report.md.
See docs/js_feature_matrix.md for the full current feature status.