aboutsummaryrefslogtreecommitdiff
path: root/test/compress/properties.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-01-11 17:08:21 +0800
committerGitHub <noreply@github.com>2018-01-11 17:08:21 +0800
commitf1e1bb419ab642763c43dec95e07165f477a43be (patch)
tree6d95a87f66f386a675bf9024a8f3c69fbe591073 /test/compress/properties.js
parent6a0af85c8bf8673498e89ad7226d6e8cc80b2c15 (diff)
downloadtracifyjs-f1e1bb419ab642763c43dec95e07165f477a43be.tar.gz
tracifyjs-f1e1bb419ab642763c43dec95e07165f477a43be.zip
join object assignments (#2763)
Diffstat (limited to 'test/compress/properties.js')
-rw-r--r--test/compress/properties.js62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/compress/properties.js b/test/compress/properties.js
index b2ce5f61..d70eb85a 100644
--- a/test/compress/properties.js
+++ b/test/compress/properties.js
@@ -1100,3 +1100,65 @@ const_prop_assign_pure: {
x();
}
}
+
+join_object_assignments_1: {
+ options = {
+ evaluate: true,
+ join_vars: true,
+ }
+ input: {
+ console.log(function() {
+ var x = {
+ a: 1,
+ c: (console.log("c"), "C"),
+ };
+ x.b = 2;
+ x[3] = function() {
+ console.log(x);
+ },
+ x["a"] = /foo/,
+ x.bar = x;
+ return x;
+ }());
+ }
+ expect: {
+ console.log(function() {
+ var x = {
+ a: 1,
+ c: (console.log("c"), "C"),
+ b: 2,
+ 3: function() {
+ console.log(x);
+ },
+ a: /foo/,
+ };
+ x.bar = x;
+ return x;
+ }());
+ }
+ expect_stdout: true
+}
+
+join_object_assignments_2: {
+ options = {
+ evaluate: true,
+ hoist_props: true,
+ join_vars: true,
+ passes: 3,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var o = {
+ foo: 1,
+ };
+ o.bar = 2;
+ o.baz = 3;
+ console.log(o.foo, o.bar + o.bar, o.foo * o.bar * o.baz);
+ }
+ expect: {
+ console.log(1, 4, 6);
+ }
+ expect_stdout: "1 4 6"
+}