diff --git a/test/internet/test-dgram-broadcast-multi-process.js b/test/internet/test-dgram-broadcast-multi-process.js index 60bf46b5dc0b71..191967ce492be7 100644 --- a/test/internet/test-dgram-broadcast-multi-process.js +++ b/test/internet/test-dgram-broadcast-multi-process.js @@ -94,8 +94,7 @@ if (process.argv[2] !== 'child') { //all child process are listening, so start sending sendSocket.sendNext(); } - } - else if (msg.message) { + } else if (msg.message) { worker.messagesReceived.push(msg.message); if (worker.messagesReceived.length === messages.length) { diff --git a/test/parallel/test-child-process-fork-exec-path.js b/test/parallel/test-child-process-fork-exec-path.js index 35a730b0da6c42..ee62b2123f2e2f 100644 --- a/test/parallel/test-child-process-fork-exec-path.js +++ b/test/parallel/test-child-process-fork-exec-path.js @@ -12,13 +12,11 @@ if (process.env.FORK) { assert.equal(process.argv[0], copyPath); process.send(msg); process.exit(); -} -else { +} else { common.refreshTmpDir(); try { fs.unlinkSync(copyPath); - } - catch (e) { + } catch (e) { if (e.code !== 'ENOENT') throw e; } fs.writeFileSync(copyPath, fs.readFileSync(nodePath)); diff --git a/test/parallel/test-child-process-recv-handle.js b/test/parallel/test-child-process-recv-handle.js index 441740e2d483bd..6491dd032e0fcb 100644 --- a/test/parallel/test-child-process-recv-handle.js +++ b/test/parallel/test-child-process-recv-handle.js @@ -49,14 +49,12 @@ function worker() { if (n === 1) { assert.equal(msg, 'one'); assert.equal(handle, undefined); - } - else if (n === 2) { + } else if (n === 2) { assert.equal(msg, 'two'); assert.equal(typeof handle, 'object'); // Also matches null, therefore... assert.ok(handle); // also check that it's truthy. handle.close(); - } - else if (n === 3) { + } else if (n === 3) { assert.equal(msg, 'three'); assert.equal(handle, undefined); process.exit(); diff --git a/test/parallel/test-cluster-basic.js b/test/parallel/test-cluster-basic.js index 5a5efabbab821a..b48ae4de4643d8 100644 --- a/test/parallel/test-cluster-basic.js +++ b/test/parallel/test-cluster-basic.js @@ -18,9 +18,7 @@ if (cluster.isWorker) { http.Server(function() { }).listen(common.PORT, '127.0.0.1'); -} - -else if (cluster.isMaster) { +} else if (cluster.isMaster) { var checks = { cluster: { diff --git a/test/parallel/test-cluster-bind-privileged-port.js b/test/parallel/test-cluster-bind-privileged-port.js index 9f4ef8ee5e8b81..4aed915fa3524f 100644 --- a/test/parallel/test-cluster-bind-privileged-port.js +++ b/test/parallel/test-cluster-bind-privileged-port.js @@ -18,8 +18,7 @@ if (cluster.isMaster) { cluster.fork().on('exit', common.mustCall(function(exitCode) { assert.equal(exitCode, 0); })); -} -else { +} else { var s = net.createServer(common.fail); s.listen(42, common.fail.bind(null, 'listen should have failed')); s.on('error', common.mustCall(function(err) { diff --git a/test/parallel/test-cluster-bind-twice.js b/test/parallel/test-cluster-bind-twice.js index 6328f588b30b2a..8bd57a3fba43c8 100644 --- a/test/parallel/test-cluster-bind-twice.js +++ b/test/parallel/test-cluster-bind-twice.js @@ -64,8 +64,7 @@ if (!id) { process.on('exit', function() { assert(ok); }); -} -else if (id === 'one') { +} else if (id === 'one') { if (cluster.isMaster) return startWorker(); http.createServer(common.fail).listen(common.PORT, function() { @@ -75,8 +74,7 @@ else if (id === 'one') { process.on('message', function(m) { if (m === 'QUIT') process.exit(); }); -} -else if (id === 'two') { +} else if (id === 'two') { if (cluster.isMaster) return startWorker(); let ok = false; @@ -96,8 +94,7 @@ else if (id === 'two') { ok = true; }); }); -} -else { +} else { assert(0); // bad command line argument } diff --git a/test/parallel/test-cluster-eaddrinuse.js b/test/parallel/test-cluster-eaddrinuse.js index 7947fb9bab8e05..88b6de2dde4230 100644 --- a/test/parallel/test-cluster-eaddrinuse.js +++ b/test/parallel/test-cluster-eaddrinuse.js @@ -21,8 +21,7 @@ if (id === 'undefined') { }); }); }); -} -else if (id === 'worker') { +} else if (id === 'worker') { let server = net.createServer(common.fail); server.listen(common.PORT, common.fail); server.on('error', common.mustCall(function(e) { @@ -36,7 +35,6 @@ else if (id === 'worker') { })); }); })); -} -else { +} else { assert(0); // Bad argument. } diff --git a/test/parallel/test-cluster-listening-port.js b/test/parallel/test-cluster-listening-port.js index dc048c891c7b8c..810364a92648e4 100644 --- a/test/parallel/test-cluster-listening-port.js +++ b/test/parallel/test-cluster-listening-port.js @@ -19,7 +19,6 @@ if (cluster.isMaster) { // ensure that the 'listening' handler has been called assert(port); }); -} -else { +} else { net.createServer(common.fail).listen(0); } diff --git a/test/parallel/test-cluster-message.js b/test/parallel/test-cluster-message.js index 427c3058903d5d..cfe3bf801edeb7 100644 --- a/test/parallel/test-cluster-message.js +++ b/test/parallel/test-cluster-message.js @@ -40,9 +40,7 @@ if (cluster.isWorker) { }); server.listen(common.PORT, '127.0.0.1'); -} - -else if (cluster.isMaster) { +} else if (cluster.isMaster) { var checks = { global: { diff --git a/test/parallel/test-cluster-net-listen.js b/test/parallel/test-cluster-net-listen.js index c79d4cf1a27dad..81bd1641d3b761 100644 --- a/test/parallel/test-cluster-net-listen.js +++ b/test/parallel/test-cluster-net-listen.js @@ -14,8 +14,7 @@ if (cluster.isMaster) { process.on('exit', function() { assert.equal(worker, null); }); -} -else { +} else { // listen() without port should not trigger a libuv assert net.createServer(common.fail).listen(process.exit); } diff --git a/test/parallel/test-cluster-shared-handle-bind-error.js b/test/parallel/test-cluster-shared-handle-bind-error.js index 288b4b443a45bc..f5a08a1ed8481e 100644 --- a/test/parallel/test-cluster-shared-handle-bind-error.js +++ b/test/parallel/test-cluster-shared-handle-bind-error.js @@ -16,8 +16,7 @@ if (cluster.isMaster) { server.close(); })); }); -} -else { +} else { var s = net.createServer(common.fail); s.listen(common.PORT, common.fail.bind(null, 'listen should have failed')); s.on('error', common.mustCall(function(err) { diff --git a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js index 90bab2febe41e7..9dc0e4ea773137 100644 --- a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js +++ b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js @@ -20,8 +20,7 @@ if (cluster.isMaster) { cluster.fork().on('exit', common.mustCall(function(exitCode) { assert.equal(exitCode, 0); })); -} -else { +} else { var s = net.createServer(common.fail); s.listen(42, common.fail.bind(null, 'listen should have failed')); s.on('error', common.mustCall(function(err) { diff --git a/test/parallel/test-cluster-uncaught-exception.js b/test/parallel/test-cluster-uncaught-exception.js index 04eac2e8ce63d4..1f04b71f01ac73 100644 --- a/test/parallel/test-cluster-uncaught-exception.js +++ b/test/parallel/test-cluster-uncaught-exception.js @@ -23,8 +23,7 @@ if (isTestRunner) { master.on('exit', function(code) { exitCode = code; }); -} -else if (cluster.isMaster) { +} else if (cluster.isMaster) { process.on('uncaughtException', function() { process.nextTick(function() { process.exit(MAGIC_EXIT_CODE); @@ -33,7 +32,6 @@ else if (cluster.isMaster) { cluster.fork(); throw new Error('kill master'); -} -else { // worker +} else { // worker process.exit(); } diff --git a/test/parallel/test-cluster-worker-death.js b/test/parallel/test-cluster-worker-death.js index 65da9865b0dd2d..aec745b8b71f6d 100644 --- a/test/parallel/test-cluster-worker-death.js +++ b/test/parallel/test-cluster-worker-death.js @@ -5,8 +5,7 @@ var cluster = require('cluster'); if (!cluster.isMaster) { process.exit(42); -} -else { +} else { var seenExit = 0; var seenDeath = 0; var worker = cluster.fork(); diff --git a/test/parallel/test-crypto-authenticated.js b/test/parallel/test-crypto-authenticated.js index ae1599c1fce2f3..db0de9e2338a07 100644 --- a/test/parallel/test-crypto-authenticated.js +++ b/test/parallel/test-crypto-authenticated.js @@ -362,8 +362,7 @@ for (var i in TEST_CASES) { (function() { if (!test.password) return; if (common.hasFipsCrypto) { - assert.throws(function() - { crypto.createCipher(test.algo, test.password); }, + assert.throws(() => { crypto.createCipher(test.algo, test.password); }, /not supported in FIPS mode/); } else { var encrypt = crypto.createCipher(test.algo, test.password); @@ -383,8 +382,7 @@ for (var i in TEST_CASES) { (function() { if (!test.password) return; if (common.hasFipsCrypto) { - assert.throws(function() - { crypto.createDecipher(test.algo, test.password); }, + assert.throws(() => { crypto.createDecipher(test.algo, test.password); }, /not supported in FIPS mode/); } else { var decrypt = crypto.createDecipher(test.algo, test.password); @@ -415,9 +413,9 @@ for (var i in TEST_CASES) { 'ipxp9a6i1Mb4USb4', '6fKjEjR3Vl30EUYC'); encrypt.update('blah', 'ascii'); encrypt.final(); - assert.throws(function() { encrypt.getAuthTag(); }, / state/); - assert.throws(function() { - encrypt.setAAD(new Buffer('123', 'ascii')); }, / state/); + assert.throws(() => { encrypt.getAuthTag(); }, / state/); + assert.throws(() => { encrypt.setAAD(Buffer.from('123', 'ascii')); }, + / state/); })(); (function() { @@ -431,9 +429,9 @@ for (var i in TEST_CASES) { (function() { // trying to set tag on encryption object: var encrypt = crypto.createCipheriv(test.algo, - new Buffer(test.key, 'hex'), new Buffer(test.iv, 'hex')); - assert.throws(function() { - encrypt.setAuthTag(new Buffer(test.tag, 'hex')); }, / state/); + Buffer.from(test.key, 'hex'), Buffer.from(test.iv, 'hex')); + assert.throws(() => { encrypt.setAuthTag(Buffer.from(test.tag, 'hex')); }, + / state/); })(); (function() { diff --git a/test/parallel/test-debugger-util-regression.js b/test/parallel/test-debugger-util-regression.js index cf32ec3fa668e9..5d2446c6bd40ad 100644 --- a/test/parallel/test-debugger-util-regression.js +++ b/test/parallel/test-debugger-util-regression.js @@ -38,12 +38,10 @@ proc.stdout.on('data', (data) => { stdout.includes('> 4') && nextCount < 4) { nextCount++; proc.stdin.write('n\n'); - } - else if (stdout.includes('{ a: \'b\' }')) { + } else if (stdout.includes('{ a: \'b\' }')) { clearTimeout(timer); proc.stdin.write('.exit\n'); - } - else if (stdout.includes('program terminated')) { + } else if (stdout.includes('program terminated')) { // Catch edge case present in v4.x // process will terminate after call to util.inspect common.fail('the program should not terminate'); diff --git a/test/parallel/test-fs-open.js b/test/parallel/test-fs-open.js index 0818f2b7f63d8f..e2c9d327cc731a 100644 --- a/test/parallel/test-fs-open.js +++ b/test/parallel/test-fs-open.js @@ -8,8 +8,7 @@ try { // should throw ENOENT, not EBADF // see https://github.com/joyent/node/pull/1228 fs.openSync('/path/to/file/that/does/not/exist', 'r'); -} -catch (e) { +} catch (e) { assert.equal(e.code, 'ENOENT'); caughtException = true; } diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 46fbbd85877a81..e58cf7ba6ca52e 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -53,8 +53,7 @@ function asynctest(testBlock, args, callback, assertBlock) { if (assertBlock) { try { ignoreError = assertBlock.apply(assertBlock, arguments); - } - catch (e) { + } catch (e) { err = e; } } diff --git a/test/parallel/test-http-server-stale-close.js b/test/parallel/test-http-server-stale-close.js index 7430566dfd17e2..819f503de547e4 100644 --- a/test/parallel/test-http-server-stale-close.js +++ b/test/parallel/test-http-server-stale-close.js @@ -13,8 +13,7 @@ if (process.env.NODE_TEST_FORK_PORT) { }, process.exit); req.write('BAM'); req.end(); -} -else { +} else { var server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Length': '42'}); req.pipe(res); diff --git a/test/parallel/test-next-tick-errors.js b/test/parallel/test-next-tick-errors.js index 5898762eeb5e5a..d3e6d5dcabf14d 100644 --- a/test/parallel/test-next-tick-errors.js +++ b/test/parallel/test-next-tick-errors.js @@ -24,8 +24,7 @@ process.on('uncaughtException', function() { if (!exceptionHandled) { exceptionHandled = true; order.push('B'); - } - else { + } else { // If we get here then the first process.nextTick got called twice order.push('OOPS!'); } diff --git a/test/parallel/test-process-argv-0.js b/test/parallel/test-process-argv-0.js index 3299ec74ea7dd4..c3aacb60fa5403 100644 --- a/test/parallel/test-process-argv-0.js +++ b/test/parallel/test-process-argv-0.js @@ -16,7 +16,6 @@ if (process.argv[2] !== 'child') { process.on('exit', function() { assert.equal(childArgv0, process.execPath); }); -} -else { +} else { process.stdout.write(process.argv[0]); } diff --git a/test/parallel/test-repl-domain.js b/test/parallel/test-repl-domain.js index adc8478beef4af..759eb61405bae4 100644 --- a/test/parallel/test-repl-domain.js +++ b/test/parallel/test-repl-domain.js @@ -11,8 +11,7 @@ putIn.write = function(data) { // give a false negative. Don't throw, just print and exit. if (data === 'OK\n') { console.log('ok'); - } - else { + } else { console.error(data); process.exit(1); } diff --git a/test/parallel/test-vm-context.js b/test/parallel/test-vm-context.js index 48bceb14593679..06a891b5579b87 100644 --- a/test/parallel/test-vm-context.js +++ b/test/parallel/test-vm-context.js @@ -32,8 +32,7 @@ console.error('test runInContext signature'); var gh1140Exception; try { vm.runInContext('throw new Error()', context, 'expected-filename.js'); -} -catch (e) { +} catch (e) { gh1140Exception = e; assert.ok(/expected-filename/.test(e.stack), 'expected appearance of filename in Error stack'); diff --git a/test/pummel/test-fs-watch-file-slow.js b/test/pummel/test-fs-watch-file-slow.js index cb3bc5e579b86b..508de487f6dc23 100644 --- a/test/pummel/test-fs-watch-file-slow.js +++ b/test/pummel/test-fs-watch-file-slow.js @@ -11,8 +11,7 @@ var nevents = 0; try { fs.unlinkSync(FILENAME); -} -catch (e) { +} catch (e) { // swallow } diff --git a/test/pummel/test-regress-GH-814.js b/test/pummel/test-regress-GH-814.js index 820903d68873e7..7375eb98c6bf84 100644 --- a/test/pummel/test-regress-GH-814.js +++ b/test/pummel/test-regress-GH-814.js @@ -44,15 +44,13 @@ var timeToQuit = Date.now() + 8e3; //Test during no more than this seconds. if (bufPool.push(nuBuf) > 100) { bufPool.length = 0; } - } - else { + } else { throw new Error("Buffer GC'ed test -> FAIL"); } if (Date.now() < timeToQuit) { process.nextTick(main); - } - else { + } else { tail.kill(); console.log("Buffer GC'ed test -> PASS (OK)"); }