aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-04-22 11:22:45 +0100
committerGitHub <noreply@github.com>2020-04-22 18:22:45 +0800
commit01b13d797cdeabecad25c33e039fd3ec848b71d0 (patch)
treec6c1cab93354cce72d1a2a66a8abe6cf562b8558 /test/compress
parent306e8e98738ceaf90c8cb7dcb42ddb66de8bc0e6 (diff)
downloadtracifyjs-01b13d797cdeabecad25c33e039fd3ec848b71d0.tar.gz
tracifyjs-01b13d797cdeabecad25c33e039fd3ec848b71d0.zip
enhance `dead_code` (#3811)
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/dead-code.js65
1 files changed, 61 insertions, 4 deletions
diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js
index 344e1ff9..5de9ad37 100644
--- a/test/compress/dead-code.js
+++ b/test/compress/dead-code.js
@@ -97,6 +97,66 @@ dead_code_constant_boolean_should_warn_more: {
node_version: "<=4"
}
+trim_try: {
+ options = {
+ dead_code: true,
+ }
+ input: {
+ try {
+ var a;
+ } catch (e) {
+ console.log("FAIL");
+ } finally {
+ console.log(a);
+ }
+ }
+ expect: {
+ var a;
+ console.log(a);
+ }
+ expect_stdout: "undefined"
+}
+
+trim_finally_1: {
+ options = {
+ dead_code: true,
+ }
+ input: {
+ try {
+ console.log("PASS");
+ } finally {
+ var a;
+ }
+ }
+ expect: {
+ console.log("PASS");
+ var a;
+ }
+ expect_stdout: "PASS"
+}
+
+trim_finally_2: {
+ options = {
+ dead_code: true,
+ }
+ input: {
+ try {
+ console.log("PASS");
+ } catch (e) {
+ } finally {
+ var a;
+ }
+ }
+ expect: {
+ try {
+ console.log("PASS");
+ var a;
+ } catch (e) {
+ }
+ }
+ expect_stdout: "PASS"
+}
+
try_catch_finally: {
options = {
conditionals: true,
@@ -130,10 +190,7 @@ try_catch_finally: {
a = 3;
console.log("PASS");
}();
- try {
- console.log(a);
- } finally {
- }
+ console.log(a);
}
expect_stdout: [
"PASS",