diff options
author | Kevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com> | 2020-03-19 07:45:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-19 10:45:28 -0400 |
commit | 2f3de4b4252b933ac1161ba099feaed9103ab149 (patch) | |
tree | 762b05bcfe9588897b157400b2723fadf43dc94c /cli/js/tests/timers_test.ts | |
parent | 8c1c929034d46101b6a51ec5cf5e2f307ed0c271 (diff) |
Simplify timer with macrotask callback (#4385)
Diffstat (limited to 'cli/js/tests/timers_test.ts')
-rw-r--r-- | cli/js/tests/timers_test.ts | 31 |
1 files changed, 21 insertions, 10 deletions
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<void> { 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<void> { @@ -330,24 +333,32 @@ unitTest(async function timerNestedMicrotaskOrdering(): Promise<void> { 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"); }); |