diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-01-19 23:27:32 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-20 07:27:32 +0800 |
commit | d37ee4d41c70aa309550e7337f75126ef2932c62 (patch) | |
tree | f92d069caa23a7bb6824014a6139b68c8596811c /test/compress | |
parent | 7793c6c389930dd10fdce5a12b24c95d5bb93933 (diff) | |
download | tracifyjs-d37ee4d41c70aa309550e7337f75126ef2932c62.tar.gz tracifyjs-d37ee4d41c70aa309550e7337f75126ef2932c62.zip |
support asynchronous test cases properly (#4529)
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/awaits.js | 30 | ||||
-rw-r--r-- | test/compress/sandbox.js | 49 |
2 files changed, 68 insertions, 11 deletions
diff --git a/test/compress/awaits.js b/test/compress/awaits.js index 89d11bb9..4a90ca5e 100644 --- a/test/compress/awaits.js +++ b/test/compress/awaits.js @@ -612,22 +612,32 @@ issue_4340: { call_expression: { input: { console.log(typeof async function(log) { - (await log)("FAIL"); + (await log)("foo"); }(console.log).then); + console.log("bar"); } - expect_exact: 'console.log(typeof async function(log){(await log)("FAIL")}(console.log).then);' - expect_stdout: "function" + expect_exact: 'console.log(typeof async function(log){(await log)("foo")}(console.log).then);console.log("bar");' + expect_stdout: [ + "function", + "bar", + "foo", + ] node_version: ">=8" } property_access_expression: { input: { console.log(typeof async function(con) { - (await con).log("FAIL"); + (await con).log("foo"); }(console).then); + console.log("bar"); } - expect_exact: 'console.log(typeof async function(con){(await con).log("FAIL")}(console).then);' - expect_stdout: "function" + expect_exact: 'console.log(typeof async function(con){(await con).log("foo")}(console).then);console.log("bar");' + expect_stdout: [ + "function", + "bar", + "foo", + ] node_version: ">=8" } @@ -685,20 +695,18 @@ reduce_iife_3: { input: { var a = "foo"; (async function() { - console.log(a); - console.log(await a); + console.log(a, await a, a, await a); })(); a = "bar"; } expect: { var a = "foo"; (async function() { - console.log(a); - console.log(await a); + console.log(a, await a, a, await a); })(); a = "bar"; } - expect_stdout: "foo" + expect_stdout: "foo foo bar bar" node_version: ">=8" } diff --git a/test/compress/sandbox.js b/test/compress/sandbox.js index 9356f6f3..338afd11 100644 --- a/test/compress/sandbox.js +++ b/test/compress/sandbox.js @@ -13,6 +13,23 @@ console_log: { ] } +console_log_console: { + input: { + var log = console.log; + log(console); + log(typeof console.log); + } + expect: { + var log = console.log; + log(console); + log(typeof console.log); + } + expect_stdout: [ + "{ log: 'function(){}' }", + "function", + ] +} + typeof_arguments: { options = { evaluate: true, @@ -81,6 +98,38 @@ log_global: { expect_stdout: "[object global]" } +timers: { + options = { + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var count = 0, interval = 1000, duration = 3210; + var timer = setInterval(function() { + console.log(++count); + }, interval); + setTimeout(function() { + clearInterval(timer); + }, duration); + } + expect: { + var count = 0; + var timer = setInterval(function() { + console.log(++count); + }, 1000); + setTimeout(function() { + clearInterval(timer); + }, 3210); + } + expect_stdout: [ + "1", + "2", + "3", + ] + node_version: ">=0.12" +} + issue_4054: { input: { console.log({ |