diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-03-11 22:59:42 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-11 22:59:42 +0000 |
commit | 47f318230fe9b4870610cbfbaae424a28818a8d0 (patch) | |
tree | 9ded54b81f6d2583ff263e292f889851d41ca975 /tests/unit_node/worker_threads_test.ts | |
parent | a77b2987bc90879af30a39ba274df9061cc7fbae (diff) |
test(ext/node): add worker_threads test for SharedArrayBuffer (#22850)
Follow up to https://github.com/denoland/deno/pull/22815
Diffstat (limited to 'tests/unit_node/worker_threads_test.ts')
-rw-r--r-- | tests/unit_node/worker_threads_test.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/unit_node/worker_threads_test.ts b/tests/unit_node/worker_threads_test.ts index bc451e33f..1ded9a591 100644 --- a/tests/unit_node/worker_threads_test.ts +++ b/tests/unit_node/worker_threads_test.ts @@ -218,3 +218,23 @@ Deno.test({ clearTimeout(timeout); }, }); + +Deno.test({ + name: "[worker_threads] SharedArrayBuffer", + async fn() { + const sab = new SharedArrayBuffer(Uint8Array.BYTES_PER_ELEMENT); + const uint = new Uint8Array(sab); + const worker = new workerThreads.Worker( + new URL("./testdata/worker_threads2.mjs", import.meta.url), + { + workerData: { sharedArrayBuffer: sab }, + }, + ); + worker.postMessage("Hello"); + if ((await once(worker, "message"))[0] != "Hello") throw new Error(); + await new Promise((resolve) => setTimeout(resolve, 100)); + worker.terminate(); + if (uint[0] != 1) throw new Error(); + }, + sanitizeResources: false, +}); |