Skip to content

Commit 52748ee

Browse files
committed
chore: run test262 through node
1 parent 54abb74 commit 52748ee

File tree

3 files changed

+34
-22
lines changed

3 files changed

+34
-22
lines changed

__test__/run_test262.ts renamed to __test__/run_test262.mjs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import * as path from 'path';
2+
import { fileURLToPath } from 'url';
23
// @ts-ignore - no types
3-
import * as run from 'test262-parser-runner';
4+
import run from 'test262-parser-runner';
45
import * as acorn from 'acorn';
5-
import { tsPlugin } from '../src';
6+
import { tsPlugin } from '../lib/index.mjs';
67

78
const parser = acorn.Parser.extend(tsPlugin());
8-
const UNSUPPORTED_FEATURES: string[] = [
9+
const UNSUPPORTED_FEATURES = [
910
'regexp-v-flag',
1011
'regexp-duplicate-named-groups',
1112
'import-assertions',
@@ -14,7 +15,7 @@ const UNSUPPORTED_FEATURES: string[] = [
1415
'import-attributes'
1516
];
1617

17-
const SKIP_FILES: string[] = [
18+
const SKIP_FILES = [
1819
// `1 < 2 > 3;` cannot be parsed well.
1920
// This is because `< 2 >` is judged as TypeArguments.
2021
// See https://github.com/TyrealHu/acorn-typescript/issues/21
@@ -23,7 +24,7 @@ const SKIP_FILES: string[] = [
2324

2425
// Some keywords still don't throw an error.
2526
// See https://github.com/TyrealHu/acorn-typescript/issues/23
26-
const WHITELIST: string[] = [
27+
const WHITELIST = [
2728
// `this` variable name. e.g. `var this = 42`
2829
'language/identifiers/val-this.js',
2930
'language/identifiers/val-this-via-escape-hex.js',
@@ -71,7 +72,7 @@ run(
7172
});
7273
},
7374
{
74-
testsDirectory: path.dirname(require.resolve('test262/package.json')),
75+
testsDirectory: path.dirname(fileURLToPath(import.meta.resolve('test262/package.json'))),
7576
skip: (test) => {
7677
return (
7778
(test.attrs.features &&

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build": "microbundle --define process.env.NODE_ENV=production --no-sourcemap --tsconfig ./tsconfig.json --format esm,cjs",
1111
"format": "prettier --write .",
1212
"test": "vitest run",
13-
"test:test262": "ts-node -T __test__/run_test262.ts"
13+
"test:test262": "npm run build && node ./__test__/run_test262.mjs"
1414
},
1515
"exports": {
1616
".": [
@@ -37,7 +37,6 @@
3737
"acorn-jsx": "~5.3.2",
3838
"microbundle": "^0.15.1",
3939
"prettier": "~3.5.2",
40-
"ts-node": "^10.9.1",
4140
"typescript": "^4.8.4",
4241
"test262": "git+https://github.com/tc39/test262.git#dac69563480b9f22709fd49d61a32b3a0513b6b1",
4342
"test262-parser-runner": "^0.5.0",

pnpm-lock.yaml

Lines changed: 26 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)