aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-10-30 02:04:23 +0000
committerGitHub <noreply@github.com>2020-10-30 10:04:23 +0800
commit5d12abc41b9cb4890b937599fa588a53fdb2996b (patch)
tree31329fc174a3420a8e0d290b1fa2592614831552 /test
parent79e5c3f5645b339a98d73cb78e356f61fa618929 (diff)
downloadtracifyjs-5d12abc41b9cb4890b937599fa588a53fdb2996b.tar.gz
tracifyjs-5d12abc41b9cb4890b937599fa588a53fdb2996b.zip
fix corner cases in `collapse_vars` (#4249)
fixes #4248
Diffstat (limited to 'test')
-rw-r--r--test/compress/collapse_vars.js25
-rw-r--r--test/compress/const.js31
-rw-r--r--test/compress/let.js34
3 files changed, 90 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index dea01b60..edf4795a 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -8577,3 +8577,28 @@ issue_4242: {
}
expect_stdout: "undefined"
}
+
+issue_4248: {
+ options = {
+ collapse_vars: true,
+ }
+ input: {
+ var a = 0;
+ try {
+ a = 1;
+ b[1];
+ } catch (e) {
+ console.log(a);
+ }
+ }
+ expect: {
+ var a = 0;
+ try {
+ a = 1;
+ b[1];
+ } catch (e) {
+ console.log(a);
+ }
+ }
+ expect_stdout: "1"
+}
diff --git a/test/compress/const.js b/test/compress/const.js
index 2f88975e..896e8c38 100644
--- a/test/compress/const.js
+++ b/test/compress/const.js
@@ -1104,3 +1104,34 @@ issue_4245: {
}
expect_stdout: true
}
+
+issue_4248: {
+ options = {
+ collapse_vars: true,
+ }
+ input: {
+ var a = "FAIL";
+ try {
+ (function() {
+ a = "PASS";
+ b[a];
+ const b = 0;
+ })();
+ } catch (e) {
+ console.log(a);
+ }
+ }
+ expect: {
+ var a = "FAIL";
+ try {
+ (function() {
+ a = "PASS";
+ b[a];
+ const b = 0;
+ })();
+ } catch (e) {
+ console.log(a);
+ }
+ }
+ expect_stdout: "PASS"
+}
diff --git a/test/compress/let.js b/test/compress/let.js
index deb48120..9a6fc944 100644
--- a/test/compress/let.js
+++ b/test/compress/let.js
@@ -916,3 +916,37 @@ issue_4245: {
expect_stdout: ReferenceError("a is not defined")
node_version: ">=4"
}
+
+issue_4248: {
+ options = {
+ collapse_vars: true,
+ }
+ input: {
+ var a = "FAIL";
+ try {
+ (function() {
+ "use strict";
+ a = "PASS";
+ b[a];
+ let b;
+ })();
+ } catch (e) {
+ console.log(a);
+ }
+ }
+ expect: {
+ var a = "FAIL";
+ try {
+ (function() {
+ "use strict";
+ a = "PASS";
+ b[a];
+ let b;
+ })();
+ } catch (e) {
+ console.log(a);
+ }
+ }
+ expect_stdout: "PASS"
+ node_version: ">=4"
+}