Skip to content

Commit

Permalink
10
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Jan 20, 2025
1 parent dac84d5 commit 19357e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ mod test {

test(
"var x = 2; foo(x); x = 3; x = 1; var y = 2; var z = 4; x = 5",
"var x = 2; foo(x); x = 3; x = 1; var y = 2, z = 4; x = 5",
"var x = 2; foo(x), x = 3, x = 1; var y = 2, z = 4; x = 5",
);
}

Expand All @@ -292,9 +292,9 @@ mod test {

#[test]
fn test_aggressive_redeclaration_in_for() {
test_same("for(var x = 1; x = 2; x = 3) {x = 4}");
test_same("for(var x = 1; x = 2; x = 3) x = 4");
test_same("for(var x = 1; y = 2; z = 3) {var a = 4}");
test_same("var x; for(x = 1; x = 2; z = 3) {x = 4}");
test_same("var x; for(x = 1; x = 2; z = 3) x = 4");
}

#[test]
Expand Down Expand Up @@ -342,9 +342,9 @@ mod test {

#[test]
fn test_aggressive_redeclaration_of_let_in_for() {
test_same("for(let x = 1; x = 2; x = 3) {x = 4}");
test_same("for(let x = 1; x = 2; x = 3) x = 4");
test_same("for(let x = 1; y = 2; z = 3) {let a = 4}");
test_same("let x; for(x = 1; x = 2; z = 3) {x = 4}");
test_same("let x; for(x = 1; x = 2; z = 3) x = 4");
}

#[test]
Expand All @@ -362,16 +362,19 @@ mod test {

// do not redeclare function parameters
// incompatible with strict mode
test_same("function f(x) { let y = 3; x = 4; x + y; }");
test_same("function f(x) { let y = 3; x = 4, x + y; }");
}

#[test]
fn test_arrow_function() {
test("() => {let x = 1; let y = 2; x + y; }", "() => {let x = 1, y = 2; x + y; }");
test(
"(() => { let x = 1; let y = 2; x + y; })()",
"(() => { let x = 1, y = 2; x + y; })()",
);

// do not redeclare function parameters
// incompatible with strict mode
test_same("(x) => {x = 4; let y = 2; x + y; }");
test_same("((x) => { x = 4; let y = 2; x + y; })()");
}

#[test]
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_minifier/src/ast_passes/remove_unused_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ mod test {
use crate::tester::{test, test_same};

#[test]
#[ignore]
fn simple() {
test("var x", "");
test_same("var x = 1");
Expand Down

0 comments on commit 19357e1

Please sign in to comment.