diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-09-03 10:41:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-03 17:41:33 +0800 |
commit | 980fcbb56b674c1c78e1483b6d66a2f49e58d80b (patch) | |
tree | c0d4c62385f5b84669384b6853d28dfe5dca6243 /test/compress | |
parent | 375ebe316d8ff1a421c1cafc95d64e3377f7737b (diff) | |
download | tracifyjs-980fcbb56b674c1c78e1483b6d66a2f49e58d80b.tar.gz tracifyjs-980fcbb56b674c1c78e1483b6d66a2f49e58d80b.zip |
enhance `unused` (#4090)
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/drop-unused.js | 57 | ||||
-rw-r--r-- | test/compress/functions.js | 3 |
2 files changed, 58 insertions, 2 deletions
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js index 6ab4fe3b..052a013b 100644 --- a/test/compress/drop-unused.js +++ b/test/compress/drop-unused.js @@ -2848,3 +2848,60 @@ issue_4025: { "1 1 1", ] } + +forin_var_1: { + options = { + unused: true, + } + input: { + var k; + for (k in [ 1, 2 ]) + console.log(k); + for (k in { PASS: 3 }) + console.log(k); + console.log(k); + } + expect: { + for (var k in [ 1, 2 ]) + console.log(k); + for (k in { PASS: 3 }) + console.log(k); + console.log(k); + } + expect_stdout: [ + "0", + "1", + "PASS", + "PASS", + ] +} + +forin_var_2: { + options = { + unused: true, + } + input: { + console.log(function() { + switch (0) { + case function() { + for (a in 0); + }: + var b = 0; + } + for (var c = 0; a;); + var a; + }()); + } + expect: { + console.log(function() { + switch (0) { + case function() { + for (a in 0); + }: + } + for (; a;); + var a; + }()); + } + expect_stdout: "undefined" +} diff --git a/test/compress/functions.js b/test/compress/functions.js index 18f4f900..8bfb2eaf 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -1483,8 +1483,7 @@ issue_2663_2: { } expect: { (function() { - var i; - for (i in { a: 1, b: 2, c: 3 }) + for (var i in { a: 1, b: 2, c: 3 }) j = i, console.log(j); var j; })(); |