aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-02-13 01:41:22 +0800
committerGitHub <noreply@github.com>2018-02-13 01:41:22 +0800
commit0c4f315c026e607d00dd74ad7417344a937bf6dd (patch)
tree83b5324ae53679633bda9b0f50abb62e951f8014 /test
parent0809699bdc7b1c249c7bbe02924a4a861aff8bea (diff)
downloadtracifyjs-0c4f315c026e607d00dd74ad7417344a937bf6dd.tar.gz
tracifyjs-0c4f315c026e607d00dd74ad7417344a937bf6dd.zip
fix corner case in `collapse_vars` (#2909)
fixes #2908
Diffstat (limited to 'test')
-rw-r--r--test/compress/collapse_vars.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index ed1d8d97..2c7bbdeb 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -4517,3 +4517,32 @@ issue_2891_2: {
}
expect_stdout: true
}
+
+issue_2908: {
+ options = {
+ collapse_vars: true,
+ }
+ input: {
+ var a = 0, b = 0;
+ function f(c) {
+ if (1 == c) return;
+ a++;
+ if (2 == c) b = a;
+ }
+ f(0);
+ f(2);
+ console.log(b);
+ }
+ expect: {
+ var a = 0, b = 0;
+ function f(c) {
+ if (1 == c) return;
+ a++;
+ if (2 == c) b = a;
+ }
+ f(0);
+ f(2);
+ console.log(b);
+ }
+ expect_stdout: "2"
+}