From 4ffa138c8131577a204d42d50609ac18b561937a Mon Sep 17 00:00:00 2001 From: himself65 Date: Fri, 27 Mar 2020 00:46:10 +0800 Subject: [PATCH] test: refactor test-worker PR-URL: https://github.com/nodejs/node/pull/32509 Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Jiawen Geng --- test/parallel/test-worker.js | 6 ++++-- test/parallel/test-worker.mjs | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-worker.js b/test/parallel/test-worker.js index 9c388955483b94..9154aaa12baee1 100644 --- a/test/parallel/test-worker.js +++ b/test/parallel/test-worker.js @@ -3,15 +3,17 @@ const common = require('../common'); const assert = require('assert'); const { Worker, isMainThread, parentPort } = require('worker_threads'); +const kTestString = 'Hello, world!'; + if (isMainThread) { const w = new Worker(__filename); w.on('message', common.mustCall((message) => { - assert.strictEqual(message, 'Hello, world!'); + assert.strictEqual(message, kTestString); })); } else { setImmediate(() => { process.nextTick(() => { - parentPort.postMessage('Hello, world!'); + parentPort.postMessage(kTestString); }); }); } diff --git a/test/parallel/test-worker.mjs b/test/parallel/test-worker.mjs index f297d562340245..4ee3f7dc96fa4c 100644 --- a/test/parallel/test-worker.mjs +++ b/test/parallel/test-worker.mjs @@ -2,17 +2,17 @@ import { mustCall } from '../common/index.mjs'; import assert from 'assert'; import { Worker, isMainThread, parentPort } from 'worker_threads'; -const TEST_STRING = 'Hello, world!'; +const kTestString = 'Hello, world!'; if (isMainThread) { const w = new Worker(new URL(import.meta.url)); w.on('message', mustCall((message) => { - assert.strictEqual(message, TEST_STRING); + assert.strictEqual(message, kTestString); })); } else { setImmediate(() => { process.nextTick(() => { - parentPort.postMessage(TEST_STRING); + parentPort.postMessage(kTestString); }); }); }