Files
rust_browser/docs/js_conformance_report.md
Zachary D. Rowitsch 0c21feb090
Some checks failed
ci / fast (linux) (push) Failing after 11m14s
Implement JSON.stringify and JSON.parse with full spec compliance
Add the JSON global object with both methods following the sentinel
NativeFunction + interpreter interception pattern. The implementation
includes a dedicated recursive descent JSON parser (strict spec: no
trailing commas, no single quotes, no hex/octal, surrogate pair support),
JSON.stringify with replacer function/array, space indentation, toJSON,
boxed primitive unwrapping, and circular reference detection via ptr_eq.

Safety: depth-limited to 512 levels for both parse and stringify to
prevent stack overflow from malicious input. Space string truncation
uses char boundaries to avoid panics on multi-byte UTF-8.

138 unit tests, 2 conformance tests (js262).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 17:00:47 -05:00

152 lines
5.4 KiB
Markdown

# JavaScript Conformance Report
Summary of the JS262 conformance test suite results. Tests are modeled after Test262
but use our own harness. The interpreter now supports all features required by the
Test262 harness (prototype chain, classes, instanceof).
## Overall Results
| Status | Count |
|--------|-------|
| Pass | 584 |
| Known Fail | 165 |
| Skip | 1 |
| **Total** | **750** |
## Results by Feature Area
| Feature | Pass | Known Fail | Total |
|---------|------|------------|-------|
| expressions | 259 | 172 | 431 |
| variable-declarations | 11 | 0 | 11 |
| functions | 10 | 0 | 10 |
| classes | 10 | 0 | 10 |
| scheduling | 7 | 0 | 7 |
| arrays | 19 | 0 | 19 |
| arrow-functions | 6 | 0 | 6 |
| control-flow | 6 | 0 | 6 |
| dom-bindings | 6 | 0 | 6 |
| errors | 6 | 0 | 6 |
| error-constructors | 3 | 0 | 3 |
| events | 6 | 0 | 6 |
| for-loops | 6 | 0 | 6 |
| spread-rest | 6 | 0 | 6 |
| this-keyword | 5 | 0 | 5 |
| promises | 5 | 0 | 5 |
| try-catch | 5 | 0 | 5 |
| types | 5 | 0 | 5 |
| objects | 9 | 0 | 9 |
| ternary | 4 | 0 | 4 |
| while-loops | 3 | 0 | 3 |
| string-methods | 3 | 0 | 3 |
| for-in | 4 | 0 | 4 |
| for-of | 3 | 0 | 3 |
| do-while-loops | 2 | 0 | 2 |
| logical-ops | 2 | 0 | 2 |
| bitwise-ops | 1 | 0 | 1 |
| compound-assignment | 1 | 0 | 1 |
| computed-member | 1 | 0 | 1 |
| function-call | 1 | 0 | 1 |
| increment-decrement | 1 | 0 | 1 |
| instanceof | 1 | 0 | 1 |
| object-prototype | 3 | 0 | 3 |
| switch | 1 | 0 | 1 |
| template-literals | 1 | 0 | 1 |
| destructuring | 21 | 2 | 23 |
| json | 2 | 0 | 2 |
## Known Failure Reasons
| Feature | Reason |
|---------|--------|
| arrow-functions | *(implemented — promoted to pass)* |
| for-in | *(implemented — promoted to pass)* |
| bitwise-ops | *(implemented — promoted to pass)* |
| instanceof | *(implemented — promoted to pass)* |
| stack-overflow | Skipped — default recursion depth exhausts Rust stack before statement limit fires |
| Symbol/WeakMap/Proxy | *(implemented — tests now pass with Symbol, WeakMap, and Proxy support)* |
## 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 B)
550 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 | 385 |
| Known Fail | 165 |
| **Total** | **550** |
**Pass rate: 70%**
### Results by Feature Area
| Feature | Pass | Known Fail | Total |
|---------|------|------------|-------|
| asi | 20 | 5 | 25 |
| block-scope | 30 | 9 | 39 |
| comments | 15 | 0 | 15 |
| computed-property-names | 0 | 18 | 18 |
| destructuring | 11 | 3 | 14 |
| directive-prologue | 14 | 11 | 25 |
| expressions | 173 | 241 | 414 |
### Known-Fail Categories (Phase A legacy + Phase B)
| Category | Count | Details |
|----------|-------|---------|
| Strict mode | 0 | Implemented: directive detection, reserved words, `this` binding, `.call()`, `delete`, duplicate params |
| ASI gaps | 5 | Remaining ASI tests need labeled statements (3) or `do`-while ASI (2) |
| Label syntax | 2 | Labeled statement parsing not supported |
| Function decls in blocks | 2 | Block-scoped function declarations (Annex B) |
| Computed property names | 18 | Some computed property tests use unsupported features |
| Other parser/runtime gaps | ~210 | Various syntax and runtime features not yet handled |
## Phase C: Full Test262 Integration
Phase C adds the ability to run the entire tc39/test262 suite (50,000+ tests) against
our engine, without vendoring all test files.
**Two-tier architecture:**
- **Tier 1 (PR gate):** 550 vendored tests in `js262_manifest.toml` — runs on every `just test`
- **Tier 2 (Full suite):** Auto-generated `js262_full_manifest.toml` from upstream clone — runs via `just test262-full`
**Key changes:**
- Dynamic harness include loading: tests can specify `includes = ["propertyHelper.js", ...]` beyond the default `sta.js`/`assert.js`
- Status overrides tracked in `js262_full_status.toml` (checked in); defaults to `known_fail`
- ES5.1 tests tagged via `es5id` frontmatter field → `feature = "es5.1-{subdir}"`
- Automated triage: `just triage-test262-full` promotes passing known_fail tests
**Commands:**
```
just clone-test262 # Clone tc39/test262 to upstream/
just test262-scan # Clone + scan → generate full manifest
just test262-full # Scan + run full suite
just triage-test262-full # Promote passing known_fail tests
```
**Recent additions:** ToPrimitive (`valueOf`/`toString` hint-based coercion) and wrapper objects
(`new Number()`, `new String()`, `new Boolean()`) are now implemented. Test counts will be updated
after the next CI run.
See `docs/test262_roadmap.md` for the full gap analysis, tiered implementation plan,
and integration strategy.