fix corner case in awaits (#4973)

fixes #4972
This commit is contained in:
Alex Lam S.L
2021-05-28 03:53:10 +01:00
committed by GitHub
parent 8cd95dd263
commit d320a6cde2
2 changed files with 118 additions and 1 deletions

View File

@@ -1574,3 +1574,111 @@ issue_4764_3: {
expect_stdout: "PASS"
node_version: ">=8"
}
issue_4972_1: {
options = {
awaits: true,
side_effects: true,
}
input: {
console.log("foo");
(async function() {
try {
return await "bar";
} finally {
console.log("baz");
}
})().then(console.log);
console.log("moo");
}
expect: {
console.log("foo");
(async function() {
try {
return await "bar";
} finally {
console.log("baz");
}
})().then(console.log);
console.log("moo");
}
expect_stdout: [
"foo",
"moo",
"baz",
"bar",
]
node_version: ">=8"
}
issue_4972_2: {
options = {
awaits: true,
side_effects: true,
}
input: {
console.log("foo");
(async function() {
try {
console.log("bar");
} finally {
return await "baz";
}
})().then(console.log);
console.log("moo");
}
expect: {
console.log("foo");
(async function() {
try {
console.log("bar");
} finally {
return "baz";
}
})().then(console.log);
console.log("moo");
}
expect_stdout: [
"foo",
"bar",
"moo",
"baz",
]
node_version: ">=8"
}
issue_4972_3: {
options = {
awaits: true,
side_effects: true,
}
input: {
console.log("foo");
try {
(async function() {
return await "bar";
})().then(console.log);
} finally {
console.log("baz");
}
console.log("moo");
}
expect: {
console.log("foo");
try {
(async function() {
return "bar";
})().then(console.log);
} finally {
console.log("baz");
}
console.log("moo");
}
expect_stdout: [
"foo",
"baz",
"moo",
"bar",
]
node_version: ">=8"
}