aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-07-08 09:31:04 +0100
committerGitHub <noreply@github.com>2021-07-08 16:31:04 +0800
commitea7829daf55f8829cc48466379cc6f6cf3394dbd (patch)
treee9a897a9b81cdd8f94c2b08f602043d1e6dca444 /test
parent6577d641ac82419d462f11fee73a7b067e793003 (diff)
downloadtracifyjs-ea7829daf55f8829cc48466379cc6f6cf3394dbd.tar.gz
tracifyjs-ea7829daf55f8829cc48466379cc6f6cf3394dbd.zip
fix corner case in `reduce_vars` (#5062)
fixes #5061
Diffstat (limited to 'test')
-rw-r--r--test/compress/functions.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 6d41a265..7c6ebe03 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -6346,3 +6346,55 @@ issue_5046: {
}
expect_stdout: "PASS"
}
+
+issue_5061_1: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ toplevel: true,
+ }
+ input: {
+ var f, a = 1;
+ (f = function() {
+ console.log(a ? "foo" : "bar");
+ })();
+ f(a = 0);
+ }
+ expect: {
+ var f, a = 1;
+ (f = function() {
+ console.log(a ? "foo" : "bar");
+ })();
+ f(a = 0);
+ }
+ expect_stdout: [
+ "foo",
+ "bar",
+ ]
+}
+
+issue_5061_2: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var f, a = 1;
+ (f = function() {
+ console.log(a ? "foo" : "bar");
+ })();
+ f(a = 0);
+ }
+ expect: {
+ var f, a = 1;
+ (f = function() {
+ console.log(a ? "foo" : "bar");
+ })();
+ f(a = 0);
+ }
+ expect_stdout: [
+ "foo",
+ "bar",
+ ]
+}