Files
rust_browser/docs/js_conformance_report.md
Zachary D. Rowitsch 75bc30bb8e Add JavaScript arrow function (=>) support
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>
2026-02-21 22:12:47 -05:00

124 lines
3.9 KiB
Markdown

# JavaScript Conformance Report
Summary of the JS262 conformance test suite results. Tests are modeled after Test262
but use our own harness since the interpreter doesn't yet support all features
required by the Test262 harness (prototype chain remains).
## Overall Results
| Status | Count |
|--------|-------|
| Pass | 124 |
| Known Fail | 4 |
| Skip | 1 |
| **Total** | **129** |
## Results by Feature Area
| Feature | Pass | Known Fail | Total |
|---------|------|------------|-------|
| expressions | 16 | 0 | 16 |
| variable-declarations | 11 | 0 | 11 |
| functions | 10 | 0 | 10 |
| scheduling | 7 | 0 | 7 |
| arrays | 6 | 0 | 6 |
| control-flow | 6 | 0 | 6 |
| dom-bindings | 6 | 0 | 6 |
| errors | 6 | 0 | 6 |
| events | 6 | 0 | 6 |
| for-loops | 6 | 0 | 6 |
| this-keyword | 5 | 0 | 5 |
| promises | 5 | 0 | 5 |
| try-catch | 5 | 0 | 5 |
| types | 5 | 0 | 5 |
| objects | 4 | 0 | 4 |
| while-loops | 3 | 0 | 3 |
| string-methods | 3 | 0 | 3 |
| do-while-loops | 2 | 0 | 2 |
| logical-ops | 2 | 0 | 2 |
| compound-assignment | 1 | 0 | 1 |
| computed-member | 1 | 0 | 1 |
| function-call | 1 | 0 | 1 |
| increment-decrement | 1 | 0 | 1 |
| object-prototype | 1 | 0 | 1 |
| switch | 1 | 0 | 1 |
| template-literals | 1 | 0 | 1 |
| arrow-functions | 3 | 0 | 3 |
| bitwise-ops | 0 | 1 | 1 |
| for-in | 0 | 1 | 1 |
| instanceof | 0 | 1 | 1 |
| ternary | 0 | 1 | 1 |
## Known Failure Reasons
| Feature | Reason |
|---------|--------|
| for-in | For-in loop not yet supported |
| ternary | Ternary operator not yet supported |
| arrow-functions | *(implemented — promoted to pass)* |
| bitwise-ops | Bitwise operators not yet supported |
| instanceof | instanceof operator not yet supported |
| stack-overflow | Skipped — default recursion depth exhausts Rust stack before statement limit fires |
## Harness Design
The JS262 harness (`tests/js262_harness.rs`) supports two execution modes:
- **script**: Runs JS through `JsEngine` with a `CaptureSink` for console output
- **dom**: Runs JS through `WebApiFacade` with virtual clock for deterministic scheduling
Tests can specify:
- `expected_output`: Compare console output against a golden `.txt` file
- `expected_error`: Verify error class (`parse`, `reference`, `type`, `runtime`)
- `steps`: For dom-mode, specify clock advances and tick counts
Policy enforcement uses the same 3-state matrix as the WPT harness:
- Pass test that passes: OK
- Pass test that fails: ERROR
- Known-fail test that fails: OK (expected)
- Known-fail test that passes: ERROR (promote it)
## Real Test262 Tests (Phase A)
50 real tests vendored from `tc39/test262` into `tests/external/js262/test262/`.
Each test runs with `mode = "test262"`, which prepends `sta.js` and `assert.js` before execution.
| Status | Count |
|--------|-------|
| Pass | 35 |
| Known Fail | 15 |
| **Total** | **50** |
**Pass rate: 70%**
### Results by Feature Area
| Feature | Pass | Known Fail | Total |
|---------|------|------------|-------|
| asi | 3 | 2 | 5 |
| block-scope | 12 | 8 | 20 |
| comments | 5 | 0 | 5 |
| directive-prologue | 5 | 0 | 5 |
| expressions | 10 | 5 | 15 |
### Known-Fail Categories
| Category | Count | Details |
|----------|-------|---------|
| Strict mode | 5 | `"use strict"` directive enforcement not yet implemented |
| ASI gaps | 2 | Automatic semicolon insertion edge cases |
| Label syntax | 2 | Labeled statement parsing not supported |
| Function decls in blocks | 2 | Block-scoped function declarations (Annex B) |
| Other parser gaps | 4 | Various syntax not yet handled |
## Test262 Migration Path
Phase A is now complete. Next steps (Phase B):
1. Vendor ~500 tests covering variables, expressions, functions, control flow
2. Use Test262's `features` metadata to filter to supported features only
3. Script the manifest generation: parse Test262 YAML frontmatter to TOML entries
4. Track pass rate as a project metric
See `docs/test262_roadmap.md` for the full gap analysis, tiered implementation plan,
and integration strategy.