aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-03-22 23:46:26 +0800
committerGitHub <noreply@github.com>2018-03-22 23:46:26 +0800
commit5c169615a84201b707e77c1b72b56908ca369d40 (patch)
tree6a6139fe1f972da85930461d8e748c3760c782b9 /test
parent73d77f4f642b3830f7d83bb329c9a631eb09856f (diff)
downloadtracifyjs-5c169615a84201b707e77c1b72b56908ca369d40.tar.gz
tracifyjs-5c169615a84201b707e77c1b72b56908ca369d40.zip
fix corner case in `inline` (#3017)
fixes #3016
Diffstat (limited to 'test')
-rw-r--r--test/compress/functions.js157
1 files changed, 157 insertions, 0 deletions
diff --git a/test/compress/functions.js b/test/compress/functions.js
index ddf5fe05..bbe94ebf 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -2051,3 +2051,160 @@ drop_lone_use_strict: {
}
}
}
+
+issue_3016_1: {
+ options = {
+ inline: true,
+ toplevel: true,
+ }
+ input: {
+ var b = 1;
+ do {
+ (function(a) {
+ return a[b];
+ var a;
+ })(3);
+ } while (0);
+ console.log(b);
+ }
+ expect: {
+ var b = 1;
+ do {
+ a = 3,
+ a[b];
+ } while(0);
+ var a;
+ console.log(b);
+ }
+ expect_stdout: "1"
+}
+
+issue_3016_2: {
+ options = {
+ dead_code: true,
+ inline: true,
+ toplevel: true,
+ }
+ input: {
+ var b = 1;
+ do {
+ (function(a) {
+ return a[b];
+ try {
+ a = 2;
+ } catch (a) {
+ var a;
+ }
+ })(3);
+ } while (0);
+ console.log(b);
+ }
+ expect: {
+ var b = 1;
+ do {
+ a = 3,
+ a[b];
+ } while(0);
+ var a;
+ console.log(b);
+ }
+ expect_stdout: "1"
+}
+
+issue_3016_2_ie8: {
+ options = {
+ dead_code: true,
+ ie8: true,
+ inline: true,
+ toplevel: true,
+ }
+ input: {
+ var b = 1;
+ do {
+ (function(a) {
+ return a[b];
+ try {
+ a = 2;
+ } catch (a) {
+ var a;
+ }
+ })(3);
+ } while (0);
+ console.log(b);
+ }
+ expect: {
+ var b = 1;
+ do {
+ a = 3,
+ a[b];
+ } while(0);
+ var a;
+ console.log(b);
+ }
+ expect_stdout: "1"
+}
+
+issue_3016_3: {
+ options = {
+ dead_code: true,
+ inline: true,
+ toplevel: true,
+ }
+ input: {
+ var b = 1;
+ do {
+ console.log(function() {
+ return a ? "FAIL" : a = "PASS";
+ try {
+ a = 2;
+ } catch (a) {
+ var a;
+ }
+ }());
+ } while (b--);
+ }
+ expect: {
+ var b = 1;
+ do {
+ console.log((a = void 0, a ? "FAIL" : a = "PASS"));
+ } while(b--);
+ var a;
+ }
+ expect_stdout: [
+ "PASS",
+ "PASS",
+ ]
+}
+
+issue_3016_3_ie8: {
+ options = {
+ dead_code: true,
+ ie8: true,
+ inline: true,
+ toplevel: true,
+ }
+ input: {
+ var b = 1;
+ do {
+ console.log(function() {
+ return a ? "FAIL" : a = "PASS";
+ try {
+ a = 2;
+ } catch (a) {
+ var a;
+ }
+ }());
+ } while (b--);
+ }
+ expect: {
+ var b = 1;
+ do {
+ console.log((a = void 0, a ? "FAIL" : a = "PASS"));
+ } while(b--);
+ var a;
+ }
+ expect_stdout: [
+ "PASS",
+ "PASS",
+ ]
+}