From 2f3de4b4252b933ac1161ba099feaed9103ab149 Mon Sep 17 00:00:00 2001 From: "Kevin (Kun) \"Kassimo\" Qian" Date: Thu, 19 Mar 2020 07:45:28 -0700 Subject: Simplify timer with macrotask callback (#4385) --- cli/js/tests/timers_test.ts | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'cli/js/tests') diff --git a/cli/js/tests/timers_test.ts b/cli/js/tests/timers_test.ts index 429e42692..077e27ae6 100644 --- a/cli/js/tests/timers_test.ts +++ b/cli/js/tests/timers_test.ts @@ -127,6 +127,9 @@ unitTest(async function intervalSuccess(): Promise { clearInterval(id); // count should increment twice assertEquals(count, 1); + // Similar false async leaking alarm. + // Force next round of polling. + await waitForMs(0); }); unitTest(async function intervalCancelSuccess(): Promise { @@ -330,24 +333,32 @@ unitTest(async function timerNestedMicrotaskOrdering(): Promise { s += "0"; setTimeout(() => { s += "4"; - setTimeout(() => (s += "8")); - Promise.resolve().then(() => { - setTimeout(() => { - s += "9"; - resolve(); + setTimeout(() => (s += "A")); + Promise.resolve() + .then(() => { + setTimeout(() => { + s += "B"; + resolve(); + }); + }) + .then(() => { + s += "5"; }); - }); }); - setTimeout(() => (s += "5")); + setTimeout(() => (s += "6")); Promise.resolve().then(() => (s += "2")); Promise.resolve().then(() => setTimeout(() => { - s += "6"; - Promise.resolve().then(() => (s += "7")); + s += "7"; + Promise.resolve() + .then(() => (s += "8")) + .then(() => { + s += "9"; + }); }) ); Promise.resolve().then(() => Promise.resolve().then(() => (s += "3"))); s += "1"; await promise; - assertEquals(s, "0123456789"); + assertEquals(s, "0123456789AB"); }); -- cgit v1.2.3