aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-07-27 14:47:01 +0100
committerGitHub <noreply@github.com>2021-07-27 21:47:01 +0800
commit4fe2cac35ecd8fc5a69b1122cf536ee148340b3d (patch)
tree8fa8c61c03dea044412bb3ed9ec3bc2e717786de /test
parente219a9a78a0d2251e4dcbd4bb9034207eb484fe8 (diff)
downloadtracifyjs-4fe2cac35ecd8fc5a69b1122cf536ee148340b3d.tar.gz
tracifyjs-4fe2cac35ecd8fc5a69b1122cf536ee148340b3d.zip
enhance `inline` (#5105)
Diffstat (limited to 'test')
-rw-r--r--test/compress/awaits.js6
-rw-r--r--test/compress/drop-unused.js6
-rw-r--r--test/compress/functions.js39
3 files changed, 43 insertions, 8 deletions
diff --git a/test/compress/awaits.js b/test/compress/awaits.js
index dc278f7e..0a7ae648 100644
--- a/test/compress/awaits.js
+++ b/test/compress/awaits.js
@@ -227,7 +227,7 @@ inline_await_1_trim: {
console.log("PASS");
}
expect: {
- void 0;
+ 0;
console.log("PASS");
}
expect_stdout: "PASS"
@@ -571,7 +571,7 @@ drop_async_1: {
}
expect: {
console.log(function(a) {
- void (a *= 7);
+ a *= 7;
return a;
}(6));
}
@@ -1774,7 +1774,7 @@ issue_5001: {
}
expect: {
var a = 0;
- void a++;
+ a++;
console.log(a ? "PASS" : "FAIL");
}
expect_stdout: "PASS"
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index 3d2a4f44..dc934c9b 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -1557,9 +1557,9 @@ issue_2665: {
}
expect: {
var a = 1;
- !function g() {
+ (function g() {
a-- && g();
- }();
+ })();
console.log(a);
}
expect_stdout: "-1"
@@ -3379,7 +3379,7 @@ issue_4834: {
}
expect: {
try {
- void b.p;
+ b.p;
} catch (e) {
console.log("PASS");
}
diff --git a/test/compress/functions.js b/test/compress/functions.js
index ccfb3044..05d175c1 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -1171,11 +1171,11 @@ issue_2620_4: {
}
expect: {
var c = "FAIL";
- !function() {
+ (function() {
switch (NaN) {
case void (c = "PASS"):
}
- }();
+ })();
console.log(c);
}
expect_stdout: "PASS"
@@ -6565,3 +6565,38 @@ issue_5098: {
}
expect_stdout: "PASS"
}
+
+shorter_without_void: {
+ options = {
+ inline: true,
+ passes: 2,
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ }
+ input: {
+ var a;
+ function f(b) {
+ a = b;
+ }
+ f("foo");
+ console.log(a) || f("bar");
+ console.log(a, f("baz"));
+ console.log(a);
+ }
+ expect: {
+ var a;
+ function f(b) {
+ a = b;
+ }
+ a = "foo";
+ console.log(a) || (a = "bar");
+ console.log(a, f("baz"));
+ console.log(a);
+ }
+ expect_stdout: [
+ "foo",
+ "bar undefined",
+ "baz",
+ ]
+}