11cb0ef41Sopenharmony_ciimport { mustCall } from '../common/index.mjs'; 21cb0ef41Sopenharmony_ciimport assert from 'assert'; 31cb0ef41Sopenharmony_ciimport { Worker, isMainThread, parentPort } from 'worker_threads'; 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst kTestString = 'Hello, world!'; 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciif (isMainThread) { 81cb0ef41Sopenharmony_ci const w = new Worker(new URL(import.meta.url)); 91cb0ef41Sopenharmony_ci w.on('message', mustCall((message) => { 101cb0ef41Sopenharmony_ci assert.strictEqual(message, kTestString); 111cb0ef41Sopenharmony_ci })); 121cb0ef41Sopenharmony_ci} else { 131cb0ef41Sopenharmony_ci setImmediate(() => { 141cb0ef41Sopenharmony_ci process.nextTick(() => { 151cb0ef41Sopenharmony_ci parentPort.postMessage(kTestString); 161cb0ef41Sopenharmony_ci }); 171cb0ef41Sopenharmony_ci }); 181cb0ef41Sopenharmony_ci} 19