aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorRichard van Velzen <rvanvelzen1@gmail.com>2015-12-26 14:28:33 +0100
committerRichard van Velzen <rvanvelzen1@gmail.com>2015-12-26 14:28:33 +0100
commit60c4030a4d6758e98bb534cdcfe26bebda9ddd2b (patch)
tree97268bd04343593fefbfdeb80bea505819b0b37a /test/compress
parentac810dc07a6cfb2bd32cf5c8eb2f496bfe0edf3d (diff)
parent774bda13cdf8de39de7f236ed95ae3da4fc7d822 (diff)
downloadtracifyjs-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/compress')
-rw-r--r--test/compress/conditionals.js204
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;