diff options
Diffstat (limited to 'cli/js/timers_test.ts')
-rw-r--r-- | cli/js/timers_test.ts | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/cli/js/timers_test.ts b/cli/js/timers_test.ts index 8cb505ee4..429e42692 100644 --- a/cli/js/timers_test.ts +++ b/cli/js/timers_test.ts @@ -1,6 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { - test, + unitTest, createResolvable, assert, assertEquals, @@ -31,7 +31,7 @@ async function waitForMs(ms: number): Promise<number> { return new Promise((resolve: () => void): number => setTimeout(resolve, ms)); } -test(async function timeoutSuccess(): Promise<void> { +unitTest(async function timeoutSuccess(): Promise<void> { const { promise, resolve } = deferred(); let count = 0; setTimeout((): void => { @@ -43,7 +43,7 @@ test(async function timeoutSuccess(): Promise<void> { assertEquals(count, 1); }); -test(async function timeoutArgs(): Promise<void> { +unitTest(async function timeoutArgs(): Promise<void> { const { promise, resolve } = deferred(); const arg = 1; setTimeout( @@ -61,7 +61,7 @@ test(async function timeoutArgs(): Promise<void> { await promise; }); -test(async function timeoutCancelSuccess(): Promise<void> { +unitTest(async function timeoutCancelSuccess(): Promise<void> { let count = 0; const id = setTimeout((): void => { count++; @@ -72,7 +72,7 @@ test(async function timeoutCancelSuccess(): Promise<void> { assertEquals(count, 0); }); -test(async function timeoutCancelMultiple(): Promise<void> { +unitTest(async function timeoutCancelMultiple(): Promise<void> { function uncalled(): never { throw new Error("This function should not be called."); } @@ -97,7 +97,7 @@ test(async function timeoutCancelMultiple(): Promise<void> { await waitForMs(50); }); -test(async function timeoutCancelInvalidSilentFail(): Promise<void> { +unitTest(async function timeoutCancelInvalidSilentFail(): Promise<void> { // Expect no panic const { promise, resolve } = deferred(); let count = 0; @@ -114,7 +114,7 @@ test(async function timeoutCancelInvalidSilentFail(): Promise<void> { clearTimeout(2147483647); }); -test(async function intervalSuccess(): Promise<void> { +unitTest(async function intervalSuccess(): Promise<void> { const { promise, resolve } = deferred(); let count = 0; const id = setInterval((): void => { @@ -129,7 +129,7 @@ test(async function intervalSuccess(): Promise<void> { assertEquals(count, 1); }); -test(async function intervalCancelSuccess(): Promise<void> { +unitTest(async function intervalCancelSuccess(): Promise<void> { let count = 0; const id = setInterval((): void => { count++; @@ -139,7 +139,7 @@ test(async function intervalCancelSuccess(): Promise<void> { assertEquals(count, 0); }); -test(async function intervalOrdering(): Promise<void> { +unitTest(async function intervalOrdering(): Promise<void> { const timers: number[] = []; let timeouts = 0; function onTimeout(): void { @@ -155,12 +155,12 @@ test(async function intervalOrdering(): Promise<void> { assertEquals(timeouts, 1); }); -test(async function intervalCancelInvalidSilentFail(): Promise<void> { +unitTest(async function intervalCancelInvalidSilentFail(): Promise<void> { // Should silently fail (no panic) clearInterval(2147483647); }); -test(async function fireCallbackImmediatelyWhenDelayOverMaxValue(): Promise< +unitTest(async function fireCallbackImmediatelyWhenDelayOverMaxValue(): Promise< void > { let count = 0; @@ -171,7 +171,7 @@ test(async function fireCallbackImmediatelyWhenDelayOverMaxValue(): Promise< assertEquals(count, 1); }); -test(async function timeoutCallbackThis(): Promise<void> { +unitTest(async function timeoutCallbackThis(): Promise<void> { const { promise, resolve } = deferred(); const obj = { foo(): void { @@ -183,7 +183,7 @@ test(async function timeoutCallbackThis(): Promise<void> { await promise; }); -test(async function timeoutBindThis(): Promise<void> { +unitTest(async function timeoutBindThis(): Promise<void> { const thisCheckPassed = [null, undefined, window, globalThis]; const thisCheckFailed = [ @@ -231,7 +231,7 @@ test(async function timeoutBindThis(): Promise<void> { } }); -test(async function clearTimeoutShouldConvertToNumber(): Promise<void> { +unitTest(async function clearTimeoutShouldConvertToNumber(): Promise<void> { let called = false; const obj = { valueOf(): number { @@ -243,7 +243,7 @@ test(async function clearTimeoutShouldConvertToNumber(): Promise<void> { assert(called); }); -test(function setTimeoutShouldThrowWithBigint(): void { +unitTest(function setTimeoutShouldThrowWithBigint(): void { let hasThrown = 0; try { setTimeout((): void => {}, (1n as unknown) as number); @@ -258,7 +258,7 @@ test(function setTimeoutShouldThrowWithBigint(): void { assertEquals(hasThrown, 2); }); -test(function clearTimeoutShouldThrowWithBigint(): void { +unitTest(function clearTimeoutShouldThrowWithBigint(): void { let hasThrown = 0; try { clearTimeout((1n as unknown) as number); @@ -273,23 +273,23 @@ test(function clearTimeoutShouldThrowWithBigint(): void { assertEquals(hasThrown, 2); }); -test(function testFunctionName(): void { +unitTest(function testFunctionName(): void { assertEquals(clearTimeout.name, "clearTimeout"); assertEquals(clearInterval.name, "clearInterval"); }); -test(function testFunctionParamsLength(): void { +unitTest(function testFunctionParamsLength(): void { assertEquals(setTimeout.length, 1); assertEquals(setInterval.length, 1); assertEquals(clearTimeout.length, 0); assertEquals(clearInterval.length, 0); }); -test(function clearTimeoutAndClearIntervalNotBeEquals(): void { +unitTest(function clearTimeoutAndClearIntervalNotBeEquals(): void { assertNotEquals(clearTimeout, clearInterval); }); -test(async function timerMaxCpuBug(): Promise<void> { +unitTest(async function timerMaxCpuBug(): Promise<void> { // There was a bug where clearing a timeout would cause Deno to use 100% CPU. clearTimeout(setTimeout(() => {}, 1000)); // We can check this by counting how many ops have triggered in the interim. @@ -300,7 +300,7 @@ test(async function timerMaxCpuBug(): Promise<void> { assert(opsDispatched_ - opsDispatched < 10); }); -test(async function timerBasicMicrotaskOrdering(): Promise<void> { +unitTest(async function timerBasicMicrotaskOrdering(): Promise<void> { let s = ""; let count = 0; const { promise, resolve } = deferred(); @@ -324,7 +324,7 @@ test(async function timerBasicMicrotaskOrdering(): Promise<void> { assertEquals(s, "deno"); }); -test(async function timerNestedMicrotaskOrdering(): Promise<void> { +unitTest(async function timerNestedMicrotaskOrdering(): Promise<void> { let s = ""; const { promise, resolve } = deferred(); s += "0"; |