mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
timers: add test for clearTimer bug #942
This commit is contained in:
parent
3fe6530f11
commit
5b66f28fa3
1 changed files with 25 additions and 0 deletions
|
@ -65,6 +65,31 @@ test(async function timeoutCancelSuccess() {
|
|||
assertEqual(count, 0);
|
||||
});
|
||||
|
||||
test(async function timeoutCancelMultiple() {
|
||||
// Set timers and cancel them in the same order.
|
||||
const t1 = setTimeout(uncalled, 10);
|
||||
const t2 = setTimeout(uncalled, 10);
|
||||
const t3 = setTimeout(uncalled, 10);
|
||||
clearTimeout(t1);
|
||||
clearTimeout(t2);
|
||||
clearTimeout(t3);
|
||||
|
||||
// Set timers and cancel them in reverse order.
|
||||
const t4 = setTimeout(uncalled, 20);
|
||||
const t5 = setTimeout(uncalled, 20);
|
||||
const t6 = setTimeout(uncalled, 20);
|
||||
clearTimeout(t6);
|
||||
clearTimeout(t5);
|
||||
clearTimeout(t4);
|
||||
|
||||
// Sleep until we're certain that the cancelled timers aren't gonna fire.
|
||||
await waitForMs(50);
|
||||
|
||||
function uncalled() {
|
||||
throw new Error("This function should not be called.");
|
||||
}
|
||||
});
|
||||
|
||||
test(async function timeoutCancelInvalidSilentFail() {
|
||||
// Expect no panic
|
||||
const { promise, resolve } = deferred();
|
||||
|
|
Loading…
Reference in a new issue