Commit a68dcff4 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[test] Add some more tests for async functions.

BUG=

Change-Id: I4a5db9bc045a63e710d0115523ab23b98e7c7ae6
Reviewed-on: https://chromium-review.googlesource.com/442504Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43189}
parent 6bb6224e
......@@ -390,3 +390,175 @@ async function gaga() {
while (i-- > 0) { await 42 }
}
assertDoesNotThrow(gaga);
{
let log = [];
async function foo() {
try {
Promise.resolve().then(() => log.push("a"))
} finally {
log.push("b");
}
}
foo().then(() => log.push("c"));
%RunMicrotasks();
assertEquals(["b", "a", "c"], log);
}
{
let log = [];
async function foo() {
try {
return Promise.resolve().then(() => log.push("a"))
} finally {
log.push("b");
}
}
foo().then(() => log.push("c"));
%RunMicrotasks();
assertEquals(["b", "a", "c"], log);
}
{
let log = [];
async function foo() {
try {
return await Promise.resolve().then(() => log.push("a"))
} finally {
log.push("b");
}
}
foo().then(() => log.push("c"));
%RunMicrotasks();
assertEquals(["a", "b", "c"], log);
}
{
let log = [];
async function foo() {
try {
Promise.resolve().then().then(() => log.push("a"))
} finally {
log.push("b");
}
}
foo().then(() => log.push("c"));
%RunMicrotasks();
assertEquals(["b", "c", "a"], log);
}
{
let log = [];
async function foo() {
try {
return Promise.resolve().then().then(() => log.push("a"))
} finally {
log.push("b");
}
}
foo().then(() => log.push("c"));
%RunMicrotasks();
assertEquals(["b", "a", "c"], log);
}
{
let log = [];
async function foo() {
try {
return await Promise.resolve().then().then(() => log.push("a"))
} finally {
log.push("b");
}
}
foo().then(() => log.push("c"));
%RunMicrotasks();
assertEquals(["a", "b", "c"], log);
}
{
let log = [];
async function foo() {
try {
Promise.resolve().then(() => log.push("a"))
} finally {
return log.push("b");
}
}
foo().then(() => log.push("c"));
%RunMicrotasks();
assertEquals(["b", "a", "c"], log);
}
{
let log = [];
async function foo() {
try {
return Promise.resolve().then(() => log.push("a"))
} finally {
return log.push("b");
}
}
foo().then(() => log.push("c"));
%RunMicrotasks();
assertEquals(["b", "a", "c"], log);
}
{
let log = [];
async function foo() {
try {
return await Promise.resolve().then(() => log.push("a"))
} finally {
return log.push("b");
}
}
foo().then(() => log.push("c"));
%RunMicrotasks();
assertEquals(["a", "b", "c"], log);
}
{
let log = [];
async function foo() {
try {
Promise.resolve().then().then(() => log.push("a"))
} finally {
return log.push("b");
}
}
foo().then(() => log.push("c"));
%RunMicrotasks();
assertEquals(["b", "c", "a"], log);
}
{
let log = [];
async function foo() {
try {
return Promise.resolve().then().then(() => log.push("a"))
} finally {
return log.push("b");
}
}
foo().then(() => log.push("c"));
%RunMicrotasks();
assertEquals(["b", "c", "a"], log);
}
{
let log = [];
async function foo() {
try {
return await Promise.resolve().then().then(() => log.push("a"))
} finally {
return log.push("b");
}
}
foo().then(() => log.push("c"));
%RunMicrotasks();
assertEquals(["a", "b", "c"], log);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment