aboutsummaryrefslogtreecommitdiff
path: root/test/compress/conditionals.js
diff options
context:
space:
mode:
authorkzc <zaxxon2011@gmail.com>2016-02-21 18:47:21 -0500
committerRichard van Velzen <rvanvelzen@experty.com>2016-02-22 17:59:36 +0100
commit11b0efdf84dcdae71ac66453f8bf644052a32cc8 (patch)
treee136446f5b56170f9868180bc73bac510ffd9a04 /test/compress/conditionals.js
parent5486b68850f8da3fbcdef228a88ff494c33bac4a (diff)
downloadtracifyjs-11b0efdf84dcdae71ac66453f8bf644052a32cc8.tar.gz
tracifyjs-11b0efdf84dcdae71ac66453f8bf644052a32cc8.zip
boolean_expression ? true : false --> boolean_expression
Diffstat (limited to 'test/compress/conditionals.js')
-rw-r--r--test/compress/conditionals.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js
index 65cfea64..db0d8000 100644
--- a/test/compress/conditionals.js
+++ b/test/compress/conditionals.js
@@ -738,3 +738,77 @@ conditional_or: {
a = condition + 3 || null;
}
}
+
+trivial_boolean_ternary_expressions : {
+ options = {
+ conditionals: true,
+ evaluate : true,
+ booleans : true
+ };
+ input: {
+ f('foo' in m ? true : false);
+ f('foo' in m ? false : true);
+
+ f(g ? true : false);
+ f(foo() ? true : false);
+ f("bar" ? true : false);
+ f(5 ? true : false);
+ f(5.7 ? true : false);
+ f(x - y ? true : false);
+
+ f(x == y ? true : false);
+ f(x === y ? !0 : !1);
+ f(x < y ? !0 : false);
+ f(x <= y ? true : false);
+ f(x > y ? true : !1);
+ f(x >= y ? !0 : !1);
+
+ f(g ? false : true);
+ f(foo() ? false : true);
+ f("bar" ? false : true);
+ f(5 ? false : true);
+ f(5.7 ? false : true);
+ f(x - y ? false : true);
+
+ f(x == y ? !1 : !0);
+ f(x === y ? false : true);
+
+ f(x < y ? false : true);
+ f(x <= y ? false : !0);
+ f(x > y ? !1 : true);
+ f(x >= y ? !1 : !0);
+ }
+ expect: {
+ f('foo' in m);
+ f(!('foo' in m));
+
+ f(!!g);
+ f(!!foo());
+ f(!0);
+ f(!0);
+ f(!0);
+ f(!!(x - y));
+
+ f(x == y);
+ f(x === y);
+ f(x < y);
+ f(x <= y);
+ f(x > y);
+ f(x >= y);
+
+ f(!g);
+ f(!foo());
+ f(!1);
+ f(!1);
+ f(!1);
+ f(!(x - y));
+
+ f(x != y);
+ f(x !== y);
+
+ f(!(x < y));
+ f(!(x <= y));
+ f(!(x > y));
+ f(!(x >= y));
+ }
+}