From 22ce1680cb1c2a54add76d8ac8f917fc4a17fe43 Mon Sep 17 00:00:00 2001 From: Deverick Date: Thu, 20 Oct 2016 23:32:34 -0500 Subject: [PATCH 1/2] test: Refactor to ES6 This commit replaces function expressions with ES6 arrow functions as well as improve the comparison operator to check if operands are of same types. --- .../test-cluster-uncaught-exception.js | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/test/parallel/test-cluster-uncaught-exception.js b/test/parallel/test-cluster-uncaught-exception.js index 1091b6fec759a1..44430b7c126189 100644 --- a/test/parallel/test-cluster-uncaught-exception.js +++ b/test/parallel/test-cluster-uncaught-exception.js @@ -4,26 +4,20 @@ // https://github.com/joyent/node/issues/2556 const common = require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); -var fork = require('child_process').fork; +const assert = require('assert'); +const cluster = require('cluster'); +const fork = require('child_process').fork; -var MAGIC_EXIT_CODE = 42; +const MAGIC_EXIT_CODE = 42; -var isTestRunner = process.argv[2] != 'child'; +const isTestRunner = process.argv[2] !== 'child'; if (isTestRunner) { var master = fork(__filename, ['child']); - master.on('exit', common.mustCall(function(code) { - assert.strictEqual(code, MAGIC_EXIT_CODE); - })); -} else if (cluster.isMaster) { - process.on('uncaughtException', function() { - process.nextTick(function() { - process.exit(MAGIC_EXIT_CODE); - }); - }); + master.on('exit', common.mustCall(code => assert.strictEqual(code, MAGIC_EXIT_CODE))); +} else if (cluster.isMaster) { + process.on('uncaughtException', () => process.nextTick(() => process.exit(MAGIC_EXIT_CODE))); cluster.fork(); throw new Error('kill master'); } else { // worker From bacf0f94be4d6255bebafcc55faae7b16d646478 Mon Sep 17 00:00:00 2001 From: Deverick Date: Sat, 22 Oct 2016 18:58:22 -0500 Subject: [PATCH 2/2] Fix Line Length Correction made to previous commit, correcting a line length restriction. --- test/parallel/test-cluster-uncaught-exception.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-cluster-uncaught-exception.js b/test/parallel/test-cluster-uncaught-exception.js index 44430b7c126189..3a4d7136205ce0 100644 --- a/test/parallel/test-cluster-uncaught-exception.js +++ b/test/parallel/test-cluster-uncaught-exception.js @@ -13,11 +13,14 @@ const MAGIC_EXIT_CODE = 42; const isTestRunner = process.argv[2] !== 'child'; if (isTestRunner) { - var master = fork(__filename, ['child']); - master.on('exit', common.mustCall(code => assert.strictEqual(code, MAGIC_EXIT_CODE))); - + const master = fork(__filename, ['child']); + master.on('exit', common.mustCall( + (code) => assert.strictEqual(code, MAGIC_EXIT_CODE) + )); } else if (cluster.isMaster) { - process.on('uncaughtException', () => process.nextTick(() => process.exit(MAGIC_EXIT_CODE))); + process.on('uncaughtException', () => process.nextTick( + () => process.exit(MAGIC_EXIT_CODE) + )); cluster.fork(); throw new Error('kill master'); } else { // worker