aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorkzc <zaxxon2011@gmail.com>2016-01-27 14:18:46 -0500
committerkzc <zaxxon2011@gmail.com>2016-01-27 14:18:46 -0500
commit0a38a688f9a327d677d7f8314b5c4dcf4590b798 (patch)
treed6e38cd542fb0f2891e1e457b7587142be1040dd /test/compress
parentf4c2ea37bf9231b6f76804e74ee157be916280de (diff)
downloadtracifyjs-0a38a688f9a327d677d7f8314b5c4dcf4590b798.tar.gz
tracifyjs-0a38a688f9a327d677d7f8314b5c4dcf4590b798.zip
fix bug in collapse_vars for right side of "||" and "&&"
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/collapse_vars.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index e0235972..f67b3f47 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -1045,3 +1045,45 @@ collapse_vars_arguments: {
}
}
+collapse_vars_short_circuit: {
+ options = {
+ collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
+ comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
+ keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true
+ }
+ input: {
+ function f0(x) { var a = foo(), b = bar(); return b || x; }
+ function f1(x) { var a = foo(), b = bar(); return b && x; }
+ function f2(x) { var a = foo(), b = bar(); return x && a && b; }
+ function f3(x) { var a = foo(), b = bar(); return a && x; }
+ function f4(x) { var a = foo(), b = bar(); return a && x && b; }
+ function f5(x) { var a = foo(), b = bar(); return x || a || b; }
+ function f6(x) { var a = foo(), b = bar(); return a || x || b; }
+ function f7(x) { var a = foo(), b = bar(); return a && b && x; }
+ function f8(x,y) { var a = foo(), b = bar(); return (x || a) && (y || b); }
+ function f9(x,y) { var a = foo(), b = bar(); return (x && a) || (y && b); }
+ function f10(x,y) { var a = foo(), b = bar(); return (x - a) || (y - b); }
+ function f11(x,y) { var a = foo(), b = bar(); return (x - b) || (y - a); }
+ function f12(x,y) { var a = foo(), b = bar(); return (x - y) || (b - a); }
+ function f13(x,y) { var a = foo(), b = bar(); return (a - b) || (x - y); }
+ function f14(x,y) { var a = foo(), b = bar(); return (b - a) || (x - y); }
+ }
+ expect: {
+ function f0(x) { foo(); return bar() || x; }
+ function f1(x) { foo(); return bar() && x; }
+ function f2(x) { var a = foo(), b = bar(); return x && a && b; }
+ function f3(x) { var a = foo(); bar(); return a && x; }
+ function f4(x) { var a = foo(), b = bar(); return a && x && b; }
+ function f5(x) { var a = foo(), b = bar(); return x || a || b; }
+ function f6(x) { var a = foo(), b = bar(); return a || x || b; }
+ function f7(x) { var a = foo(), b = bar(); return a && b && x; }
+ function f8(x,y) { var a = foo(), b = bar(); return (x || a) && (y || b); }
+ function f9(x,y) { var a = foo(), b = bar(); return (x && a) || (y && b); }
+ function f10(x,y) { var a = foo(), b = bar(); return (x - a) || (y - b); }
+ function f11(x,y) { var a = foo(); return (x - bar()) || (y - a); }
+ function f12(x,y) { var a = foo(), b = bar(); return (x - y) || (b - a); }
+ function f13(x,y) { return (foo() - bar()) || (x - y); }
+ function f14(x,y) { var a = foo(); return (bar() - a) || (x - y); }
+ }
+}
+