diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-07-12 00:43:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-12 07:43:13 +0800 |
commit | 0d350b78bfd7df22a6311efa94761e71950e3494 (patch) | |
tree | a75e9cf13c3cefdd406fd26dc21ac8c2e0bc85f5 /test | |
parent | 1ad830facb198878d7fe35586bca89c42b1ea263 (diff) | |
download | tracifyjs-0d350b78bfd7df22a6311efa94761e71950e3494.tar.gz tracifyjs-0d350b78bfd7df22a6311efa94761e71950e3494.zip |
fix corner cases in `unused` (#5075)
fixes #5074
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/destructured.js | 134 |
1 files changed, 133 insertions, 1 deletions
diff --git a/test/compress/destructured.js b/test/compress/destructured.js index 45724b1a..54ee1ac8 100644 --- a/test/compress/destructured.js +++ b/test/compress/destructured.js @@ -1154,7 +1154,7 @@ drop_hole: { node_version: ">=6" } -keep_key: { +keep_key_1: { options = { evaluate: true, side_effects: true, @@ -1174,6 +1174,39 @@ keep_key: { node_version: ">=6" } +keep_key_2: { + options = { + evaluate: true, + toplevel: true, + unused: true, + } + input: { + var { 42: a } = { [(console.log("PASS"), 42)](){} }; + } + expect: { + var {} = { [(console.log("PASS"), 42)]: 0 }; + } + expect_stdout: "PASS" + node_version: ">=6" +} + +keep_key_2_pure_getters: { + options = { + evaluate: true, + pure_getters: "strict", + toplevel: true, + unused: true, + } + input: { + var { 42: a } = { [(console.log("PASS"), 42)](){} }; + } + expect: { + console.log("PASS"); + } + expect_stdout: "PASS" + node_version: ">=6" +} + keep_reference: { options = { reduce_vars: true, @@ -2816,3 +2849,102 @@ issue_5071_2: { expect_stdout: "PASS" node_version: ">=6" } + +issue_5074_getter: { + options = { + evaluate: true, + side_effects: true, + unused: true, + } + input: { + ({} = { get [(console.log("PASS"), 42)]() {} }); + } + expect: { + ({} = { [(console.log("PASS"), 42)]: 0 }); + } + expect_stdout: "PASS" + node_version: ">=6" +} + +issue_5074_getter_pure_getters: { + options = { + evaluate: true, + pure_getters: "strict", + side_effects: true, + unused: true, + } + input: { + ({} = { get [(console.log("PASS"), 42)]() {} }); + } + expect: { + console.log("PASS"); + } + expect_stdout: "PASS" + node_version: ">=6" +} + +issue_5074_setter: { + options = { + evaluate: true, + side_effects: true, + unused: true, + } + input: { + ({} = { set [(console.log("PASS"), 42)](v) {} }); + } + expect: { + ({} = { [(console.log("PASS"), 42)]: 0 }); + } + expect_stdout: "PASS" + node_version: ">=6" +} + +issue_5074_setter_pure_getters: { + options = { + evaluate: true, + pure_getters: "strict", + side_effects: true, + unused: true, + } + input: { + ({} = { set [(console.log("PASS"), 42)](v) {} }); + } + expect: { + console.log("PASS"); + } + expect_stdout: "PASS" + node_version: ">=6" +} + +issue_5074_method: { + options = { + evaluate: true, + side_effects: true, + unused: true, + } + input: { + ({} = { [(console.log("PASS"), 42)]() {} }); + } + expect: { + ({} = { [(console.log("PASS"), 42)]: 0 }); + } + expect_stdout: "PASS" + node_version: ">=6" +} + +issue_5074_method_pure_getters: { + options = { + evaluate: true, + pure_getters: "strict", + side_effects: true, + unused: true, + } + input: { + ({} = { [(console.log("PASS"), 42)]() {} }); + } + expect: { + console.log("PASS"); + } + expect_stdout: "PASS" + node_version: ">=6" +} |