Skip to content

Commit 6f8f3fb

Browse files
test: read an escape a string runs out of the way the printer does
§4.3.4 ignores a `\` at the end of a string, where an escape anywhere else names U+FFFD — the oracle named one on the as-written side only, which reads as a difference the printer never made.
1 parent 1f66026 commit 6f8f3fb

5 files changed

Lines changed: 11 additions & 9 deletions

File tree

‎test/configCases/css/minimize-strings/__snapshots__/ConfigCacheTest.snap‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ b\\"}",
4646
4747
exports[`ConfigCacheTestCases css minimize-strings minimize-strings should compile 2`] = `
4848
Array [
49-
"/*! webpack: a string the tokenizer closes at EOF keeps its one quote */.t31:after{content:\\"unterminated
50-
}",
49+
"/*! webpack: a string the tokenizer closes at EOF keeps its one quote */.t31:after{content:\\"unterminated\\\\
50+
\\"}",
5151
]
5252
`;

‎test/configCases/css/minimize-strings/__snapshots__/ConfigTest.snap‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ b\\"}",
4646
4747
exports[`ConfigTestCases css minimize-strings minimize-strings should compile 2`] = `
4848
Array [
49-
"/*! webpack: a string the tokenizer closes at EOF keeps its one quote */.t31:after{content:\\"unterminated
50-
}",
49+
"/*! webpack: a string the tokenizer closes at EOF keeps its one quote */.t31:after{content:\\"unterminated\\\\
50+
\\"}",
5151
]
5252
`;

‎test/configCases/css/minimize-strings/unterminated.css‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
stylesheet it is emitted into. */
55

66
/*! webpack: a string the tokenizer closes at EOF keeps its one quote */
7-
.t31:after { content: "unterminated
7+
.t31:after { content: "unterminated\

‎test/helpers/syntaxEquivalence.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,16 @@ const installHelpers = () => {
254254
// otherwise read as punctuation.
255255
if (ch === "\\") {
256256
const [named, end] = readEscape(text, at);
257+
// §4.3.4: a `\` a string runs out after names nothing, unlike the
258+
// U+FFFD the same escape names anywhere else.
259+
const ranOut = end === at + 1;
257260
at = end - 1;
258261
const code = /** @type {number} */ (named.codePointAt(0));
259262
const written = BARE_ESCAPED.test(named)
260263
? named
261264
: `\\${code.toString(16).padStart(6, "0")}`;
262265
if (quote === "") out += written;
263-
else string += named;
266+
else if (!ranOut) string += named;
264267
continue;
265268
}
266269
if (quote !== "") {

‎test/syntaxEquivalence.spectest.js‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,8 @@ describe("printer output in real Chrome", () => {
331331
why = `${facet}: ${a.length} vs ${b.length}`;
332332
break;
333333
}
334-
// Only an element's own shape carries a number the printer rounds —
335-
// a `style` attribute's computed lengths. Text, scripts, templates
336-
// and shadow content are compared exactly, as they are written.
334+
// Only an element's own shape carries a number the printer rounds;
335+
// everything else is text, compared exactly as it is written.
337336
const rounded = facet === "elements";
338337
const found = a.findIndex((entry, i) =>
339338
rounded ? !numericallyEqual(entry, b[i]) : entry !== b[i]

0 commit comments

Comments
 (0)