MCPcopy Create free account
hub / github.com/denoland/std / assertBlocks

Function assertBlocks

async/unstable_semaphore_test.ts:13–24  ·  view source on GitHub ↗

Helper to assert that a promise is blocked until released

(
  acquirePromise: Promise<unknown>,
  release: () => void,
)

Source from the content-addressed store, hash-verified

11
12/** Helper to assert that a promise is blocked until released */
13async function assertBlocks(
14 acquirePromise: Promise<unknown>,
15 release: () => void,
16): Promise<void> {
17 let blocked = true;
18 const p = acquirePromise.then(() => blocked = false);
19 await Promise.resolve();
20 assert(blocked);
21 release();
22 await p;
23 assertFalse(blocked);
24}
25
26Deno.test("Semaphore constructor throws for non-positive max", () => {
27 assertThrows(() => new Semaphore(0), TypeError);

Callers 1

Calls 2

assertFunction · 0.90
assertFalseFunction · 0.90

Tested by

no test coverage detected