Skip to content

Commit 211083c

Browse files
test(test262): accept a parse error only where one is reported or thrown
A negative parse test passed on any thrown value, so a bundle that ran into the test's unreachable call passed too. It now needs webpack's parse error or a SyntaxError from the engine. The top-level `return` cases are built as CommonJS, so they are listed as a deliberate divergence. Claude-Session: https://claude.ai/code/session_019cRZoHW2M4sCbrLFgrAc6b
1 parent fbcf4bc commit 211083c

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

‎test/specCases/test262.spectest.js‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,6 +2043,23 @@ const deliberateProductionDivergences = [
20432043
"statements/class/definition/prototype-getter.js",
20442044
"module-code/eval-export-dflt-expr-err-get-value.js"
20452045
];
2046+
2047+
// A Script runs as CommonJS, which may return at its top level, so webpack
2048+
// builds these where the spec rejects them; `configCases/module/iife-top-level-return`
2049+
// pins the bundle it writes.
2050+
const deliberateDivergences = [
2051+
"global-code/return.js",
2052+
"statements/return/S12.9_A1_T1.js",
2053+
"statements/return/S12.9_A1_T2.js",
2054+
"statements/return/S12.9_A1_T3.js",
2055+
"statements/return/S12.9_A1_T4.js",
2056+
"statements/return/S12.9_A1_T5.js",
2057+
"statements/return/S12.9_A1_T6.js",
2058+
"statements/return/S12.9_A1_T7.js",
2059+
"statements/return/S12.9_A1_T8.js",
2060+
"statements/return/S12.9_A1_T9.js",
2061+
"statements/return/S12.9_A1_T10.js"
2062+
];
20462063
/* cspell:enable */
20472064

20482065
const testFiles = fs
@@ -2123,6 +2140,7 @@ describe("test262", () => {
21232140
meta.features.includes("source-phase-imports-module-source")) &&
21242141
!(meta.negative && meta.negative.phase === "parse")) ||
21252142
knownBugs.includes(name) ||
2143+
deliberateDivergences.includes(name) ||
21262144
(mode === "production" &&
21272145
deliberateProductionDivergences.includes(name)) ||
21282146
(minify !== undefined && renamedByMinifier.test(name))
@@ -2330,12 +2348,16 @@ describe("test262", () => {
23302348

23312349
const { warnings, errors } = stats.compilation;
23322350

2351+
// webpack reports the parse error, or the engine throws it loading the
2352+
// bundle; a bundle that runs into the test's unreachable call is not one.
23332353
const isExpectedParseError =
23342354
errored &&
23352355
meta.negative &&
23362356
meta.negative.phase === "parse" &&
2337-
// meta.negative.type === errored.constructor.name &&
2338-
errors.every((item) => item.name === "ModuleParseError");
2357+
errors.every((item) => item.name === "ModuleParseError") &&
2358+
(errors.length > 0 ||
2359+
(typeof errored === "object" &&
2360+
errored.name === "SyntaxError"));
23392361

23402362
const isExpectedRuntimeError =
23412363
errored &&

0 commit comments

Comments
 (0)