diff --git a/crates/oxc_minifier/src/peephole/collapse_variable_declarations.rs b/crates/oxc_minifier/src/peephole/collapse_variable_declarations.rs index 7149079b6ce0f..10e4c87a85db6 100644 --- a/crates/oxc_minifier/src/peephole/collapse_variable_declarations.rs +++ b/crates/oxc_minifier/src/peephole/collapse_variable_declarations.rs @@ -191,17 +191,16 @@ mod test { ); test_same("function f(){ for(; a < 2 ; a++) foo() }"); - // TODO // Verify destructuring assignments are moved. - // test( - // "[a, b] = [1, 2]; for (; a < 2; a = b++) foo();", - // "for ([a, b] = [1, 2]; a < 2; a = b++) foo();", - // ); - - // test( - // "var [a, b] = [1, 2]; for (; a < 2; a = b++) foo();", - // "var a; var b; for ([a, b] = [1, 2]; a < 2; a = b++) foo();", - // ); + test( + "[a, b] = [1, 2]; for (; a < 2; a = b++) foo();", + "for ([a, b] = [1, 2]; a < 2; a = b++) foo();", + ); + + test( + "var [a, b] = [1, 2]; for (; a < 2; a = b++) foo();", + "for (var [a, b] = [1, 2]; a < 2; a = b++) foo();", + ); } #[test] diff --git a/crates/oxc_minifier/src/peephole/fold_constants.rs b/crates/oxc_minifier/src/peephole/fold_constants.rs index c564a8a6f89c4..7b43b8e05e867 100644 --- a/crates/oxc_minifier/src/peephole/fold_constants.rs +++ b/crates/oxc_minifier/src/peephole/fold_constants.rs @@ -1509,7 +1509,7 @@ mod test { fold("x = foo() + 'a' + 2", "x = foo()+\"a2\""); fold("x = '' + null", "x = 'null'"); fold("x = true + '' + false", "x = 'truefalse'"); - // fold("x = '' + []", "x = ''"); + fold("x = '' + []", "x = ''"); fold("x = foo() + 'a' + 1 + 1", "x = foo() + 'a11'"); fold("x = 1 + 1 + 'a'", "x = '2a'"); fold("x = 1 + 1 + 'a'", "x = '2a'"); diff --git a/crates/oxc_minifier/src/peephole/replace_known_methods.rs b/crates/oxc_minifier/src/peephole/replace_known_methods.rs index 8be02a5f491bf..6755c8bac52b0 100644 --- a/crates/oxc_minifier/src/peephole/replace_known_methods.rs +++ b/crates/oxc_minifier/src/peephole/replace_known_methods.rs @@ -1325,10 +1325,9 @@ mod test { test_value("Math.abs(NaN)", "NaN"); test_value("Math.abs(-0)", "0"); test_value("Math.abs(-Infinity)", "Infinity"); - // TODO - // test_value("Math.abs([])", "0"); - // test_value("Math.abs([2])", "2"); - // test_value("Math.abs([1,2])", "NaN"); + test_value("Math.abs([])", "0"); + test_value("Math.abs([2])", "2"); + test_value("Math.abs([1,2])", "NaN"); test_value("Math.abs({})", "NaN"); test_value("Math.abs('string');", "NaN"); }