From 2d0532e7c121ed210e6fc7d868288841d0994c44 Mon Sep 17 00:00:00 2001 From: "S. Everett Abbott" Date: Fri, 12 Oct 2018 09:56:49 -0700 Subject: [PATCH] test: update test-cluster-worker-events to use arrow functions PR-URL: https://github.com/nodejs/node/pull/23469 Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell --- test/parallel/test-cluster-worker-events.js | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/parallel/test-cluster-worker-events.js b/test/parallel/test-cluster-worker-events.js index 91e716285dc2b8..3b156addedc63f 100644 --- a/test/parallel/test-cluster-worker-events.js +++ b/test/parallel/test-cluster-worker-events.js @@ -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); }); @@ -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); +});