aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-12-14 04:38:21 +0800
committerGitHub <noreply@github.com>2017-12-14 04:38:21 +0800
commit8266993c6e0a78c4872cbcb81072094a4a7dba2d (patch)
tree4bd8d1e6fc25a50256c4d66810e5dbfd164262ac /test/compress
parent9a137e8613e49066a54f2a1b734a559c05338f11 (diff)
downloadtracifyjs-8266993c6e0a78c4872cbcb81072094a4a7dba2d.tar.gz
tracifyjs-8266993c6e0a78c4872cbcb81072094a4a7dba2d.zip
fix `dead_code` on `return`/`throw` within `try` (#2588)
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/dead-code.js146
1 files changed, 146 insertions, 0 deletions
diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js
index ca7ad5c0..9612b92b 100644
--- a/test/compress/dead-code.js
+++ b/test/compress/dead-code.js
@@ -491,6 +491,20 @@ return_assignment: {
var e;
return e = x();
}
+ function f5(a) {
+ try {
+ return a = x();
+ } catch (b) {
+ console.log(a);
+ }
+ }
+ function f6(a) {
+ try {
+ return a = x();
+ } finally {
+ console.log(a);
+ }
+ }
}
expect: {
function f1(a, b, c) {
@@ -505,5 +519,137 @@ return_assignment: {
function f4() {
return x();
}
+ function f5(a) {
+ try {
+ return x();
+ } catch (b) {
+ console.log(a);
+ }
+ }
+ function f6(a) {
+ try {
+ return a = x();
+ } finally {
+ console.log(a);
+ }
+ }
+ }
+}
+
+throw_assignment: {
+ options = {
+ dead_code: true,
+ unused: true,
+ }
+ input: {
+ function f1() {
+ throw a = x();
+ }
+ function f2(a) {
+ throw a = x();
+ }
+ function f3() {
+ var a;
+ throw a = x();
+ }
+ function f4() {
+ try {
+ throw a = x();
+ } catch (b) {
+ console.log(a);
+ }
+ }
+ function f5(a) {
+ try {
+ throw a = x();
+ } catch (b) {
+ console.log(a);
+ }
+ }
+ function f6() {
+ var a;
+ try {
+ throw a = x();
+ } catch (b) {
+ console.log(a);
+ }
+ }
+ function f7() {
+ try {
+ throw a = x();
+ } finally {
+ console.log(a);
+ }
+ }
+ function f8(a) {
+ try {
+ throw a = x();
+ } finally {
+ console.log(a);
+ }
+ }
+ function f9() {
+ var a;
+ try {
+ throw a = x();
+ } finally {
+ console.log(a);
+ }
+ }
+ }
+ expect: {
+ function f1() {
+ throw a = x();
+ }
+ function f2(a) {
+ throw x();
+ }
+ function f3() {
+ throw x();
+ }
+ function f4() {
+ try {
+ throw a = x();
+ } catch (b) {
+ console.log(a);
+ }
+ }
+ function f5(a) {
+ try {
+ throw a = x();
+ } catch (b) {
+ console.log(a);
+ }
+ }
+ function f6() {
+ var a;
+ try {
+ throw a = x();
+ } catch (b) {
+ console.log(a);
+ }
+ }
+ function f7() {
+ try {
+ throw a = x();
+ } finally {
+ console.log(a);
+ }
+ }
+ function f8(a) {
+ try {
+ throw a = x();
+ } finally {
+ console.log(a);
+ }
+ }
+ function f9() {
+ var a;
+ try {
+ throw a = x();
+ } finally {
+ console.log(a);
+ }
+ }
}
}