aboutsummaryrefslogtreecommitdiff
path: root/test/compress/dead-code.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-30 12:16:58 +0800
committerGitHub <noreply@github.com>2017-03-30 12:16:58 +0800
commit7bea38a05dbe357434001fe59dbe06bb659a585f (patch)
tree7cc5cd33df52b95b44c31ecbfa49a48af4d0b121 /test/compress/dead-code.js
parent0f910ee25c3e644baf043f217b2fe91df8dc67ac (diff)
downloadtracifyjs-7bea38a05dbe357434001fe59dbe06bb659a585f.tar.gz
tracifyjs-7bea38a05dbe357434001fe59dbe06bb659a585f.zip
optimize try-catch-finally (#1731)
- eliminate empty blocks - flatten out if try-block does not throw
Diffstat (limited to 'test/compress/dead-code.js')
-rw-r--r--test/compress/dead-code.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js
index 7772e76e..bb72451c 100644
--- a/test/compress/dead-code.js
+++ b/test/compress/dead-code.js
@@ -214,3 +214,45 @@ dead_code_const_annotation_complex_scope: {
}
expect_stdout: true
}
+
+try_catch_finally: {
+ options = {
+ conditionals: true,
+ dead_code: true,
+ evaluate: true,
+ }
+ input: {
+ var a = 1;
+ !function() {
+ try {
+ if (false) throw x;
+ } catch (a) {
+ var a = 2;
+ console.log("FAIL");
+ } finally {
+ a = 3;
+ console.log("PASS");
+ }
+ }();
+ try {
+ console.log(a);
+ } finally {
+ }
+ }
+ expect: {
+ var a = 1;
+ !function() {
+ var a;
+ a = 3;
+ console.log("PASS");
+ }();
+ try {
+ console.log(a);
+ } finally {
+ }
+ }
+ expect_stdout: [
+ "PASS",
+ "1",
+ ]
+}