From 4dd7d0e39baacdd3bf7dc87fc547df66e327f206 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Wed, 11 Apr 2018 02:48:15 +0800 Subject: extend `hoist_props` (#3073) - handle `AST_Assign` the same way as `AST_VarDef` - inject `AST_Var` as succeeding statement fixes #3071 --- test/compress/hoist_props.js | 82 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'test/compress/hoist_props.js') diff --git a/test/compress/hoist_props.js b/test/compress/hoist_props.js index b16f7425..0e399167 100644 --- a/test/compress/hoist_props.js +++ b/test/compress/hoist_props.js @@ -742,3 +742,85 @@ issue_3046: { } expect_stdout: "1" } + +issue_3071_1: { + options = { + evaluate: true, + inline: true, + join_vars: true, + hoist_props: true, + passes: 3, + reduce_vars: true, + sequences: true, + side_effects: true, + toplevel: true, + unused: true, + } + input: { + (function() { + var obj = {}; + obj.one = 1; + obj.two = 2; + console.log(obj.one); + })(); + } + expect: { + console.log(1); + } + expect_stdout: "1" +} + +issue_3071_2: { + options = { + evaluate: true, + inline: true, + join_vars: true, + hoist_props: true, + passes: 3, + reduce_vars: true, + sequences: true, + side_effects: true, + unused: true, + } + input: { + (function() { + obj = {}; + obj.one = 1; + obj.two = 2; + console.log(obj.one); + var obj; + })(); + } + expect: { + console.log(1); + } + expect_stdout: "1" +} + +issue_3071_2_toplevel: { + options = { + evaluate: true, + inline: true, + join_vars: true, + hoist_props: true, + passes: 3, + reduce_vars: true, + sequences: true, + side_effects: true, + toplevel: true, + unused: true, + } + input: { + (function() { + obj = {}; + obj.one = 1; + obj.two = 2; + console.log(obj.one); + var obj; + })(); + } + expect: { + console.log(1); + } + expect_stdout: "1" +} -- cgit v1.2.3