diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-11-24 14:07:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-24 14:07:39 +0800 |
commit | 3b28b915ebad2d9452c0e8649033ab4813eabca4 (patch) | |
tree | 408bb79e5b762fb0df1eb793c37153853223e7d7 /test/compress | |
parent | eb001dc1d9efbb81841410c06d854091473061ee (diff) | |
download | tracifyjs-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.js | 133 |
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 +} |