Acorn is run with:
ecmaVersion: "latest",
sourceType: module ? "module" : "script",
preserveParens: true,
allowHashBang: true,
allowReturnOutsideFunction: true,
Negative errors are filtered out. Files producing the following errors are ignored:
- Invalid regular expression flag.
- Unexpected token (possibility a stage 3 feature).
- Cannot parse YAML from Test262 fixture comment.
RegExps and BigInts are serialized as null, because JSON does not support BigInts, and
serializes RegExps as {} (not useful).
Literals which are RegExps have regex.flags property sorted in alphabetical order, the way V8 does.
Literal nodes which are BigInts have a bigint field containing the BigInt's value as a string.
Similarly, Literal nodes which are RegExps have a regex field containing pattern and flags.
So in both cases, the BigInt / RegExp can be reconstructed from this extra data.
Infinity is serialized as 1e+400 - which JSON.parse converts back to Infinity.
A decorators field is added to ClassDeclaration, ClassExpression, MethodDefinition,
and PropertyDefinition (stage 3 proposal).
A phase field is added to ImportDeclaration and ImportExpression (stage 3 proposal).
A non-standard hashbang field is added to Program.
A GitHub Actions workflow automatically updates fixtures every Monday at 09:00 UTC. The workflow:
- Fetches the latest commit SHAs from test262, TypeScript, and acorn-jsx repositories
- Updates the commit SHAs in
package.jsonif they have changed - Runs
pnpm run initto clone the repositories - Runs
pnpm run startto generate new fixtures - Commits and pushes changes back to the repository
You can also manually trigger the workflow from the GitHub Actions tab.
# Change the commit SHAs in the clone commands, then:
pnpm run init
pnpm run start
git commit -m "update snapshots"
# Test262 only
pnpm run clone-test262
pnpm run gen-test262
# Acorn JSX only
pnpm run clone-acorn-jsx
pnpm run gen-acorn-jsx
# TypeScript only
pnpm run clone-typescript
pnpm run gen-typescript