Skip to content

Commit f9a5937

Browse files
committed
test: update minimifier tests
1 parent 0cf8a57 commit f9a5937

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

crates/oxc_minifier/src/peephole/fold_constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ mod test {
13801380
fn test_fold_logical_op2() {
13811381
fold("x = function(){} && x", "x=x");
13821382
fold("x = true && function(){}", "x=function(){}");
1383-
fold("x = [(function(){alert(x)})()] && x", "x=((function(){alert(x)})(),x)");
1383+
fold("x = [(function(){alert(x)})()] && x", "x=(alert(x), x)");
13841384
}
13851385

13861386
#[test]

crates/oxc_minifier/tests/peephole/esbuild.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,11 +1297,11 @@ fn test_flatten_values() {
12971297
test("(function() {})()", "");
12981298
test("(function*() {})()", "");
12991299
test("(async function() {})()", "");
1300-
test("(function() { a() })()", "(function() { a();})();");
1300+
test("(function() { a() })()", "a();");
13011301
test("(function*() { a() })()", "(function* () { a();})();");
13021302
test("(async function() { a() })()", "(async function() { a();})();");
13031303
test("(() => x)()", "x;");
1304-
test("/* @__PURE__ */ (() => x)()", "");
1304+
test("/* @__PURE__ */ (() => x)()", "x;");
13051305
test("/* @__PURE__ */ (() => x)(y, z)", "y, z;");
13061306
test("_ = `a${x}b${y}c`", "_ = `a${x}b${y}c`;");
13071307
test("_ = `a${x}b${'y'}c`", "_ = `a${x}byc`;");

crates/oxc_minifier/tests/peephole/inline_single_use_variable.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,20 +226,20 @@ fn test_inline_single_use_variable() {
226226
// cannot be compressed to `function wrapper() { var foo; globalThis[console.log(foo)] = (() => { foo = 1 })() }`
227227
test(
228228
"function wrapper() { var foo; var bar = (() => { foo = 1 })(); globalThis[console.log(foo)] = bar }",
229-
"function wrapper() { var foo, bar = (() => { foo = 1 })(); globalThis[console.log(foo)] = bar }",
229+
"function wrapper() { var foo, bar = (foo = 1, void 0); globalThis[console.log(foo)] = bar }",
230230
);
231231
// cannot be compressed to `function wrapper() { let foo; return foo.bar = (() => { foo = {} })(), foo }`
232232
test(
233233
"function wrapper() { let foo; const bar = (() => { foo = {} })(); foo.bar = bar; return foo }",
234-
"function wrapper() { let foo, bar = (() => { foo = {} })(); return foo.bar = bar, foo }",
234+
"function wrapper() { let foo, bar = (foo = {}, void 0); return foo.bar = void 0, foo }",
235235
);
236236
test(
237237
"function wrapper() { let foo = {}; const bar = (() => { console.log() })(); foo.bar = bar; return foo }",
238-
"function wrapper() { let foo = {}; return foo.bar = (() => { console.log() })(), foo }",
238+
"function wrapper() { let foo = {}, bar = (console.log(), void 0); return foo.bar = void 0, foo; }",
239239
);
240240
test(
241241
"function wrapper() { const bar = (() => { console.log() })(); this.bar = bar; return this }",
242-
"function wrapper() { return this.bar = (() => { console.log() })(), this }",
242+
"function wrapper() { let bar = (console.log(), void 0); return this.bar = void 0, this; }",
243243
);
244244
}
245245

crates/oxc_minifier/tests/peephole/merge_assignments_to_declarations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn merge_assignments_to_declarations_let() {
3636
test("let a, b; a = c(); b = d()", "let a, b; a = c(), b = d()"); // same as above
3737
test("let a, b; a = b", "let a, b; a = void 0"); // `let a = b, b` will cause TDZ error
3838
test_same("let a; a = foo(a)"); // `let a = foo(a)` will cause TDZ error
39-
test_same("let a; a = (() => a)()"); // `let a = (() => a)()` will cause TDZ error
39+
test("let a; a = (() => a)()", "let a; a = a;"); // `let a = (() => a)()` will cause TDZ error
4040
test("let a; a = () => a", "let a = () => a");
4141
}
4242

crates/oxc_minifier/tests/peephole/obscure_edge_cases.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ fn test_esm_module_patterns() {
533533
);
534534

535535
// ESM with IIFE patterns
536-
test("export default (() => { return 1 + 2; })();", "export default (() => 3)();");
536+
test("export default (() => { return 1 + 2; })();", "export default 3;");
537537
test(
538538
"export default (async () => { return await fetchData(); })();",
539539
"export default (async () => await fetchData())();",

0 commit comments

Comments
 (0)