Skip to content

Commit

Permalink
test: update test-cluster-worker-events to use arrow functions
Browse files Browse the repository at this point in the history
PR-URL: #23469
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
S. Everett Abbott authored and jasnell committed Oct 17, 2018
1 parent ec8fbfb commit 2d0532e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions test/parallel/test-cluster-worker-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (cluster.isMaster) {

const worker = cluster.fork();

worker.on('exit', function(code) {
worker.on('exit', (code) => {
assert.strictEqual(code, OK);
process.exit(0);
});
Expand All @@ -49,31 +49,31 @@ assert(cluster.isWorker);
let sawProcess;
let sawWorker;

process.on('message', function(m) {
assert(!sawProcess);
sawProcess = true;
check(m);
});

cluster.worker.on('message', function(m) {
assert(!sawWorker);
sawWorker = true;
check(m);
});

const messages = [];

function check(m) {
const check = (m) => {
messages.push(m);

if (messages.length < 2) return;

assert.deepStrictEqual(messages[0], messages[1]);

cluster.worker.once('error', function(e) {
cluster.worker.once('error', (e) => {
assert.strictEqual(e, 'HI');
process.exit(OK);
});

process.emit('error', 'HI');
}
};

process.on('message', (m) => {
assert(!sawProcess);
sawProcess = true;
check(m);
});

cluster.worker.on('message', (m) => {
assert(!sawWorker);
sawWorker = true;
check(m);
});

0 comments on commit 2d0532e

Please sign in to comment.