The `test262-parser-tests` package provides a comprehensive, standardized set of test cases specifically designed for evaluating ECMAScript parsers against the official specification. Currently at version 0.0.5, this project is maintained by TC39 and serves as a foundational resource for parser implementers. It categorizes tests into `pass/` for syntactically valid programs, `early/` for programs that adhere to grammar but trigger early errors, and `fail/` for syntactically invalid programs. A unique feature is `pass-explicit/`, offering explicitly parenthesized versions of `pass/` tests for robust equivalence checking of Abstract Syntax Tree (AST) generation. Crucially, these tests are intended solely for parsing validation and are explicitly *not* designed for runtime evaluation; most would throw errors if executed. Its release cadence is generally tied to updates and amendments of the ECMAScript specification, incorporating new syntax or parsing rules as they evolve.
npm install test262-parser-testsNo compatibility data collected yet for this library.
This quickstart demonstrates how to programmatically access and validate test cases from the `test262-parser-tests` package using Node.js `fs` module and `assert`. It showcases parsing 'pass' tests (and comparing with 'pass-explicit'), expecting errors for 'fail' tests, and distinguishing between initial parsing and early error detection for 'early' tests. It uses `shift-parser` as a placeholder for any ECMAScript parser you wish to test; ensure you install `shift-parser` if you plan to run this specific example.
Do not attempt to execute these test files directly. Implement a parser that consumes their content and generates an Abstract Syntax Tree (AST), then validate the AST or parser's error reporting.
Ensure your parser correctly identifies early errors after successful grammatical parsing, or, if your parser doesn't differentiate, ensure it reports an error for both 'early/' and 'fail/' cases.
Follow the contribution guidelines in the package's README, utilizing `normalize-parser-test` and `make-explicit.js` to ensure consistency and correctness of new test cases.
This is often the expected behavior for `fail/` tests. Ensure your parser correctly reports a syntax error for these files. If your parser *doesn't* throw, it's a bug in your parser.
There is a bug in your parser where it incorrectly rejects valid ECMAScript syntax. Debug your parser to identify why it's failing on a correct input.
Review your parser's AST generation logic. Ensure it produces equivalent ASTs for syntactically equivalent code, disregarding non-semantic differences. A custom AST comparison function might be necessary instead of `assert.deepStrictEqual` for precise equivalence.
No dependency data recorded yet.