aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorkzc <zaxxon2011@gmail.com>2016-06-21 14:52:13 -0400
committerkzc <zaxxon2011@gmail.com>2016-06-21 14:52:13 -0400
commitace8aaa0f4ad6ecae77e760473353f07b384880e (patch)
tree3540de9720167a66b26dfa90fb0bf0788eeb162c /test/compress
parent0c003c92a85bd845dec8a10ee567c46b696c1403 (diff)
downloadtracifyjs-ace8aaa0f4ad6ecae77e760473353f07b384880e.tar.gz
tracifyjs-ace8aaa0f4ad6ecae77e760473353f07b384880e.zip
Fix conditional expressions of form (x ? -1 : -1)
Fixes #1154, #1153
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/conditionals.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js
index f5eeb6f2..35cb26f7 100644
--- a/test/compress/conditionals.js
+++ b/test/compress/conditionals.js
@@ -868,3 +868,41 @@ trivial_boolean_ternary_expressions : {
f(!(x >= y));
}
}
+
+issue_1154: {
+ options = {
+ conditionals: true,
+ evaluate : true,
+ booleans : true,
+ };
+ input: {
+ function f1(x) { return x ? -1 : -1; }
+ function f2(x) { return x ? +2 : +2; }
+ function f3(x) { return x ? ~3 : ~3; }
+ function f4(x) { return x ? !4 : !4; }
+ function f5(x) { return x ? void 5 : void 5; }
+ function f6(x) { return x ? typeof 6 : typeof 6; }
+
+ function g1() { return g() ? -1 : -1; }
+ function g2() { return g() ? +2 : +2; }
+ function g3() { return g() ? ~3 : ~3; }
+ function g4() { return g() ? !4 : !4; }
+ function g5() { return g() ? void 5 : void 5; }
+ function g6() { return g() ? typeof 6 : typeof 6; }
+ }
+ expect: {
+ function f1(x) { return -1; }
+ function f2(x) { return 2; }
+ function f3(x) { return -4; }
+ function f4(x) { return !1; }
+ function f5(x) { return; }
+ function f6(x) { return "number"; }
+
+ function g1() { return g(), -1; }
+ function g2() { return g(), 2; }
+ function g3() { return g(), -4; }
+ function g4() { return g(), !1; }
+ function g5() { return g(), void 0; }
+ function g6() { return g(), "number"; }
+ }
+}