aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-22 00:21:21 +0000
committerGitHub <noreply@github.com>2021-02-22 08:21:21 +0800
commit55b59407e44bcccf0068d6ae2dc3f446d60809b4 (patch)
tree782d8dd1ea1ca6d96fcb06a7c00cff0adf226bfc /test
parentb726e364c1164b0c828d7be04bfcfa21774366a1 (diff)
downloadtracifyjs-55b59407e44bcccf0068d6ae2dc3f446d60809b4.tar.gz
tracifyjs-55b59407e44bcccf0068d6ae2dc3f446d60809b4.zip
fix corner cases in `reduce_vars` (#4674)
Diffstat (limited to 'test')
-rw-r--r--test/compress/arrays.js69
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"
+}