diff options
Diffstat (limited to 'cli/tests/unit')
-rw-r--r-- | cli/tests/unit/flock_test.ts | 2 | ||||
-rw-r--r-- | cli/tests/unit/timers_test.ts | 52 |
2 files changed, 4 insertions, 50 deletions
diff --git a/cli/tests/unit/flock_test.ts b/cli/tests/unit/flock_test.ts index 3c73d0481..fbc061593 100644 --- a/cli/tests/unit/flock_test.ts +++ b/cli/tests/unit/flock_test.ts @@ -136,7 +136,7 @@ function runFlockTestProcess(opts: { exclusive: boolean; sync: boolean }) { // the lock so that the enter time of the next process doesn't // occur at the same time as this exit time const exitTime = new Date().getTime(); - Deno.sleepSync(100); + await new Promise(resolve => setTimeout(resolve, 100)); // release the lock ${opts.sync ? "Deno.funlockSync(rid);" : "await Deno.funlock(rid);"} diff --git a/cli/tests/unit/timers_test.ts b/cli/tests/unit/timers_test.ts index ef7dc9eef..e6901a42c 100644 --- a/cli/tests/unit/timers_test.ts +++ b/cli/tests/unit/timers_test.ts @@ -215,7 +215,7 @@ Deno.test(async function callbackTakesLongerThanInterval() { const interval = setInterval(() => { if (timeEndOfFirstCallback === undefined) { // First callback - Deno.sleepSync(300); + Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 300); timeEndOfFirstCallback = Date.now(); } else { // Second callback @@ -237,7 +237,7 @@ Deno.test(async function clearTimeoutAfterNextTimerIsDue1() { }, 300); const interval = setInterval(() => { - Deno.sleepSync(400); + Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 400); // Both the interval and the timeout's due times are now in the past. clearInterval(interval); }, 100); @@ -255,7 +255,7 @@ Deno.test(async function clearTimeoutAfterNextTimerIsDue2() { promise.resolve(); }, 200); - Deno.sleepSync(300); + Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 300); // Both of the timeouts' due times are now in the past. clearTimeout(timeout1); @@ -531,52 +531,6 @@ Deno.test(async function timerIgnoresDateOverride() { assertEquals(hasThrown, 1); }); -Deno.test({ permissions: { hrtime: true } }, function sleepSync() { - const start = performance.now(); - Deno.sleepSync(10); - const after = performance.now(); - assert(after - start >= 10); -}); - -Deno.test( - { permissions: { hrtime: true } }, - async function sleepSyncShorterPromise() { - const perf = performance; - const short = 5; - const long = 10; - - const start = perf.now(); - const p = delay(short).then(() => { - const after = perf.now(); - // pending promises should resolve after the main thread comes out of sleep - assert(after - start >= long); - }); - Deno.sleepSync(long); - - await p; - }, -); - -Deno.test( - { permissions: { hrtime: true } }, - async function sleepSyncLongerPromise() { - const perf = performance; - const short = 5; - const long = 10; - - const start = perf.now(); - const p = delay(long).then(() => { - const after = perf.now(); - // sleeping for less than the duration of a promise should have no impact - // on the resolution of that promise - assert(after - start >= long); - }); - Deno.sleepSync(short); - - await p; - }, -); - Deno.test({ name: "unrefTimer", permissions: { run: true, read: true }, |