aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-18 08:15:44 +0000
committerGitHub <noreply@github.com>2021-02-18 16:15:44 +0800
commita7bcd4d613b73ff43300bf9053ce466735a7f81a (patch)
tree10d04fc5ed2a9a80218158ea917856150122905a /test/compress
parent6a2bda52f332b0c39f1a5f81583cc5c63f437f4c (diff)
downloadtracifyjs-a7bcd4d613b73ff43300bf9053ce466735a7f81a.tar.gz
tracifyjs-a7bcd4d613b73ff43300bf9053ce466735a7f81a.zip
fix corner case in `inline` (#4660)
fixes #4659
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/functions.js122
1 files changed, 122 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 7e2b45db..f521433d 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -5436,3 +5436,125 @@ issue_4655: {
}
expect_stdout: "PASS"
}
+
+issue_4659_1: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ }
+ input: {
+ var a = 0;
+ (function() {
+ function f() {
+ return a++;
+ }
+ (function() {
+ f && f();
+ (function() {
+ var a = console && a;
+ })();
+ })();
+ })();
+ console.log(a);
+ }
+ expect: {
+ var a = 0;
+ (function() {
+ function f() {
+ return a++;
+ }
+ (function() {
+ f && a++;
+ (function() {
+ var a = console && a;
+ })();
+ })();
+ })();
+ console.log(a);
+ }
+ expect_stdout: "1"
+}
+
+issue_4659_2: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ }
+ input: {
+ var a = 0;
+ (function() {
+ function f() {
+ return a++;
+ }
+ (function() {
+ (function() {
+ f && f();
+ })();
+ (function() {
+ var a = console && a;
+ })();
+ })();
+ })();
+ console.log(a);
+ }
+ expect: {
+ var a = 0;
+ (function() {
+ function f() {
+ return a++;
+ }
+ (function() {
+ void (f && a++);
+ (function() {
+ var a = console && a;
+ })();
+ })();
+ })();
+ console.log(a);
+ }
+ expect_stdout: "1"
+}
+
+issue_4659_3: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ var a = 0;
+ (function() {
+ function f() {
+ return a++;
+ }
+ (function() {
+ function g() {
+ while (!console);
+ }
+ g(f && f());
+ (function() {
+ var a = console && a;
+ })();
+ })();
+ })();
+ console.log(a);
+ }
+ expect: {
+ var a = 0;
+ (function() {
+ function f() {
+ return a++;
+ }
+ (function() {
+ (function() {
+ while (!console);
+ })(f && a++);
+ (function() {
+ var a = console && a;
+ })();
+ })();
+ })();
+ console.log(a);
+ }
+ expect_stdout: "1"
+}