aboutsummaryrefslogtreecommitdiff
path: root/test/compress/yields.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-08 20:28:23 +0000
committerGitHub <noreply@github.com>2021-02-09 04:28:23 +0800
commite13d1e996909f68ee643df17fd7d87773c3e82a5 (patch)
treeb519e7a0cd2c3150de25964aaa3399be135eaa7a /test/compress/yields.js
parentaedc1e7fc9cab772734d559e149c0b4f70454321 (diff)
downloadtracifyjs-e13d1e996909f68ee643df17fd7d87773c3e82a5.tar.gz
tracifyjs-e13d1e996909f68ee643df17fd7d87773c3e82a5.zip
support `for [await]...of` statements (#4627)
Diffstat (limited to 'test/compress/yields.js')
-rw-r--r--test/compress/yields.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/compress/yields.js b/test/compress/yields.js
index 2d29c9b6..d799c194 100644
--- a/test/compress/yields.js
+++ b/test/compress/yields.js
@@ -96,6 +96,48 @@ pause_resume: {
node_version: ">=4"
}
+for_of: {
+ input: {
+ function* f() {
+ if (yield "PASS") yield "FAIL 1";
+ yield 42;
+ return "FAIL 2";
+ }
+ for (var a of f())
+ console.log(a);
+ }
+ expect_exact: 'function*f(){if(yield"PASS")yield"FAIL 1";yield 42;return"FAIL 2"}for(var a of f())console.log(a);'
+ expect_stdout: [
+ "PASS",
+ "42",
+ ]
+ node_version: ">=4"
+}
+
+for_await_of: {
+ input: {
+ async function* f() {
+ if (yield "PASS") yield "FAIL 1";
+ yield {
+ then: function(r) {
+ r(42);
+ },
+ };
+ return "FAIL 2";
+ }
+ (async function(a) {
+ for await (a of f())
+ console.log(a);
+ })();
+ }
+ expect_exact: 'async function*f(){if(yield"PASS")yield"FAIL 1";yield{then:function(r){r(42)}};return"FAIL 2"}(async function(a){for await(a of f())console.log(a)})();'
+ expect_stdout: [
+ "PASS",
+ "42",
+ ]
+ node_version: ">=10"
+}
+
collapse_vars_1: {
options = {
collapse_vars: true,