11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst { Worker, isMainThread, parentPort } = require('worker_threads'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst kTestString = 'Hello, world!'; 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciif (isMainThread) { 91cb0ef41Sopenharmony_ci const w = new Worker(__filename); 101cb0ef41Sopenharmony_ci w.on('message', common.mustCall((message) => { 111cb0ef41Sopenharmony_ci assert.strictEqual(message, kTestString); 121cb0ef41Sopenharmony_ci })); 131cb0ef41Sopenharmony_ci} else { 141cb0ef41Sopenharmony_ci setImmediate(() => { 151cb0ef41Sopenharmony_ci process.nextTick(() => { 161cb0ef41Sopenharmony_ci parentPort.postMessage(kTestString); 171cb0ef41Sopenharmony_ci }); 181cb0ef41Sopenharmony_ci }); 191cb0ef41Sopenharmony_ci} 20