Skip to content

Commit

Permalink
test(minifier): add anonymous function test case for logical expressi…
Browse files Browse the repository at this point in the history
…on to logical assignment compression (#8347)

Added a test case that tells having an anonymous function on the right hand side for "logical expression to logical assignment" compression is fine.
  • Loading branch information
sapphi-red committed Jan 8, 2025
1 parent 9a5c66a commit 3149fe0
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,10 @@ mod test {
test("x && (x = g())", "x &&= g()");
test("x ?? (x = g())", "x ??= g()");

// `||=`, `&&=`, `??=` sets the name property of the function
// Example case: `let f = false; f || (f = () => {}); console.log(f.name)`
test("x || (x = () => 'a')", "x ||= () => 'a'");

test_same("x || (y = 3)");

// foo() might have a side effect
Expand Down

0 comments on commit 3149fe0

Please sign in to comment.