diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-01-05 07:02:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-05 15:02:49 +0800 |
commit | 6eceac096694cfa3390e7112c4764a235592751d (patch) | |
tree | e22a76acbb8b27726f271c57306b8a08d78e4ab4 /test | |
parent | fc5aee662d99257f59830ebcd5053ead48c9039b (diff) | |
download | tracifyjs-6eceac096694cfa3390e7112c4764a235592751d.tar.gz tracifyjs-6eceac096694cfa3390e7112c4764a235592751d.zip |
enhance `inline` & `side_effects` (#4506)
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/default-values.js | 57 | ||||
-rw-r--r-- | test/compress/destructured.js | 42 |
2 files changed, 79 insertions, 20 deletions
diff --git a/test/compress/default-values.js b/test/compress/default-values.js index 7308b303..0fa27ea5 100644 --- a/test/compress/default-values.js +++ b/test/compress/default-values.js @@ -354,6 +354,22 @@ inline_constant: { node_version: ">=6" } +inline_destructured: { + options = { + inline: true, + } + input: { + console.log(function([ a ] = []) { + return "PASS"; + }()); + } + expect: { + console.log(([ [] = [] ] = [], "PASS")); + } + expect_stdout: "PASS" + node_version: ">=6" +} + inline_function: { options = { default_values: true, @@ -423,6 +439,45 @@ inline_loop_2: { node_version: ">=6" } +inline_side_effects_1: { + options = { + inline: true, + toplevel: true, + } + input: { + var a = 42; + (function(b = --a) {})(console); + console.log(a); + } + expect: { + var a = 42; + [ b = --a ] = [ console ], + void 0; + var b; + console.log(a); + } + expect_stdout: "42" + node_version: ">=6" +} + +inline_side_effects_2: { + options = { + side_effects: true, + } + input: { + var a = 42; + (function(b = --a) {})(console); + console.log(a); + } + expect: { + var a = 42; + [ 0[0] = --a ] = [ console ]; + console.log(a); + } + expect_stdout: "42" + node_version: ">=6" +} + drop_empty_iife: { options = { side_effects: true, @@ -1419,7 +1474,7 @@ issue_4502_4: { (function(a, b = console.log("FAIL")) {})(..."" + console.log(42)); } expect: { - (function(a, b = console.log("FAIL")) {})(..."" + console.log(42)); + [ , 0[0] = console.log("FAIL") ] = [ ..."" + console.log(42) ]; } expect_stdout: "42" node_version: ">=6" diff --git a/test/compress/destructured.js b/test/compress/destructured.js index 9812b146..f9d32ce0 100644 --- a/test/compress/destructured.js +++ b/test/compress/destructured.js @@ -188,7 +188,7 @@ funarg_side_effects_1: { } expect: { try { - (function({}) {})(); + [ {} ] = []; } catch (e) { console.log("PASS"); } @@ -682,7 +682,7 @@ funarg_inline: { } expect: { try { - (function({}) {})(); + [ {} ] = []; } catch (e) { console.log("PASS"); } @@ -1718,10 +1718,14 @@ issue_4312: { expect: { var a; b = "PASS", - (function({ - [a = b]: d, - }){})((c = "FAIL") && c); - var b, c; + c = "FAIL", + [ + { + [a = b]: d, + }, + ] = [ c && c ], + void 0; + var b, c, d; console.log(a); } expect_stdout: "PASS" @@ -1783,9 +1787,7 @@ issue_4319: { function f(a) { while (!a); } - console.log(function({}) { - return f(console); - }(0)); + console.log(([ {} ] = [ 0 ], f(console))); } expect_stdout: "undefined" node_version: ">=6" @@ -1809,11 +1811,9 @@ issue_4321: { } expect: { try { - console.log(function({}) { - return function() { - while (!console); - }(); - }()); + console.log(([ {} ] = [], function() { + while (!console); + }())); } catch (e) { console.log("PASS"); } @@ -1844,11 +1844,15 @@ issue_4323: { } expect: { var a = 0; - (function({ - [function a() { - console.log(typeof a); - }()]: d, - }) {})(0); + [ + { + [function a() { + console.log(typeof a); + }()]: d, + }, + ] = [ 0 ], + void 0; + var d; e = 1, console.log, void e.p; |