diff options
Diffstat (limited to 'tests/specs/node/worker_threads_cache')
| -rw-r--r-- | tests/specs/node/worker_threads_cache/__test__.jsonc | 5 | ||||
| -rw-r--r-- | tests/specs/node/worker_threads_cache/main.out | 2 | ||||
| -rw-r--r-- | tests/specs/node/worker_threads_cache/main.ts | 13 |
3 files changed, 20 insertions, 0 deletions
diff --git a/tests/specs/node/worker_threads_cache/__test__.jsonc b/tests/specs/node/worker_threads_cache/__test__.jsonc new file mode 100644 index 000000000..a47fed572 --- /dev/null +++ b/tests/specs/node/worker_threads_cache/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "tempDir": true, + "args": "run -A main.ts", + "output": "main.out" +} diff --git a/tests/specs/node/worker_threads_cache/main.out b/tests/specs/node/worker_threads_cache/main.out new file mode 100644 index 000000000..d14c028e5 --- /dev/null +++ b/tests/specs/node/worker_threads_cache/main.out @@ -0,0 +1,2 @@ +[Module: null prototype] { default: true } +[Module: null prototype] { default: false } diff --git a/tests/specs/node/worker_threads_cache/main.ts b/tests/specs/node/worker_threads_cache/main.ts new file mode 100644 index 000000000..9703ac8f6 --- /dev/null +++ b/tests/specs/node/worker_threads_cache/main.ts @@ -0,0 +1,13 @@ +import fs from "node:fs/promises"; +import { isMainThread, Worker } from "node:worker_threads"; + +await fs.writeFile("mod.mjs", "export default " + isMainThread); + +const path = new URL("mod.mjs", import.meta.url); +const i = await import(path.href); +console.log(i); + +if (isMainThread) { + const worker = new Worker(new URL("main.ts", import.meta.url)); + worker.on("message", (msg) => console.log(msg)); +} |
