fix corner case in awaits (#5160)

fixes #5159
This commit is contained in:
Alex Lam S.L
2021-10-31 23:46:55 +08:00
committed by GitHub
parent eb93d92357
commit a841d45bc3
2 changed files with 70 additions and 1 deletions

View File

@@ -2143,3 +2143,72 @@ issue_5157_promise: {
expect_stdout: "PASS"
node_version: ">=8"
}
issue_5159_1: {
options = {
awaits: true,
side_effects: true,
}
input: {
(async function() {
try {
throw "foo";
} catch (e) {
return await "bar";
} finally {
console.log("baz");
}
})().catch(console.log).then(console.log);
console.log("moo");
}
expect: {
(async function() {
try {
throw "foo";
} catch (e) {
return await "bar";
} finally {
console.log("baz");
}
})().catch(console.log).then(console.log);
console.log("moo");
}
expect_stdout: [
"moo",
"baz",
"bar",
]
node_version: ">=8"
}
issue_5159_2: {
options = {
awaits: true,
side_effects: true,
}
input: {
(async function() {
try {
throw "foo";
} catch (e) {
return await "bar";
}
})().catch(console.log).then(console.log);
console.log("baz");
}
expect: {
(async function() {
try {
throw "foo";
} catch (e) {
return "bar";
}
})().catch(console.log).then(console.log);
console.log("baz");
}
expect_stdout: [
"baz",
"bar",
]
node_version: ">=8"
}