aboutsummaryrefslogtreecommitdiff
path: root/test/compress/async.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-01-02 01:43:05 +0000
committerGitHub <noreply@github.com>2021-01-02 09:43:05 +0800
commitcc2d7acaf0ed2479c8d3a5d3cbbce15a3cb2333b (patch)
treefcd83b713f22071052fbb1a4319d486fa16489ab /test/compress/async.js
parentdfb86ccdd1dfe6f07953afc8c308b00c9c6856b1 (diff)
downloadtracifyjs-cc2d7acaf0ed2479c8d3a5d3cbbce15a3cb2333b.tar.gz
tracifyjs-cc2d7acaf0ed2479c8d3a5d3cbbce15a3cb2333b.zip
enhance `inline`, `sequences` & `side_effects` (#4493)
Diffstat (limited to 'test/compress/async.js')
-rw-r--r--test/compress/async.js176
1 files changed, 176 insertions, 0 deletions
diff --git a/test/compress/async.js b/test/compress/async.js
index 5d623bbe..51aba26c 100644
--- a/test/compress/async.js
+++ b/test/compress/async.js
@@ -140,6 +140,182 @@ dont_inline: {
node_version: ">=8"
}
+inline_await_1: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (async function() {
+ async function f() {
+ await 42;
+ }
+ return await f();
+ })();
+ console.log("PASS");
+ }
+ expect: {
+ (async function() {
+ return await void await 42;
+ })();
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+ node_version: ">=8"
+}
+
+inline_await_1_trim: {
+ options = {
+ if_return: true,
+ inline: true,
+ reduce_vars: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ (async function() {
+ async function f() {
+ await 42;
+ }
+ return await f();
+ })();
+ console.log("PASS");
+ }
+ expect: {
+ (async function() {
+ await 42;
+ })();
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+ node_version: ">=8"
+}
+
+inline_await_2: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (async function() {
+ async function f(a) {
+ await a;
+ }
+ return await f(console);
+ })();
+ console.log("PASS");
+ }
+ expect: {
+ (async function() {
+ return await void await console;
+ })();
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+ node_version: ">=8"
+}
+
+inline_await_2_trim: {
+ options = {
+ if_return: true,
+ inline: true,
+ reduce_vars: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ (async function() {
+ async function f(a) {
+ await a;
+ }
+ return await f(console);
+ })();
+ console.log("PASS");
+ }
+ expect: {
+ (async function() {
+ await console;
+ })();
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+ node_version: ">=8"
+}
+
+inline_await_3: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (async function() {
+ async function f(a, b) {
+ return await b(a);
+ }
+ return await f("PASS", console.log);
+ })();
+ }
+ expect: {
+ (async function() {
+ return await (a = "PASS", b = console.log, await b(a));
+ var a, b;
+ })();
+ }
+ expect_stdout: "PASS"
+ node_version: ">=8"
+}
+
+inline_await_3_trim: {
+ options = {
+ inline: true,
+ reduce_vars: true,
+ sequences: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ (async function() {
+ async function f(a, b) {
+ return await b(a);
+ }
+ return await f("PASS", console.log);
+ })();
+ }
+ expect: {
+ (async function() {
+ return a = "PASS", b = console.log, await b(a);
+ var a, b;
+ })();
+ }
+ expect_stdout: "PASS"
+ node_version: ">=8"
+}
+
+await_unary: {
+ options = {
+ side_effects: true,
+ }
+ input: {
+ (async function() {
+ console.log("PASS");
+ await +[];
+ console.log("FAIL");
+ })();
+ }
+ expect: {
+ (async function() {
+ console.log("PASS");
+ await +[];
+ console.log("FAIL");
+ })();
+ }
+ expect_stdout: "PASS"
+ node_version: ">=8"
+}
+
evaluate: {
options = {
evaluate: true,