aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-11-06 16:10:57 +0800
committerGitHub <noreply@github.com>2017-11-06 16:10:57 +0800
commit2cfb5aa7dadd744bf7fbe16756696fc595f134a2 (patch)
tree047a685ececbd705d3fd69dd630723fe2c706b72 /test/compress
parent6c4510187066555c77003f03fd26e2cf5ff47491 (diff)
downloadtracifyjs-2cfb5aa7dadd744bf7fbe16756696fc595f134a2.tar.gz
tracifyjs-2cfb5aa7dadd744bf7fbe16756696fc595f134a2.zip
account for `eval` & `with` in `reduce_vars` (#2441)
fixes #2440
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/reduce_vars.js112
1 files changed, 112 insertions, 0 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 1acd902b..25f95ff8 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -3542,3 +3542,115 @@ issue_2423_6: {
"2",
]
}
+
+issue_2440_eval_1: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function foo() {
+ return bar();
+ }
+ baz = {
+ quux: foo
+ };
+ exec = function() {
+ return eval("foo()");
+ };
+ }
+ expect: {
+ function foo() {
+ return bar();
+ }
+ baz = {
+ quux: foo
+ };
+ exec = function() {
+ return eval("foo()");
+ };
+ }
+}
+
+issue_2440_eval_2: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ baz = {
+ quux: foo
+ };
+ exec = function() {
+ return eval("foo()");
+ };
+ function foo() {
+ return bar();
+ }
+ }
+ expect: {
+ baz = {
+ quux: foo
+ };
+ exec = function() {
+ return eval("foo()");
+ };
+ function foo() {
+ return bar();
+ }
+ }
+}
+
+issue_2440_with_1: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function foo() {
+ return bar();
+ }
+ baz = {
+ quux: foo
+ };
+ with (o) whatever();
+ }
+ expect: {
+ function foo() {
+ return bar();
+ }
+ baz = {
+ quux: foo
+ };
+ with (o) whatever();
+ }
+}
+
+issue_2440_with_2: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ baz = {
+ quux: foo
+ };
+ with (o) whatever();
+ function foo() {
+ return bar();
+ }
+ }
+ expect: {
+ baz = {
+ quux: foo
+ };
+ with (o) whatever();
+ function foo() {
+ return bar();
+ }
+ }
+}