diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-04-16 22:31:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-17 05:31:33 +0800 |
commit | 0ce71bbec0c9f0d49ec86f8b959f12a7bf9df21d (patch) | |
tree | f02d7f7b8604eee716e86bd35b760c717212e758 /test/compress | |
parent | 46d142cbf6f14692063fe52b807955ee52704a7b (diff) | |
download | tracifyjs-0ce71bbec0c9f0d49ec86f8b959f12a7bf9df21d.tar.gz tracifyjs-0ce71bbec0c9f0d49ec86f8b959f12a7bf9df21d.zip |
enhance `join_vars` (#3783)
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/collapse_vars.js | 7 | ||||
-rw-r--r-- | test/compress/drop-unused.js | 18 | ||||
-rw-r--r-- | test/compress/hoist_props.js | 20 | ||||
-rw-r--r-- | test/compress/properties.js | 4 |
4 files changed, 33 insertions, 16 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 99e57b32..a9167262 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -804,7 +804,7 @@ collapse_vars_assignment: { function log(x) { return console.log(x), x; } function f0(c) { var a = 3 / c; - return a = a; + return a; } function f1(c) { return 1 - 3 / c; @@ -2012,6 +2012,7 @@ issue_1631_3: { join_vars: true, sequences: true, side_effects: true, + unused: true, } input: { function g() { @@ -2031,8 +2032,8 @@ issue_1631_3: { function f() { return a = 2, 4; } - var a = 0, b = 1, t = f(); - return b = a + t; + var a = 0, t = f(); + return a + t; } console.log(g()); } diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js index 99ab7b40..949106c2 100644 --- a/test/compress/drop-unused.js +++ b/test/compress/drop-unused.js @@ -2444,3 +2444,21 @@ issue_3746: { } expect_stdout: "PASS" } + +join_vars_assign: { + options = { + join_vars: true, + unused: true, + } + input: { + var y, x; + x = Object("PAS"); + y = Object("S"); + console.log(x + y); + } + expect: { + var x = Object("PAS"), y = Object("S"); + console.log(x + y); + } + expect_stdout: "PASS" +} diff --git a/test/compress/hoist_props.js b/test/compress/hoist_props.js index c647ccc1..563c7aab 100644 --- a/test/compress/hoist_props.js +++ b/test/compress/hoist_props.js @@ -767,18 +767,17 @@ issue_3071_1: { var obj = {}; obj.one = 1; obj.two = 2; - console.log(obj.one); + console.log(obj.one, obj.two); })(); } expect: { - console.log(1); + console.log(1, 2); } - expect_stdout: "1" + expect_stdout: "1 2" } issue_3071_2: { options = { - evaluate: true, hoist_props: true, inline: true, join_vars: true, @@ -793,19 +792,18 @@ issue_3071_2: { obj = {}; obj.one = 1; obj.two = 2; - console.log(obj.one); + console.log(obj.one, obj.two); var obj; })(); } expect: { - console.log(1); + console.log(1, 2); } - expect_stdout: "1" + expect_stdout: "1 2" } issue_3071_2_toplevel: { options = { - evaluate: true, hoist_props: true, inline: true, join_vars: true, @@ -821,14 +819,14 @@ issue_3071_2_toplevel: { obj = {}; obj.one = 1; obj.two = 2; - console.log(obj.one); + console.log(obj.one, obj.two); var obj; })(); } expect: { - console.log(1); + console.log(1, 2); } - expect_stdout: "1" + expect_stdout: "1 2" } issue_3071_3: { diff --git a/test/compress/properties.js b/test/compress/properties.js index 9270f438..b23c362c 100644 --- a/test/compress/properties.js +++ b/test/compress/properties.js @@ -1875,8 +1875,8 @@ join_expr: { expect: { var c = "FAIL"; (function() { - var a = 0; - switch (a = { b: 0 }, a.b) { + var a = 0, a = { b: 0 }; + switch (a.b) { case 0: c = "PASS"; } |