diff options
author | Tal Ater <tal@talater.com> | 2014-09-13 18:59:19 +0300 |
---|---|---|
committer | Richard van Velzen <rvanvelzen1@gmail.com> | 2015-01-13 18:27:21 +0100 |
commit | a1a4c2ada70760851c63a7e3ff51ee7f786d3e8f (patch) | |
tree | 11e939a2b41bcfaa31b4abc162c23ccbbc930386 /test/compress/conditionals.js | |
parent | 189dbf02b6f0c1abc0c10f092d72f7ffcc58a48f (diff) | |
download | tracifyjs-a1a4c2ada70760851c63a7e3ff51ee7f786d3e8f.tar.gz tracifyjs-a1a4c2ada70760851c63a7e3ff51ee7f786d3e8f.zip |
Optimize conditionals where the consequent and alternative are both booleans and not equivalent
Diffstat (limited to 'test/compress/conditionals.js')
-rw-r--r-- | test/compress/conditionals.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js index 2212f85f..9af1630a 100644 --- a/test/compress/conditionals.js +++ b/test/compress/conditionals.js @@ -312,3 +312,57 @@ cond_7_1: { x = (y, 2); } } + +cond_8: { + options = { + conditionals: true, + evaluate : true + }; + input: { + // compress these + a = condition ? true : false; + + a = !condition ? true : false; + + a = condition() ? true : false; + + if (condition) { + a = true; + } else { + a = false; + } + + a = condition ? false : true; + + a = !condition ? false : true; + + a = condition() ? false : true; + + if (condition) { + a = false; + } else { + a = true; + } + + // don't compress these + a = condition ? 1 : false; + + a = !condition ? true : 0; + + a = condition ? 1 : 0; + + } + expect: { + 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; + } +}
\ No newline at end of file |