8000 fix: re-order `TemplateElement` fields by overlookmotel · Pull Request #44 · oxc-project/acorn-test262 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: re-order TemplateElement fields #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion src/test262.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ function fixMeriyahNode(node, code) {
node.value.raw = node.value.raw.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
}
// `cooked` and `raw` in opposite order from Acorn (cosmetic difference only)
node.value = { raw: undefined, ...node.value };
if (Object.hasOwn(node.value, 'raw')) {
node.value = { raw: undefined, ...node.value };
}
}
} else if (type === 'ExportNamedDeclaration') {
// `ExportNamedDeclaration` should always have an `attributes` property
Expand Down
5 changes: 5 additions & 0 deletions src/utils/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export function transformerTs(_key, value) {
} else if (type === 'Literal' && Object.hasOwn(value, 'regex')) {
value.regex.flags = [...value.regex.flags].sort().join('');
value.value = null;
} else if (type === 'TemplateElement') {
if (value.value && typeof value.value === 'object' && Object.hasOwn(value.value, 'raw')) {
// Reverse order of `raw` and `cooked` fields to match Acorn
value.value = { raw: undefined, ...value.value };
}
}

// Replace `undefined` with `null`
Expand Down
28 changes: 14 additions & 14 deletions tests/typescript/tests/cases/compiler/APISample_compile.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -892,8 +892,8 @@ __ESTREE_TEST__:PASS:
"start": 969,
"end": 972,
"value": {
"cooked": "",
"raw": ""
"raw": "",
"cooked": ""
},
"tail": false
},
Expand All @@ -902,8 +902,8 @@ __ESTREE_TEST__:PASS:
"start": 996,
"end": 1001,
"value": {
"cooked": " (",
"raw": " ("
"raw": " (",
"cooked": " ("
},
"tail": false
},
Expand All @@ -912,8 +912,8 @@ __ESTREE_TEST__:PASS:
"start": 1009,
"end": 1013,
"value": {
"cooked": ",",
"raw": ","
"raw": ",",
"cooked": ","
},
"tail": false
},
Expand All @@ -922,8 +922,8 @@ __ESTREE_TEST__:PASS:
"start": 1026,
"end": 1032,
"value": {
"cooked": "): ",
"raw": "): "
"raw": "): ",
"cooked": "): "
},
"tail": false
},
Expand All @@ -932,8 +932,8 @@ __ESTREE_TEST__:PASS:
"start": 1039,
"end": 1041,
"value": {
"cooked": "",
"raw": ""
"raw": "",
"cooked": ""
},
"tail": true
}
Expand Down Expand Up @@ -1163,8 +1163,8 @@ __ESTREE_TEST__:PASS:
"start": 1120,
"end": 1150,
"value": {
"cooked": "Process exiting with code '",
"raw": "Process exiting with code '"
"raw": "Process exiting with code '",
"cooked": "Process exiting with code '"
},
"tail": false
},
Expand All @@ -1173,8 +1173,8 @@ __ESTREE_TEST__:PASS:
"start": 1158,
"end": 1162,
"value": {
"cooked": "'.",
"raw": "'."
"raw": "'.",
"cooked": "'."
},
"tail": true
}
Expand Down
20 changes: 10 additions & 10 deletions tests/typescript/tests/cases/compiler/APISample_linter.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -1935,8 +1935,8 @@ __ESTREE_TEST__:PASS:
"start": 2238,
"end": 2241,
"value": {
"cooked": "",
"raw": ""
"raw": "",
"cooked": ""
},
"tail": false
},
Expand All @@ -1945,8 +1945,8 @@ __ESTREE_TEST__:PASS:
"start": 2260,
"end": 2265,
"value": {
"cooked": " (",
"raw": " ("
"raw": " (",
"cooked": " ("
},
"tail": false
},
Expand All @@ -1955,8 +1955,8 @@ __ESTREE_TEST__:PASS:
"start": 2273,
"end": 2277,
"value": {
"cooked": ",",
"raw": ","
"raw": ",",
"cooked": ","
},
"tail": false
},
Expand All @@ -1965,8 +1965,8 @@ __ESTREE_TEST__:PASS:
"start": 2290,
"end": 2296,
"value": {
"cooked": "): ",
"raw": "): "
"raw": "): ",
"cooked": "): "
},
"tail": false
},
Expand All @@ -1975,8 +1975,8 @@ __ESTREE_TEST__:PASS:
"start": 2303,
"end": 2305,
"value": {
"cooked": "",
"raw": ""
"raw": "",
"cooked": ""
},
"tail": true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ __ESTREE_TEST__:PASS:
"start": 494,
"end": 497,
"value": {
"cooked": "",
"raw": ""
"raw": "",
"cooked": ""
},
"tail": false
},
Expand All @@ -300,8 +300,8 @@ __ESTREE_TEST__:PASS:
"start": 530,
"end": 535,
"value": {
"cooked": ": ",
"raw": ": "
"raw": ": ",
"cooked": ": "
},
"tail": false
},
Expand All @@ -310,8 +310,8 @@ __ESTREE_TEST__:PASS:
"start": 552,
"end": 554,
"value": {
"cooked": "",
"raw": ""
"raw": "",
"cooked": ""
},
"tail": true
}
Expand Down
44 changes: 22 additions & 22 deletions tests/typescript/tests/cases/compiler/APISample_watcher.ts.md
F438
Original file line number Diff line number Diff line change
Expand Up @@ -2714,8 +2714,8 @@ __ESTREE_TEST__:PASS:
"start": 2894,
"end": 2906,
"value": {
"cooked": "Emitting ",
"raw": "Emitting "
"raw": "Emitting ",
"cooked": "Emitting "
},
"tail": false
},
Expand All @@ -2724,8 +2724,8 @@ __ESTREE_TEST__:PASS:
"start": 2914,
"end": 2916,
"value": {
"cooked": "",
"raw": ""
"raw": "",
"cooked": ""
},
"tail": true
}
Expand Down Expand Up @@ -2799,8 +2799,8 @@ __ESTREE_TEST__:PASS:
"start": 2968,
"end": 2980,
"value": {
"cooked": "Emitting ",
"raw": "Emitting "
"raw": "Emitting ",
"cooked": "Emitting "
},
"tail": false
},
Expand All @@ -2809,8 +2809,8 @@ __ESTREE_TEST__:PASS:
"start": 2988,
"end": 2997,
"value": {
"cooked": " failed",
"raw": " failed"
"raw": " failed",
"cooked": " failed"
},
"tail": true
}
Expand Down Expand Up @@ -3679,8 +3679,8 @@ __ESTREE_TEST__:PASS:
"start": 3708,
"end": 3719,
"value": {
"cooked": " Error ",
"raw": " Error "
"raw": " Error ",
"cooked": " Error "
},
"tail": false
},
Expand All @@ -3689,8 +3689,8 @@ __ESTREE_TEST__:PASS:
"start": 3743,
"end": 3748,
"value": {
"cooked": " (",
"raw": " ("
"raw": " (",
"cooked": " ("
},
"tail": false
},
Expand All @@ -3699,8 +3699,8 @@ __ESTREE_TEST__:PASS:
"start": 3756,
"end": 3760,
"value": {
"cooked": ",",
"raw": ","
"raw": ",",
"cooked": ","
},
"tail": false
},
Expand All @@ -3709,8 +3709,8 @@ __ESTREE_TEST__:PASS:
"start": 3773,
"end": 3779,
"value": {
"cooked": "): ",
"raw": "): "
"raw": "): ",
"cooked": "): "
},
"tail": false
},
Expand All @@ -3719,8 +3719,8 @@ __ESTREE_TEST__:PASS:
"start": 3786,
"end": 3788,
"value": {
"cooked": "",
"raw": ""
"raw": "",
"cooked": ""
},
"tail": true
}
Expand Down Expand Up @@ -3879,8 +3879,8 @@ __ESTREE_TEST__:PASS:
"start": 3852,
"end": 3864,
"value": {
"cooked": " Error: ",
"raw": " Error: "
"raw": " Error: ",
"cooked": " Error: "
},
"tail": false
},
Expand All @@ -3889,8 +3889,8 @@ __ESTREE_TEST__:PASS:
"start": 3871,
"end": 3873,
"value": {
"cooked": "",
"raw": ""
"raw": "",
"cooked": ""
},
"tail": true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ __ESTREE_TEST__:PASS:
"start": 48,
"end": 51,
"value": {
"cooked": "1",
"raw": "1"
"raw": "1",
"cooked": "1"
},
"tail": true
}
Expand Down Expand Up @@ -196,8 +196,8 @@ __ESTREE_TEST__:PASS:
"start": 145,
"end": 155,
"value": {
"cooked": "template",
"raw": "template"
"raw": "template",
"cooked": "template"
},
"tail": true
}
Expand Down Expand Up @@ -374,8 +374,8 @@ __ESTREE_TEST__:PASS:
"start": 242,
"end": 245,
"value": {
"cooked": "c",
"raw": "c"
"raw": "c",
"cooked": "c"
},
"tail": true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@ __ESTREE_TEST__:PASS:
"start": 516,
"end": 519,
"value": {
"cooked": "",
"raw": ""
"raw": "",
"cooked": ""
},
"tail": false
},
Expand All @@ -612,8 +612,8 @@ __ESTREE_TEST__:PASS:
"start": 527,
"end": 557,
"value": {
"cooked": " is not a supported operator",
"raw": " is not a supported operator"
"raw": " is not a supported operator",
"cooked": " is not a supported operator"
},
"tail": true
}
Expand Down
Loading
Loading
0