support for [await]...of statements (#4627)

This commit is contained in:
Alex Lam S.L
2021-02-08 20:28:23 +00:00
committed by GitHub
parent aedc1e7fc9
commit e13d1e9969
11 changed files with 203 additions and 64 deletions

View File

@@ -828,6 +828,21 @@ empty_for_in_prop_init: {
]
}
for_of: {
input: {
var async = [ "PASS", 42 ];
async.p = "FAIL";
for (async of (null, async))
console.log(async);
}
expect_exact: 'var async=["PASS",42];async.p="FAIL";for(async of(null,async))console.log(async);'
expect_stdout: [
"PASS",
"42",
]
node_version: ">=0.12"
}
issue_3631_1: {
options = {
dead_code: true,

View File

@@ -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,