aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-05 14:56:14 +0800
committerGitHub <noreply@github.com>2017-03-05 14:56:14 +0800
commit35a849dc48adf4a7318481f0ff540375ec0e43b2 (patch)
tree6a803e1f94d3963146ef21e034135c22f9de49bd /test/compress
parentb70591be1a603d3c1728e6563691c3a192023d3f (diff)
downloadtracifyjs-35a849dc48adf4a7318481f0ff540375ec0e43b2.tar.gz
tracifyjs-35a849dc48adf4a7318481f0ff540375ec0e43b2.zip
collapse assignment with adjacent subsequent usage (#1553)
- consolidate `cascade` optimisations - support ++/-- postfixes - remove redundant optimisation identified in #1460 fixes #368
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/issue-368.js41
1 files changed, 41 insertions, 0 deletions
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;
+ }
+ }
+}