aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-11-24 14:07:39 +0800
committerGitHub <noreply@github.com>2017-11-24 14:07:39 +0800
commit3b28b915ebad2d9452c0e8649033ab4813eabca4 (patch)
tree408bb79e5b762fb0df1eb793c37153853223e7d7 /test/compress
parenteb001dc1d9efbb81841410c06d854091473061ee (diff)
downloadtracifyjs-3b28b915ebad2d9452c0e8649033ab4813eabca4.tar.gz
tracifyjs-3b28b915ebad2d9452c0e8649033ab4813eabca4.zip
extend escape analysis on constant expression properties (#2509)
fixes #2508
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/hoist_props.js133
1 files changed, 133 insertions, 0 deletions
diff --git a/test/compress/hoist_props.js b/test/compress/hoist_props.js
index 40d36ace..b2dd0270 100644
--- a/test/compress/hoist_props.js
+++ b/test/compress/hoist_props.js
@@ -500,3 +500,136 @@ issue_2473_4: {
}
expect_stdout: "1 2"
}
+
+issue_2508_1: {
+ options = {
+ collapse_vars: true,
+ hoist_props: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var o = {
+ a: [ 1 ],
+ f: function(x) {
+ console.log(x);
+ }
+ };
+ o.f(o.a);
+ }
+ expect: {
+ (function(x) {
+ console.log(x);
+ })([ 1 ]);
+ }
+ expect_stdout: true
+}
+
+issue_2508_2: {
+ options = {
+ collapse_vars: true,
+ hoist_props: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var o = {
+ a: { b: 2 },
+ f: function(x) {
+ console.log(x);
+ }
+ };
+ o.f(o.a);
+ }
+ expect: {
+ (function(x) {
+ console.log(x);
+ })({ b: 2 });
+ }
+ expect_stdout: true
+}
+
+issue_2508_3: {
+ options = {
+ collapse_vars: true,
+ hoist_props: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var o = {
+ a: [ o ],
+ f: function(x) {
+ console.log(x);
+ }
+ };
+ o.f(o.a);
+ }
+ expect: {
+ var o = {
+ a: [ o ],
+ f: function(x) {
+ console.log(x);
+ }
+ };
+ o.f(o.a);
+ }
+ expect_stdout: true
+}
+
+issue_2508_4: {
+ options = {
+ collapse_vars: true,
+ hoist_props: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var o = {
+ a: { b: o },
+ f: function(x) {
+ console.log(x);
+ }
+ };
+ o.f(o.a);
+ }
+ expect: {
+ var o = {
+ a: { b: o },
+ f: function(x) {
+ console.log(x);
+ }
+ };
+ o.f(o.a);
+ }
+ expect_stdout: true
+}
+
+issue_2508_5: {
+ options = {
+ collapse_vars: true,
+ hoist_props: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var o = {
+ f: function(x) {
+ console.log(x);
+ }
+ };
+ o.f(o.f);
+ }
+ expect: {
+ var o_f = function(x) {
+ console.log(x);
+ };
+ o_f(o_f);
+ }
+ expect_stdout: true
+}