aboutsummaryrefslogtreecommitdiff
path: root/test/compress/hoist_props.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-04-11 02:48:15 +0800
committerGitHub <noreply@github.com>2018-04-11 02:48:15 +0800
commit4dd7d0e39baacdd3bf7dc87fc547df66e327f206 (patch)
tree1854302f42b89b6b71b3e69a01470d1369462e61 /test/compress/hoist_props.js
parent90199d0a961bb75cc5bf6d8ade8bf5b0098cb341 (diff)
downloadtracifyjs-4dd7d0e39baacdd3bf7dc87fc547df66e327f206.tar.gz
tracifyjs-4dd7d0e39baacdd3bf7dc87fc547df66e327f206.zip
extend `hoist_props` (#3073)
- handle `AST_Assign` the same way as `AST_VarDef` - inject `AST_Var` as succeeding statement fixes #3071
Diffstat (limited to 'test/compress/hoist_props.js')
-rw-r--r--test/compress/hoist_props.js82
1 files changed, 82 insertions, 0 deletions
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"
+}