diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-03-20 23:31:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-20 23:31:21 +0800 |
commit | 65648d84a5f1df20e6a839cde9fc9dcabc7e13ea (patch) | |
tree | 933dd149220d9085754322c77f74e317200c499c /test/compress/collapse_vars.js | |
parent | fd788590f6aa8ebb99612116b293f99caedd36bb (diff) | |
download | tracifyjs-65648d84a5f1df20e6a839cde9fc9dcabc7e13ea.tar.gz tracifyjs-65648d84a5f1df20e6a839cde9fc9dcabc7e13ea.zip |
enhance `collapse_vars` (#3351)
Diffstat (limited to 'test/compress/collapse_vars.js')
-rw-r--r-- | test/compress/collapse_vars.js | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index a858e000..22a8d7ae 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -3895,11 +3895,11 @@ issue_2436_10: { o = { b: 3 }; return n; } - console.log((c = o, [ - c.a, + console.log([ + (c = o).a, f(c.b), c.b, - ]).join(" ")); + ].join(" ")); var c; } expect_stdout: "1 2 2" @@ -6121,3 +6121,39 @@ issue_3327: { } expect_stdout: "PASS 42" } + +assign_left: { + options = { + collapse_vars: true, + } + input: { + console.log(function(a, b) { + (b = a, b.p).q = "PASS"; + return a.p.q; + }({p: {}})); + } + expect: { + console.log(function(a, b) { + (b = a).p.q = "PASS"; + return a.p.q; + }({p: {}})); + } + expect_stdout: "PASS" +} + +sub_property: { + options = { + collapse_vars: true, + } + input: { + console.log(function(a, b) { + return a[(b = a, b.length - 1)]; + }([ "FAIL", "PASS" ])); + } + expect: { + console.log(function(a, b) { + return a[(b = a).length - 1]; + }([ "FAIL", "PASS" ])); + } + expect_stdout: "PASS" +} |