mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
test: update test-cluster-worker-events to use arrow functions
PR-URL: https://github.com/nodejs/node/pull/23469 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
3d284c856c
commit
434ca4ff27
1 file changed
+16
-16
@@ -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);
|
||||
});
|
||||
Reference in new issue
Block a user