diff options
author | Richard van Velzen <rvanvelzen1@gmail.com> | 2015-12-26 14:28:33 +0100 |
---|---|---|
committer | Richard van Velzen <rvanvelzen1@gmail.com> | 2015-12-26 14:28:33 +0100 |
commit | 60c4030a4d6758e98bb534cdcfe26bebda9ddd2b (patch) | |
tree | 97268bd04343593fefbfdeb80bea505819b0b37a /test | |
parent | ac810dc07a6cfb2bd32cf5c8eb2f496bfe0edf3d (diff) | |
parent | 774bda13cdf8de39de7f236ed95ae3da4fc7d822 (diff) | |
download | tracifyjs-60c4030a4d6758e98bb534cdcfe26bebda9ddd2b.tar.gz tracifyjs-60c4030a4d6758e98bb534cdcfe26bebda9ddd2b.zip |
Merge pull request #874 from kzc/fix-conditionals
#873 Fix `conditionals` optimizations with default compress options
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/conditionals.js | 204 |
1 files changed, 199 insertions, 5 deletions
diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js index 16ef6d66..65cfea64 100644 --- a/test/compress/conditionals.js +++ b/test/compress/conditionals.js @@ -332,53 +332,247 @@ cond_7_1: { cond_8: { options = { conditionals: true, - evaluate : true + evaluate : true, + booleans : false }; input: { var a; // compress these a = condition ? true : false; - a = !condition ? true : false; - a = condition() ? true : false; + a = condition ? !0 : !1; + a = !condition ? !null : !2; + a = condition() ? !0 : !-3.5; + if (condition) { a = true; } else { a = false; } - a = condition ? false : true; + if (condition) { + a = !0; + } else { + a = !1; + } + a = condition ? false : true; a = !condition ? false : true; - a = condition() ? false : true; + a = condition ? !3 : !0; + a = !condition ? !2 : !0; + a = condition() ? !1 : !0; + if (condition) { a = false; } else { a = true; } + if (condition) { + a = !1; + } else { + a = !0; + } + // don't compress these a = condition ? 1 : false; + a = !condition ? true : 0; + a = condition ? 1 : 0; + } + expect: { + var a; + a = !!condition; + a = !condition; + a = !!condition(); + + a = !!condition; + a = !condition; + a = !!condition(); + + a = !!condition; + a = !!condition; + + a = !condition; + a = !!condition; + a = !condition(); + + a = !condition; + a = !!condition; + a = !condition(); + + a = !condition; + a = !condition; + + a = condition ? 1 : false; + a = condition ? 0 : true; + a = condition ? 1 : 0; + } +} +cond_8b: { + options = { + conditionals: true, + evaluate : true, + booleans : true + }; + input: { + var a; + // compress these + a = condition ? true : false; + a = !condition ? true : false; + a = condition() ? true : false; + + a = condition ? !0 : !1; + a = !condition ? !null : !2; + a = condition() ? !0 : !-3.5; + + if (condition) { + a = true; + } else { + a = false; + } + + if (condition) { + a = !0; + } else { + a = !1; + } + + a = condition ? false : true; + a = !condition ? false : true; + a = condition() ? false : true; + + a = condition ? !3 : !0; + a = !condition ? !2 : !0; + a = condition() ? !1 : !0; + + if (condition) { + a = false; + } else { + a = true; + } + + if (condition) { + a = !1; + } else { + a = !0; + } + + a = condition ? 1 : false; a = !condition ? true : 0; + a = condition ? 1 : 0; + } + expect: { + var a; + a = !!condition; + a = !condition; + a = !!condition(); + a = !!condition; + a = !condition; + a = !!condition(); + + a = !!condition; + a = !!condition; + + a = !condition; + a = !!condition; + a = !condition(); + + a = !condition; + a = !!condition; + a = !condition(); + + a = !condition; + a = !condition; + + a = condition ? 1 : !1; + a = condition ? 0 : !0; a = condition ? 1 : 0; + } +} + +cond_8c: { + options = { + conditionals: true, + evaluate : false, + booleans : false + }; + input: { + var a; + // compress these + a = condition ? true : false; + a = !condition ? true : false; + a = condition() ? true : false; + a = condition ? !0 : !1; + a = !condition ? !null : !2; + a = condition() ? !0 : !-3.5; + + if (condition) { + a = true; + } else { + a = false; + } + + if (condition) { + a = !0; + } else { + a = !1; + } + + a = condition ? false : true; + a = !condition ? false : true; + a = condition() ? false : true; + + a = condition ? !3 : !0; + a = !condition ? !2 : !0; + a = condition() ? !1 : !0; + + if (condition) { + a = false; + } else { + a = true; + } + + if (condition) { + a = !1; + } else { + a = !0; + } + + a = condition ? 1 : false; + a = !condition ? true : 0; + a = condition ? 1 : 0; } expect: { var a; a = !!condition; a = !condition; a = !!condition(); + + a = !!condition; + a = !condition; + a = condition() ? !0 : !-3.5; + + a = !!condition; + a = !!condition; + + a = !condition; a = !!condition; + a = !condition(); + a = !condition; a = !!condition; a = !condition(); + a = !condition; + a = !condition; + a = condition ? 1 : false; a = condition ? 0 : true; a = condition ? 1 : 0; |