diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-02-22 00:21:21 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-22 08:21:21 +0800 |
commit | 55b59407e44bcccf0068d6ae2dc3f446d60809b4 (patch) | |
tree | 782d8dd1ea1ca6d96fcb06a7c00cff0adf226bfc /test | |
parent | b726e364c1164b0c828d7be04bfcfa21774366a1 (diff) | |
download | tracifyjs-55b59407e44bcccf0068d6ae2dc3f446d60809b4.tar.gz tracifyjs-55b59407e44bcccf0068d6ae2dc3f446d60809b4.zip |
fix corner cases in `reduce_vars` (#4674)
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/arrays.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/test/compress/arrays.js b/test/compress/arrays.js index fff7e9b6..4767a9a5 100644 --- a/test/compress/arrays.js +++ b/test/compress/arrays.js @@ -355,3 +355,72 @@ constructor_good: { expect_stdout: true expect_warnings: [] } + +unsafe_evaluate_modified_binary: { + options = { + evaluate: true, + reduce_vars: true, + unsafe: true, + } + input: { + (function(a) { + (console && a).push(1); + if (a.length) + console.log("PASS"); + })([]); + } + expect: { + (function(a) { + (console && a).push(1); + if (a.length) + console.log("PASS"); + })([]); + } + expect_stdout: "PASS" +} + +unsafe_evaluate_modified_conditional: { + options = { + evaluate: true, + reduce_vars: true, + unsafe: true, + } + input: { + (function(a) { + (console ? a : []).push(1); + if (a.length) + console.log("PASS"); + })([]); + } + expect: { + (function(a) { + (console ? a : []).push(1); + if (a.length) + console.log("PASS"); + })([]); + } + expect_stdout: "PASS" +} + +unsafe_evaluate_modified_sequence: { + options = { + evaluate: true, + reduce_vars: true, + unsafe: true, + } + input: { + (function(a) { + (0, a).push(1); + if (a.length) + console.log("PASS"); + })([]); + } + expect: { + (function(a) { + (0, a).push(1); + if (a.length) + console.log("PASS"); + })([]); + } + expect_stdout: "PASS" +} |