From 35a849dc48adf4a7318481f0ff540375ec0e43b2 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sun, 5 Mar 2017 14:56:14 +0800 Subject: collapse assignment with adjacent subsequent usage (#1553) - consolidate `cascade` optimisations - support ++/-- postfixes - remove redundant optimisation identified in #1460 fixes #368 --- test/compress/issue-368.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/compress/issue-368.js (limited to 'test') diff --git a/test/compress/issue-368.js b/test/compress/issue-368.js new file mode 100644 index 00000000..8c41a894 --- /dev/null +++ b/test/compress/issue-368.js @@ -0,0 +1,41 @@ +collapse: { + options = { + cascade: true, + sequences: true, + side_effects: true, + unused: true, + } + input: { + function f1() { + var a; + a = typeof b === 'function' ? b() : b; + return a !== undefined && c(); + } + function f2(b) { + var a; + b = c(); + a = typeof b === 'function' ? b() : b; + return 'stirng' == typeof a && d(); + } + function f3(c) { + var a; + a = b(a / 2); + if (a < 0) { + c++; + return c / 2; + } + } + } + expect: { + function f1() { + return void 0 !== ('function' === typeof b ? b() : b) && c(); + } + function f2(b) { + return b = c(), 'stirng' == typeof ('function' === typeof b ? b() : b) && d(); + } + function f3(c) { + var a; + if ((a = b(a / 2)) < 0) return c++ / 2; + } + } +} -- cgit v1.2.3