diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-12-01 22:41:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-01 22:41:35 +0800 |
commit | 9a6b11f8e628c66731c4037ff408bb969003e6f7 (patch) | |
tree | f051f2404ce1049b56387e074c11fac589a5eed0 /test/compress/conditionals.js | |
parent | 7ac6fdcc9923e173522c4b94b919ac09049024f9 (diff) | |
download | tracifyjs-9a6b11f8e628c66731c4037ff408bb969003e6f7.tar.gz tracifyjs-9a6b11f8e628c66731c4037ff408bb969003e6f7.zip |
improve boolean compression (#2548)
fixes #2535
Diffstat (limited to 'test/compress/conditionals.js')
-rw-r--r-- | test/compress/conditionals.js | 73 |
1 files changed, 72 insertions, 1 deletions
diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js index 22947d86..89c05263 100644 --- a/test/compress/conditionals.js +++ b/test/compress/conditionals.js @@ -1016,7 +1016,7 @@ delete_conditional_2: { expect_stdout: true } -issue_2535: { +issue_2535_1: { options = { booleans: true, conditionals: true, @@ -1044,3 +1044,74 @@ issue_2535: { (x(), 0) && y(); } } + +issue_2535_2: { + options = { + booleans: true, + conditionals: true, + evaluate: true, + side_effects: true, + } + input: { + function x() {} + function y() { + return "foo"; + } + console.log((x() || true) || y()); + console.log((y() || true) || x()); + console.log((x() || true) && y()); + console.log((y() || true) && x()); + console.log((x() && true) || y()); + console.log((y() && true) || x()); + console.log((x() && true) && y()); + console.log((y() && true) && x()); + console.log((x() || false) || y()); + console.log((y() || false) || x()); + console.log((x() || false) && y()); + console.log((y() || false) && x()); + console.log((x() && false) || y()); + console.log((y() && false) || x()); + console.log((x() && false) && y()); + console.log((y() && false) && x()); + } + expect: { + function x() {} + function y() { + return "foo"; + } + console.log(x() || !0); + console.log(y() || !0); + console.log((x(), y())); + console.log((y(), x())); + console.log(!!x() || y()); + console.log(!!y() || x()); + console.log(x() && y()); + console.log(y() && x()); + console.log(x() || y()); + console.log(y() || x()); + console.log(!!x() && y()); + console.log(!!y() && x()); + console.log((x(), y())); + console.log((y(), x())); + console.log(x() && !1); + console.log(y() && !1); + } + expect_stdout: [ + "true", + "foo", + "foo", + "undefined", + "foo", + "true", + "undefined", + "undefined", + "foo", + "foo", + "false", + "undefined", + "foo", + "undefined", + "undefined", + "false", + ] +} |