1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00
denoland-deno/cli/js/performance_test.ts
Bartek Iwańczuk ee452ad883
add assertOps sanitizer in cli/js/ unit tests (#4209)
* add "assertOps" test assertion which makes sure test case
  is not "leaking" ops - ie. after test finishes there are no 
  pending async ops

* apply "assertOps" to all tests in "cli/js/"

* fix numerous tests leaking ops

* document problem with edge case in "clearInterval"
   and "clearTimeout" implementation where they
   may leak async ops

* move "cli/js/worker_test.ts" to "cli/tests/worker_test.ts" and 
  run as integration test; workers leak ops because of missing
  "terminate" implementation
2020-03-03 18:22:53 +01:00

13 lines
451 B
TypeScript

// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { testPerm, assert, createResolvable } from "./test_util.ts";
testPerm({ hrtime: false }, async function performanceNow(): Promise<void> {
const resolvable = createResolvable();
const start = performance.now();
setTimeout((): void => {
const end = performance.now();
assert(end - start >= 10);
resolvable.resolve();
}, 10);
await resolvable;
});