aboutsummaryrefslogtreecommitdiff
path: root/test/compress/collapse_vars.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/compress/collapse_vars.js')
-rw-r--r--test/compress/collapse_vars.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index 39fee597..934a5c73 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -1103,3 +1103,53 @@ collapse_vars_short_circuit: {
}
}
+collapse_vars_short_circuited_conditions: {
+ options = {
+ collapse_vars: true,
+ sequences: false,
+ dead_code: true,
+ conditionals: false,
+ comparisons: false,
+ evaluate: true,
+ booleans: true,
+ loops: true,
+ unused: true,
+ hoist_funs: true,
+ keep_fargs: true,
+ if_return: false,
+ join_vars: true,
+ cascade: true,
+ side_effects: true,
+ }
+ input: {
+ function c1(x) { var a = foo(), b = bar(), c = baz(); return a ? b : c; }
+ function c2(x) { var a = foo(), b = bar(), c = baz(); return a ? c : b; }
+ function c3(x) { var a = foo(), b = bar(), c = baz(); return b ? a : c; }
+ function c4(x) { var a = foo(), b = bar(), c = baz(); return b ? c : a; }
+ function c5(x) { var a = foo(), b = bar(), c = baz(); return c ? a : b; }
+ function c6(x) { var a = foo(), b = bar(), c = baz(); return c ? b : a; }
+
+ function i1(x) { var a = foo(), b = bar(), c = baz(); if (a) return b; else return c; }
+ function i2(x) { var a = foo(), b = bar(), c = baz(); if (a) return c; else return b; }
+ function i3(x) { var a = foo(), b = bar(), c = baz(); if (b) return a; else return c; }
+ function i4(x) { var a = foo(), b = bar(), c = baz(); if (b) return c; else return a; }
+ function i5(x) { var a = foo(), b = bar(), c = baz(); if (c) return a; else return b; }
+ function i6(x) { var a = foo(), b = bar(), c = baz(); if (c) return b; else return a; }
+ }
+ expect: {
+ function c1(x) { var a = foo(), b = bar(), c = baz(); return a ? b : c; }
+ function c2(x) { var a = foo(), b = bar(), c = baz(); return a ? c : b; }
+ function c3(x) { var a = foo(), b = bar(), c = baz(); return b ? a : c; }
+ function c4(x) { var a = foo(), b = bar(), c = baz(); return b ? c : a; }
+ function c5(x) { var a = foo(), b = bar(); return baz() ? a : b; }
+ function c6(x) { var a = foo(), b = bar(); return baz() ? b : a; }
+
+ function i1(x) { var a = foo(), b = bar(), c = baz(); if (a) return b; else return c; }
+ function i2(x) { var a = foo(), b = bar(), c = baz(); if (a) return c; else return b; }
+ function i3(x) { var a = foo(), b = bar(), c = baz(); if (b) return a; else return c; }
+ function i4(x) { var a = foo(), b = bar(), c = baz(); if (b) return c; else return a; }
+ function i5(x) { var a = foo(), b = bar(); if (baz()) return a; else return b; }
+ function i6(x) { var a = foo(), b = bar(); if (baz()) return b; else return a; }
+ }
+}
+