aboutsummaryrefslogtreecommitdiff
path: root/test/compress/reduce_vars.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-04-30 22:52:36 +0800
committerGitHub <noreply@github.com>2017-04-30 22:52:36 +0800
commit2cb55b2ad0119852bc8714401992724d4fdb224d (patch)
treebbfa6cafc5c87c5ec7dfc17a6b11e489bfc183a3 /test/compress/reduce_vars.js
parentbbb5f2a89c9b68b35aec96ccc48a9d0ef250780a (diff)
downloadtracifyjs-2cb55b2ad0119852bc8714401992724d4fdb224d.tar.gz
tracifyjs-2cb55b2ad0119852bc8714401992724d4fdb224d.zip
enforce `toplevel` on other compress options (#1855)
Respect "funcs" and "vars" properly. fixes #1850
Diffstat (limited to 'test/compress/reduce_vars.js')
-rw-r--r--test/compress/reduce_vars.js90
1 files changed, 90 insertions, 0 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 57e23891..f7bdcb36 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -2327,3 +2327,93 @@ iife_assign: {
}
expect_stdout: "1"
}
+
+issue_1850_1: {
+ options = {
+ reduce_vars: true,
+ toplevel: false,
+ unused: true,
+ }
+ input: {
+ function f() {
+ console.log(a, a, a);
+ }
+ var a = 1;
+ f();
+ }
+ expect: {
+ function f() {
+ console.log(a, a, a);
+ }
+ var a = 1;
+ f();
+ }
+ expect_stdout: true
+}
+
+issue_1850_2: {
+ options = {
+ reduce_vars: true,
+ toplevel: "funcs",
+ unused: true,
+ }
+ input: {
+ function f() {
+ console.log(a, a, a);
+ }
+ var a = 1;
+ f();
+ }
+ expect: {
+ var a = 1;
+ (function() {
+ console.log(a, a, a);
+ })();
+ }
+ expect_stdout: true
+}
+
+issue_1850_3: {
+ options = {
+ reduce_vars: true,
+ toplevel: "vars",
+ unused: true,
+ }
+ input: {
+ function f() {
+ console.log(a, a, a);
+ }
+ var a = 1;
+ f();
+ }
+ expect: {
+ function f() {
+ console.log(a, a, a);
+ }
+ var a = 1;
+ f();
+ }
+ expect_stdout: true
+}
+
+issue_1850_4: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function f() {
+ console.log(a, a, a);
+ }
+ var a = 1;
+ f();
+ }
+ expect: {
+ var a = 1;
+ (function() {
+ console.log(a, a, a);
+ })();
+ }
+ expect_stdout: true
+}