diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-01-14 17:11:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-14 17:11:31 +0800 |
commit | 62a66dfff4fdd05b760d3e45cab4a2815a23d9ff (patch) | |
tree | 22bd94fdcfd8bd44a57c03555448b0d6f6a059d7 /test/compress/properties.js | |
parent | 2cab34834191ea4fb48059e5725b631ff2752aa4 (diff) | |
download | tracifyjs-62a66dfff4fdd05b760d3e45cab4a2815a23d9ff.tar.gz tracifyjs-62a66dfff4fdd05b760d3e45cab4a2815a23d9ff.zip |
fix & extend `join_vars` for object assigments (#2781)
Diffstat (limited to 'test/compress/properties.js')
-rw-r--r-- | test/compress/properties.js | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/test/compress/properties.js b/test/compress/properties.js index 6b368e64..7df53d39 100644 --- a/test/compress/properties.js +++ b/test/compress/properties.js @@ -1188,3 +1188,113 @@ join_object_assignments_3: { } expect_stdout: "PASS" } + +join_object_assignments_4: { + options = { + join_vars: true, + } + input: { + console.log(function() { + var o = { + p: 3 + }; + return o.q = "foo"; + }()); + } + expect: { + console.log(function() { + var o = { + p: 3, + q: "foo" + }; + return o.q; + }()); + } + expect_stdout: "foo" +} + +join_object_assignments_5: { + options = { + join_vars: true, + } + input: { + console.log(function() { + var o = { + p: 3 + }; + return o.q = /foo/, + o.r = "bar"; + }()); + } + expect: { + console.log(function() { + var o = { + p: 3, + q: /foo/, + r: "bar" + }; + return o.r; + }()); + } + expect_stdout: "bar" +} + +join_object_assignments_6: { + options = { + join_vars: true, + } + input: { + console.log(function() { + var o = { + p: 3 + }; + return o.q = "foo", + o.p += "", + console.log(o.q), + o.p; + }()); + } + expect: { + console.log(function() { + var o = { + p: 3, + q: "foo" + }; + return o.p += "", + console.log(o.q), + o.p; + }()); + } + expect_stdout: [ + "foo", + "3", + ] +} + +join_object_assignments_7: { + options = { + join_vars: true, + } + input: { + console.log(function() { + var o = { + p: 3 + }; + for (o.q = "foo"; console.log(o.q);); + return o.p; + }()); + } + expect: { + console.log(function() { + for (var o = { + p: 3, + q: "foo" + }; console.log(o.q);); + return o.p; + }()); + } + expect_stdout: [ + "foo", + "3", + ] +} |