aboutsummaryrefslogtreecommitdiff
path: root/test/compress/ie8.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-10-03 00:02:28 +0100
committerGitHub <noreply@github.com>2020-10-03 07:02:28 +0800
commitbaf4903aa7c36bd614d3547403d6794bf77ab472 (patch)
tree3dfa234e6adb17920356e82b0abbf03563a50e40 /test/compress/ie8.js
parent35465d590eda4074fd9df0e640a8c0934e760d9b (diff)
downloadtracifyjs-baf4903aa7c36bd614d3547403d6794bf77ab472.tar.gz
tracifyjs-baf4903aa7c36bd614d3547403d6794bf77ab472.zip
fix corner cases of `catch` variable inlining (#4169)
Diffstat (limited to 'test/compress/ie8.js')
-rw-r--r--test/compress/ie8.js105
1 files changed, 105 insertions, 0 deletions
diff --git a/test/compress/ie8.js b/test/compress/ie8.js
index 6c0aa9e8..4d74d44e 100644
--- a/test/compress/ie8.js
+++ b/test/compress/ie8.js
@@ -2714,3 +2714,108 @@ issue_2737: {
}
expect_stdout: "function"
}
+
+single_use_catch_redefined: {
+ options = {
+ ie8: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var a = 1;
+ try {
+ throw 2;
+ } catch (a) {
+ function g() {
+ return a;
+ }
+ }
+ console.log(g());
+ }
+ expect: {
+ var a = 1;
+ try {
+ throw 2;
+ } catch (a) {
+ function g() {
+ return a;
+ }
+ }
+ console.log(g());
+ }
+ expect_stdout: true
+}
+
+single_use_inline_catch_redefined: {
+ options = {
+ ie8: true,
+ inline: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var a = 1;
+ try {
+ throw 2;
+ } catch (a) {
+ function g() {
+ return a;
+ }
+ }
+ console.log(g());
+ }
+ expect: {
+ var a = 1;
+ try {
+ throw 2;
+ } catch (a) {
+ function g() {
+ return a;
+ }
+ }
+ console.log(g());
+ }
+ expect_stdout: true
+}
+
+direct_inline_catch_redefined: {
+ options = {
+ ie8: true,
+ inline: true,
+ reduce_vars: true,
+ toplevel: true,
+ }
+ input: {
+ var a = 1;
+ function f() {
+ return a;
+ }
+ try {
+ throw 2;
+ } catch (a) {
+ function g() {
+ return a;
+ }
+ console.log(a, f(), g());
+ }
+ console.log(a, f(), g());
+ }
+ expect: {
+ var a = 1;
+ function f() {
+ return a;
+ }
+ try {
+ throw 2;
+ } catch (a) {
+ function g() {
+ return a;
+ }
+ console.log(a, f(), g());
+ }
+ console.log(a, a, g());
+ }
+ expect_stdout: true
+}