diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-03-24 14:30:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-24 14:30:31 +0800 |
commit | f3a1694a4182e1a26d3dd63dd21fcd4b38dafe3a (patch) | |
tree | 8c60fe21729b8de44bede0e2c4b57c20880f506c /test | |
parent | 2e0dc970037b3a22fb367ab77c5fe506317ee40b (diff) | |
download | tracifyjs-f3a1694a4182e1a26d3dd63dd21fcd4b38dafe3a.tar.gz tracifyjs-f3a1694a4182e1a26d3dd63dd21fcd4b38dafe3a.zip |
fix assignment substitution in sequences (#1643)
take side effects of binary boolean operations into account
fixes #1639
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/issue-1639.js | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/test/compress/issue-1639.js b/test/compress/issue-1639.js new file mode 100644 index 00000000..b6a9647f --- /dev/null +++ b/test/compress/issue-1639.js @@ -0,0 +1,88 @@ + +issue_1639_1: { + options = { + booleans: true, + cascade: true, + conditionals: true, + evaluate: true, + join_vars: true, + loops: true, + sequences: true, + side_effects: true, + } + input: { + var a = 100, b = 10; + + var L1 = 5; + while (--L1 > 0) { + if ((--b), false) { + if (b) { + var ignore = 0; + } + } + } + + console.log(a, b); + } + expect: { + for (var a = 100, b = 10, L1 = 5; --L1 > 0;) + if (--b, !1) var ignore = 0; + console.log(a, b); + } + expect_stdout: true +} + +issue_1639_2: { + options = { + booleans: true, + cascade: true, + conditionals: true, + evaluate: true, + join_vars: true, + sequences: true, + side_effects: true, + } + input: { + var a = 100, b = 10; + + function f19() { + if (++a, false) + if (a) + if (++a); + } + f19(); + + console.log(a, b); + } + expect: { + var a = 100, b = 10; + function f19() { + ++a, 1; + } + f19(), + console.log(a, b); + } + expect_stdout: true +} + +issue_1639_3: { + options = { + booleans: true, + cascade: true, + conditionals: true, + evaluate: true, + sequences: true, + side_effects: true, + } + input: { + var a = 100, b = 10; + a++ && false && a ? 0 : 0; + console.log(a, b); + } + expect: { + var a = 100, b = 10; + a++, + console.log(a, b); + } + expect_stdout: true +} |