diff --git a/test/common.js b/test/common.js index bb7a3652f38a02..028a171d01615d 100644 --- a/test/common.js +++ b/test/common.js @@ -437,7 +437,7 @@ exports.getServiceName = function getServiceName(port, protocol) { if (matches && matches.length > 1) { serviceName = matches[1]; } - } catch(e) { + } catch (e) { console.error('Cannot read file: ', etcServicesFileName); return undefined; } diff --git a/test/debugger/test-debugger-repl-break-in-module.js b/test/debugger/test-debugger-repl-break-in-module.js index e3f998eb6465d3..e439e08c24cd30 100644 --- a/test/debugger/test-debugger-repl-break-in-module.js +++ b/test/debugger/test-debugger-repl-break-in-module.js @@ -20,8 +20,8 @@ repl.addTest('sb(")^$*+?}{|][(.js\\\\", 1)', [ // continue - the breakpoint should be triggered repl.addTest('c', [ - /break in .*[\\\/]mod\.js:23/, - /21/, /22/, /23/, /24/, /25/ + /break in .*[\\\/]mod\.js:23/, + /21/, /22/, /23/, /24/, /25/ ]); // -- RESTORE BREAKPOINT ON RESTART -- diff --git a/test/debugger/test-debugger-repl-restart.js b/test/debugger/test-debugger-repl-restart.js index 584cb098bf02e6..206cd2e7417627 100644 --- a/test/debugger/test-debugger-repl-restart.js +++ b/test/debugger/test-debugger-repl-restart.js @@ -4,7 +4,7 @@ var repl = require('./helper-debugger-repl.js'); repl.startDebugger('breakpoints.js'); var linesWithBreakpoint = [ - /1/, /2/, /3/, /4/, /5/, /\* 6/ + /1/, /2/, /3/, /4/, /5/, /\* 6/ ]; // We slice here, because addTest will change the given array. repl.addTest('sb(6)', linesWithBreakpoint.slice()); diff --git a/test/gc/test-http-client-connaborted.js b/test/gc/test-http-client-connaborted.js index 20a4b38481ae0c..b5aafb7c9a36ab 100644 --- a/test/gc/test-http-client-connaborted.js +++ b/test/gc/test-http-client-connaborted.js @@ -6,15 +6,15 @@ function serverHandler(req, res) { res.connection.destroy(); } -var http = require('http'), - weak = require('weak'), - done = 0, - count = 0, - countGC = 0, - todo = 500, - common = require('../common'), - assert = require('assert'), - PORT = common.PORT; +const http = require('http'); +const weak = require('weak'); +const common = require('../common'); +const assert = require('assert'); +const PORT = common.PORT; +const todo = 500; +let done = 0; +let count = 0; +let countGC = 0; console.log('We should do ' + todo + ' requests'); diff --git a/test/gc/test-http-client-onerror.js b/test/gc/test-http-client-onerror.js index 7e50683c6633e5..5c2a9cc7b13350 100644 --- a/test/gc/test-http-client-onerror.js +++ b/test/gc/test-http-client-onerror.js @@ -8,15 +8,15 @@ function serverHandler(req, res) { res.end('Hello World\n'); } -var http = require('http'), - weak = require('weak'), - done = 0, - count = 0, - countGC = 0, - todo = 500, - common = require('../common'), - assert = require('assert'), - PORT = common.PORT; +const http = require('http'); +const weak = require('weak'); +const common = require('../common'); +const assert = require('assert'); +const PORT = common.PORT; +const todo = 500; +let done = 0; +let count = 0; +let countGC = 0; console.log('We should do ' + todo + ' requests'); diff --git a/test/gc/test-http-client-timeout.js b/test/gc/test-http-client-timeout.js index c84581b5c8e54a..c3ab9dc22cbb39 100644 --- a/test/gc/test-http-client-timeout.js +++ b/test/gc/test-http-client-timeout.js @@ -10,15 +10,15 @@ function serverHandler(req, res) { }, 100); } -var http = require('http'), - weak = require('weak'), - done = 0, - count = 0, - countGC = 0, - todo = 550, - common = require('../common'), - assert = require('assert'), - PORT = common.PORT; +const http = require('http'); +const weak = require('weak'); +const common = require('../common'); +const assert = require('assert'); +const PORT = common.PORT; +const todo = 550; +let done = 0; +let count = 0; +let countGC = 0; console.log('We should do ' + todo + ' requests'); diff --git a/test/gc/test-http-client.js b/test/gc/test-http-client.js index 7c3259d38b0ba1..9d210e946ed440 100644 --- a/test/gc/test-http-client.js +++ b/test/gc/test-http-client.js @@ -6,15 +6,15 @@ function serverHandler(req, res) { res.end('Hello World\n'); } -var http = require('http'), - weak = require('weak'), - done = 0, - count = 0, - countGC = 0, - todo = 500, - common = require('../common'), - assert = require('assert'), - PORT = common.PORT; +const http = require('http'); +const weak = require('weak'); +const common = require('../common'); +const assert = require('assert'); +const PORT = common.PORT; +const todo = 500; +let done = 0; +let count = 0; +let countGC = 0; console.log('We should do ' + todo + ' requests'); diff --git a/test/gc/test-net-timeout.js b/test/gc/test-net-timeout.js index 6c3b4f245be452..26e03786a68542 100644 --- a/test/gc/test-net-timeout.js +++ b/test/gc/test-net-timeout.js @@ -17,15 +17,15 @@ function serverHandler(sock) { }, 100); } -var net = require('net'), - weak = require('weak'), - done = 0, - count = 0, - countGC = 0, - todo = 500, - common = require('../common'), - assert = require('assert'), - PORT = common.PORT; +const net = require('net'); +const weak = require('weak'); +const common = require('../common'); +const assert = require('assert'); +const PORT = common.PORT; +const todo = 500; +let done = 0; +let count = 0; +let countGC = 0; console.log('We should do ' + todo + ' requests'); diff --git a/test/internet/test-dgram-broadcast-multi-process.js b/test/internet/test-dgram-broadcast-multi-process.js index a24aabcf1b4d0f..344f6506afdeb1 100644 --- a/test/internet/test-dgram-broadcast-multi-process.js +++ b/test/internet/test-dgram-broadcast-multi-process.js @@ -1,19 +1,19 @@ 'use strict'; -var common = require('../common'), - assert = require('assert'), - dgram = require('dgram'), - util = require('util'), - networkInterfaces = require('os').networkInterfaces(), - Buffer = require('buffer').Buffer, - fork = require('child_process').fork, - LOCAL_BROADCAST_HOST = '255.255.255.255', - TIMEOUT = common.platformTimeout(5000), - messages = [ - new Buffer('First message to send'), - new Buffer('Second message to send'), - new Buffer('Third message to send'), - new Buffer('Fourth message to send') - ]; +const common = require('../common'); +const assert = require('assert'); +const dgram = require('dgram'); +const util = require('util'); +const networkInterfaces = require('os').networkInterfaces(); +const Buffer = require('buffer').Buffer; +const fork = require('child_process').fork; +const LOCAL_BROADCAST_HOST = '255.255.255.255'; +const TIMEOUT = common.platformTimeout(5000); +const messages = [ + new Buffer('First message to send'), + new Buffer('Second message to send'), + new Buffer('Third message to send'), + new Buffer('Fourth message to send') +]; if (common.inFreeBSDJail) { console.log('1..0 # Skipped: in a FreeBSD jail'); @@ -34,13 +34,13 @@ get_bindAddress: for (var name in networkInterfaces) { assert.ok(bindAddress); if (process.argv[2] !== 'child') { - var workers = {}, - listeners = 3, - listening = 0, - dead = 0, - i = 0, - done = 0, - timer = null; + const workers = {}; + const listeners = 3; + let listening = 0; + let dead = 0; + let i = 0; + let done = 0; + let timer = null; //exit the test if it doesn't succeed within TIMEOUT timer = setTimeout(function() { @@ -166,15 +166,21 @@ if (process.argv[2] !== 'child') { return; } - sendSocket.send(buf, 0, buf.length, - common.PORT, LOCAL_BROADCAST_HOST, function(err) { - if (err) throw err; - console.error('[PARENT] sent %s to %s:%s', - util.inspect(buf.toString()), - LOCAL_BROADCAST_HOST, common.PORT); - - process.nextTick(sendSocket.sendNext); - }); + sendSocket.send( + buf, + 0, + buf.length, + common.PORT, + LOCAL_BROADCAST_HOST, + function(err) { + if (err) throw err; + console.error('[PARENT] sent %s to %s:%s', + util.inspect(buf.toString()), + LOCAL_BROADCAST_HOST, common.PORT); + + process.nextTick(sendSocket.sendNext); + } + ); }; function killChildren(children) { diff --git a/test/internet/test-dgram-multicast-multi-process.js b/test/internet/test-dgram-multicast-multi-process.js index f72402eef64147..5fa897fc6c35f3 100644 --- a/test/internet/test-dgram-multicast-multi-process.js +++ b/test/internet/test-dgram-multicast-multi-process.js @@ -157,14 +157,20 @@ if (process.argv[2] !== 'child') { return; } - sendSocket.send(buf, 0, buf.length, - common.PORT, LOCAL_BROADCAST_HOST, function(err) { - if (err) throw err; - console.error('[PARENT] sent "%s" to %s:%s', - buf.toString(), - LOCAL_BROADCAST_HOST, common.PORT); - process.nextTick(sendSocket.sendNext); - }); + sendSocket.send( + buf, + 0, + buf.length, + common.PORT, + LOCAL_BROADCAST_HOST, + function(err) { + if (err) throw err; + console.error('[PARENT] sent "%s" to %s:%s', + buf.toString(), + LOCAL_BROADCAST_HOST, common.PORT); + process.nextTick(sendSocket.sendNext); + } + ); }; } diff --git a/test/internet/test-dns-ipv4.js b/test/internet/test-dns-ipv4.js index bdca60d1b4fd5d..07814963924333 100644 --- a/test/internet/test-dns-ipv4.js +++ b/test/internet/test-dns-ipv4.js @@ -1,14 +1,14 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'), - dns = require('dns'), - net = require('net'), - isIPv4 = net.isIPv4; +const common = require('../common'); +const assert = require('assert'); +const dns = require('dns'); +const net = require('net'); +const isIPv4 = net.isIPv4; -var expected = 0, - completed = 0, - running = false, - queue = []; +let expected = 0; +let completed = 0; +let running = false; +const queue = []; function TEST(f) { function next() { @@ -148,19 +148,22 @@ TEST(function test_lookup_localhost_ipv4(done) { }); TEST(function test_lookup_all_ipv4(done) { - var req = dns.lookup('www.google.com', {all: true, family: 4}, - function(err, ips) { - if (err) throw err; - assert.ok(Array.isArray(ips)); - assert.ok(ips.length > 0); - - ips.forEach(function(ip) { - assert.ok(isIPv4(ip.address)); - assert.strictEqual(ip.family, 4); - }); - - done(); - }); + var req = dns.lookup( + 'www.google.com', + {all: true, family: 4}, + function(err, ips) { + if (err) throw err; + assert.ok(Array.isArray(ips)); + assert.ok(ips.length > 0); + + ips.forEach(function(ip) { + assert.ok(isIPv4(ip.address)); + assert.strictEqual(ip.family, 4); + }); + + done(); + } + ); checkWrap(req); }); diff --git a/test/internet/test-dns-ipv6.js b/test/internet/test-dns-ipv6.js index d7c50a1e86b656..38a5c3bf735175 100644 --- a/test/internet/test-dns-ipv6.js +++ b/test/internet/test-dns-ipv6.js @@ -1,14 +1,14 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'), - dns = require('dns'), - net = require('net'), - isIPv6 = net.isIPv6; +const common = require('../common'); +const assert = require('assert'); +const dns = require('dns'); +const net = require('net'); +const isIPv6 = net.isIPv6; -var expected = 0, - completed = 0, - running = false, - queue = []; +let expected = 0; +let completed = 0; +let running = false; +const queue = []; if (!common.hasIPv6) { console.log('1..0 # Skipped: this test, no IPv6 support'); @@ -156,20 +156,23 @@ TEST(function test_lookup_ip_ipv6(done) { }); TEST(function test_lookup_all_ipv6(done) { - var req = dns.lookup('www.google.com', {all: true, family: 6}, - function(err, ips) { - if (err) throw err; - assert.ok(Array.isArray(ips)); - assert.ok(ips.length > 0); - - ips.forEach(function(ip) { - assert.ok(isIPv6(ip.address), - 'Invalid IPv6: ' + ip.address.toString()); - assert.strictEqual(ip.family, 6); - }); - - done(); - }); + var req = dns.lookup( + 'www.google.com', + {all: true, family: 6}, + function(err, ips) { + if (err) throw err; + assert.ok(Array.isArray(ips)); + assert.ok(ips.length > 0); + + ips.forEach(function(ip) { + assert.ok(isIPv6(ip.address), + 'Invalid IPv6: ' + ip.address.toString()); + assert.strictEqual(ip.family, 6); + }); + + done(); + } + ); checkWrap(req); }); diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js index 6448ad7c76b07b..2ac6d1a3dbf264 100644 --- a/test/internet/test-dns.js +++ b/test/internet/test-dns.js @@ -1,16 +1,16 @@ 'use strict'; require('../common'); -var assert = require('assert'), - dns = require('dns'), - net = require('net'), - isIPv4 = net.isIPv4, - isIPv6 = net.isIPv6; -var util = require('util'); - -var expected = 0, - completed = 0, - running = false, - queue = []; +const assert = require('assert'); +const dns = require('dns'); +const net = require('net'); +const isIPv4 = net.isIPv4; +const isIPv6 = net.isIPv6; +const util = require('util'); + +let expected = 0; +let completed = 0; +let running = false; +const queue = []; function TEST(f) { diff --git a/test/parallel/test-bad-unicode.js b/test/parallel/test-bad-unicode.js index d2ce9ef01013db..a4df4ed9ed7005 100644 --- a/test/parallel/test-bad-unicode.js +++ b/test/parallel/test-bad-unicode.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'), - exception = null; +const assert = require('assert'); +let exception = null; try { eval('"\\uc/ef"'); diff --git a/test/parallel/test-buffer.js b/test/parallel/test-buffer.js index 6222e1aa39b9a5..78954796fb6966 100644 --- a/test/parallel/test-buffer.js +++ b/test/parallel/test-buffer.js @@ -852,8 +852,8 @@ Buffer(Buffer(0), 0, 0); // GH-5110 (function() { - var buffer = new Buffer('test'), - string = JSON.stringify(buffer); + const buffer = new Buffer('test'); + const string = JSON.stringify(buffer); assert.equal(string, '{"type":"Buffer","data":[116,101,115,116]}'); diff --git a/test/parallel/test-child-process-double-pipe.js b/test/parallel/test-child-process-double-pipe.js index b791d4164d52b3..2d9805d687635c 100644 --- a/test/parallel/test-child-process-double-pipe.js +++ b/test/parallel/test-child-process-double-pipe.js @@ -1,9 +1,9 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'), - os = require('os'), - util = require('util'), - spawn = require('child_process').spawn; +const common = require('../common'); +const assert = require('assert'); +const os = require('os'); +const util = require('util'); +const spawn = require('child_process').spawn; // We're trying to reproduce: // $ echo "hello\nnode\nand\nworld" | grep o | sed s/o/a/ diff --git a/test/parallel/test-child-process-fork-and-spawn.js b/test/parallel/test-child-process-fork-and-spawn.js index 5766dc865bc975..eb0e1785751747 100644 --- a/test/parallel/test-child-process-fork-and-spawn.js +++ b/test/parallel/test-child-process-fork-and-spawn.js @@ -6,18 +6,18 @@ var fork = require('child_process').fork; // Fork, then spawn. The spawned process should not hang. switch (process.argv[2] || '') { -case '': - fork(__filename, ['fork']).on('exit', checkExit); - process.on('exit', haveExit); - break; -case 'fork': - spawn(process.execPath, [__filename, 'spawn']).on('exit', checkExit); - process.on('exit', haveExit); - break; -case 'spawn': - break; -default: - assert(0); + case '': + fork(__filename, ['fork']).on('exit', checkExit); + process.on('exit', haveExit); + break; + case 'fork': + spawn(process.execPath, [__filename, 'spawn']).on('exit', checkExit); + process.on('exit', haveExit); + break; + case 'spawn': + break; + default: + assert(0); } var seenExit = false; diff --git a/test/parallel/test-child-process-fork-close.js b/test/parallel/test-child-process-fork-close.js index 12b64cc4ff82ac..cec3c88f0fa11c 100644 --- a/test/parallel/test-child-process-fork-close.js +++ b/test/parallel/test-child-process-fork-close.js @@ -1,14 +1,13 @@ 'use strict'; -var assert = require('assert'), - common = require('../common'), - fork = require('child_process').fork, - fork = require('child_process').fork; +const assert = require('assert'); +const common = require('../common'); +const fork = require('child_process').fork; var cp = fork(common.fixturesDir + '/child-process-message-and-exit.js'); -var gotMessage = false, - gotExit = false, - gotClose = false; +let gotMessage = false; +let gotExit = false; +let gotClose = false; cp.on('message', function(message) { assert(!gotMessage); diff --git a/test/parallel/test-child-process-fork-dgram.js b/test/parallel/test-child-process-fork-dgram.js index 86cd6576c73b98..d1e3f3e5d814c5 100644 --- a/test/parallel/test-child-process-fork-dgram.js +++ b/test/parallel/test-child-process-fork-dgram.js @@ -69,7 +69,13 @@ if (process.argv[2] === 'child') { var sendMessages = function() { var timer = setInterval(function() { - client.send(msg, 0, msg.length, common.PORT, '127.0.0.1', function(err) { + client.send( + msg, + 0, + msg.length, + common.PORT, + '127.0.0.1', + function(err) { if (err) throw err; } ); diff --git a/test/parallel/test-child-process-fork-net2.js b/test/parallel/test-child-process-fork-net2.js index dd89557b61121d..359b88f559caa5 100644 --- a/test/parallel/test-child-process-fork-net2.js +++ b/test/parallel/test-child-process-fork-net2.js @@ -66,8 +66,8 @@ if (process.argv[2] === 'child') { var server = net.createServer(); - var connected = 0, - closed = 0; + let connected = 0; + let closed = 0; server.on('connection', function(socket) { switch (connected % 6) { case 0: diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js index 15f59c8f37717c..d1db3a815f5df5 100644 --- a/test/parallel/test-cli-eval.js +++ b/test/parallel/test-cli-eval.js @@ -5,11 +5,11 @@ if (module.parent) { process.exit(42); } -var common = require('../common'), - assert = require('assert'), - child = require('child_process'), - path = require('path'), - nodejs = '"' + process.execPath + '"'; +const common = require('../common'); +const assert = require('assert'); +const child = require('child_process'); +const path = require('path'); +const nodejs = '"' + process.execPath + '"'; // replace \ by / because windows uses backslashes in paths, but they're still diff --git a/test/parallel/test-cluster-worker-exit.js b/test/parallel/test-cluster-worker-exit.js index eb941e194b33cd..ccb213f0df9601 100644 --- a/test/parallel/test-cluster-worker-exit.js +++ b/test/parallel/test-cluster-worker-exit.js @@ -24,23 +24,23 @@ if (cluster.isWorker) { } else if (cluster.isMaster) { var expected_results = { - cluster_emitDisconnect: [1, "the cluster did not emit 'disconnect'"], - cluster_emitExit: [1, "the cluster did not emit 'exit'"], - cluster_exitCode: [EXIT_CODE, 'the cluster exited w/ incorrect exitCode'], - cluster_signalCode: [null, 'the cluster exited w/ incorrect signalCode'], - worker_emitDisconnect: [1, "the worker did not emit 'disconnect'"], - worker_emitExit: [1, "the worker did not emit 'exit'"], - worker_state: ['disconnected', 'the worker state is incorrect'], - worker_suicideMode: [false, 'the worker.suicide flag is incorrect'], - worker_died: [true, 'the worker is still running'], - worker_exitCode: [EXIT_CODE, 'the worker exited w/ incorrect exitCode'], - worker_signalCode: [null, 'the worker exited w/ incorrect signalCode'] + cluster_emitDisconnect: [1, "the cluster did not emit 'disconnect'"], + cluster_emitExit: [1, "the cluster did not emit 'exit'"], + cluster_exitCode: [EXIT_CODE, 'the cluster exited w/ incorrect exitCode'], + cluster_signalCode: [null, 'the cluster exited w/ incorrect signalCode'], + worker_emitDisconnect: [1, "the worker did not emit 'disconnect'"], + worker_emitExit: [1, "the worker did not emit 'exit'"], + worker_state: ['disconnected', 'the worker state is incorrect'], + worker_suicideMode: [false, 'the worker.suicide flag is incorrect'], + worker_died: [true, 'the worker is still running'], + worker_exitCode: [EXIT_CODE, 'the worker exited w/ incorrect exitCode'], + worker_signalCode: [null, 'the worker exited w/ incorrect signalCode'] }; var results = { - cluster_emitDisconnect: 0, - cluster_emitExit: 0, - worker_emitDisconnect: 0, - worker_emitExit: 0 + cluster_emitDisconnect: 0, + cluster_emitExit: 0, + worker_emitDisconnect: 0, + worker_emitExit: 0 }; @@ -103,8 +103,8 @@ if (cluster.isWorker) { function checkResults(expected_results, results) { for (var k in expected_results) { - var actual = results[k], - expected = expected_results[k]; + const actual = results[k]; + const expected = expected_results[k]; var msg = (expected[1] || '') + (' [expected: ' + expected[0] + ' / actual: ' + actual + ']'); diff --git a/test/parallel/test-cluster-worker-kill.js b/test/parallel/test-cluster-worker-kill.js index e12b466610171a..1ad9433f1ac940 100644 --- a/test/parallel/test-cluster-worker-kill.js +++ b/test/parallel/test-cluster-worker-kill.js @@ -103,8 +103,8 @@ if (cluster.isWorker) { function checkResults(expected_results, results) { for (var k in expected_results) { - var actual = results[k], - expected = expected_results[k]; + const actual = results[k]; + const expected = expected_results[k]; var msg = (expected[1] || '') + (' [expected: ' + expected[0] + ' / actual: ' + actual + ']'); diff --git a/test/parallel/test-crypto-padding.js b/test/parallel/test-crypto-padding.js index d4cb7190e2060a..bc2011d3d892f5 100644 --- a/test/parallel/test-crypto-padding.js +++ b/test/parallel/test-crypto-padding.js @@ -15,11 +15,11 @@ crypto.DEFAULT_ENCODING = 'buffer'; * Input data */ -var ODD_LENGTH_PLAIN = 'Hello node world!', - EVEN_LENGTH_PLAIN = 'Hello node world!AbC09876dDeFgHi'; +const ODD_LENGTH_PLAIN = 'Hello node world!'; +const EVEN_LENGTH_PLAIN = 'Hello node world!AbC09876dDeFgHi'; -var KEY_PLAIN = 'S3c.r.e.t.K.e.Y!', - IV_PLAIN = 'blahFizz2011Buzz'; +const KEY_PLAIN = 'S3c.r.e.t.K.e.Y!'; +const IV_PLAIN = 'blahFizz2011Buzz'; var CIPHER_NAME = 'aes-128-cbc'; diff --git a/test/parallel/test-crypto-stream.js b/test/parallel/test-crypto-stream.js index f276e161721eb5..bf0fc2ca1d00df 100644 --- a/test/parallel/test-crypto-stream.js +++ b/test/parallel/test-crypto-stream.js @@ -43,11 +43,11 @@ if (!common.hasFipsCrypto) { } // Decipher._flush() should emit an error event, not an exception. -var key = new Buffer('48fb56eb10ffeb13fc0ef551bbca3b1b', 'hex'), - badkey = new Buffer('12341234123412341234123412341234', 'hex'), - iv = new Buffer('6d358219d1f488f5f4eb12820a66d146', 'hex'), - cipher = crypto.createCipheriv('aes-128-cbc', key, iv), - decipher = crypto.createDecipheriv('aes-128-cbc', badkey, iv); +const key = new Buffer('48fb56eb10ffeb13fc0ef551bbca3b1b', 'hex'); +const badkey = new Buffer('12341234123412341234123412341234', 'hex'); +const iv = new Buffer('6d358219d1f488f5f4eb12820a66d146', 'hex'); +const cipher = crypto.createCipheriv('aes-128-cbc', key, iv); +const decipher = crypto.createDecipheriv('aes-128-cbc', badkey, iv); cipher.pipe(decipher) .on('error', common.mustCall(function end(err) { diff --git a/test/parallel/test-dgram-bytes-length.js b/test/parallel/test-dgram-bytes-length.js index c68b2fab70aff5..6527f628d01d2c 100644 --- a/test/parallel/test-dgram-bytes-length.js +++ b/test/parallel/test-dgram-bytes-length.js @@ -5,8 +5,14 @@ var dgram = require('dgram'); var message = new Buffer('Some bytes'); var client = dgram.createSocket('udp4'); -client.send(message, 0, message.length, 41234, 'localhost', - function(err, bytes) { - assert.strictEqual(bytes, message.length); - client.close(); -}); +client.send( + message, + 0, + message.length, + 41234, + 'localhost', + function(err, bytes) { + assert.strictEqual(bytes, message.length); + client.close(); + } +); diff --git a/test/parallel/test-dgram-close.js b/test/parallel/test-dgram-close.js index 7e9dd4ef52c402..a84a3bc19e4bbc 100644 --- a/test/parallel/test-dgram-close.js +++ b/test/parallel/test-dgram-close.js @@ -2,9 +2,9 @@ // Ensure that if a dgram socket is closed before the DNS lookup completes, it // won't crash. -var assert = require('assert'), - common = require('../common'), - dgram = require('dgram'); +const assert = require('assert'); +const common = require('../common'); +const dgram = require('dgram'); var buf = new Buffer(1024); buf.fill(42); diff --git a/test/parallel/test-dgram-multicast-setTTL.js b/test/parallel/test-dgram-multicast-setTTL.js index f48fc7118ec3c1..7f641237c7999b 100644 --- a/test/parallel/test-dgram-multicast-setTTL.js +++ b/test/parallel/test-dgram-multicast-setTTL.js @@ -1,9 +1,9 @@ 'use strict'; -var common = require('../common'), - assert = require('assert'), - dgram = require('dgram'), - thrown = false, - socket = dgram.createSocket('udp4'); +const common = require('../common'); +const assert = require('assert'); +const dgram = require('dgram'); +const socket = dgram.createSocket('udp4'); +let thrown = false; socket.bind(common.PORT); socket.on('listening', function() { diff --git a/test/parallel/test-dgram-pingpong.js b/test/parallel/test-dgram-pingpong.js index 883085a9cdaab2..63d001d0b376a4 100644 --- a/test/parallel/test-dgram-pingpong.js +++ b/test/parallel/test-dgram-pingpong.js @@ -34,8 +34,8 @@ function pingPongTest(port, host) { server.on('listening', function() { console.log('server listening on ' + port + ' ' + host); - var buf = new Buffer('PING'), - client = dgram.createSocket('udp4'); + const buf = new Buffer('PING'); + const client = dgram.createSocket('udp4'); client.on('message', function(msg, rinfo) { if (debug) console.log('client got: ' + msg + diff --git a/test/parallel/test-dgram-udp4.js b/test/parallel/test-dgram-udp4.js index 58c8b69839ffe6..e845c5d845549c 100644 --- a/test/parallel/test-dgram-udp4.js +++ b/test/parallel/test-dgram-udp4.js @@ -1,11 +1,11 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); - -var dgram = require('dgram'), server, client, - server_port = common.PORT, - message_to_send = 'A message to send', - timer; +const common = require('../common'); +const assert = require('assert'); +const dgram = require('dgram'); +const server_port = common.PORT; +const message_to_send = 'A message to send'; +let server, client; +let timer; server = dgram.createSocket('udp4'); server.on('message', function(msg, rinfo) { @@ -28,13 +28,19 @@ server.on('listening', function() { client.close(); server.close(); }); - client.send(message_to_send, 0, message_to_send.length, - server_port, 'localhost', function(err) { - if (err) { - console.log('Caught error in client send.'); - throw err; - } - }); + client.send( + message_to_send, + 0, + message_to_send.length, + server_port, + 'localhost', + function(err) { + if (err) { + console.log('Caught error in client send.'); + throw err; + } + } + ); client.on('close', function() { if (server.fd === null) { diff --git a/test/parallel/test-domain-with-abort-on-uncaught-exception.js b/test/parallel/test-domain-with-abort-on-uncaught-exception.js index 3158274ea181a9..004afff318622c 100644 --- a/test/parallel/test-domain-with-abort-on-uncaught-exception.js +++ b/test/parallel/test-domain-with-abort-on-uncaught-exception.js @@ -140,24 +140,24 @@ if (process.argv[2] === 'child') { } testDomainExceptionHandling('--abort_on_uncaught_exception', { - throwInDomainErrHandler: false, - useTryCatch: false - }); + throwInDomainErrHandler: false, + useTryCatch: false + }); testDomainExceptionHandling('--abort_on_uncaught_exception', { - throwInDomainErrHandler: false, - useTryCatch: true - }); + throwInDomainErrHandler: false, + useTryCatch: true + }); testDomainExceptionHandling('--abort_on_uncaught_exception', { - throwInDomainErrHandler: true, - useTryCatch: false - }); + throwInDomainErrHandler: true, + useTryCatch: false + }); testDomainExceptionHandling('--abort_on_uncaught_exception', { - throwInDomainErrHandler: true, - useTryCatch: true - }); + throwInDomainErrHandler: true, + useTryCatch: true + }); testDomainExceptionHandling({ throwInDomainErrHandler: false diff --git a/test/parallel/test-event-emitter-num-args.js b/test/parallel/test-event-emitter-num-args.js index 51f57e89bc6e22..e405b5b894a704 100644 --- a/test/parallel/test-event-emitter-num-args.js +++ b/test/parallel/test-event-emitter-num-args.js @@ -3,8 +3,8 @@ require('../common'); var assert = require('assert'); var events = require('events'); -var e = new events.EventEmitter(), - num_args_emited = []; +const e = new events.EventEmitter(); +const num_args_emited = []; e.on('numArgs', function() { var numArgs = arguments.length; diff --git a/test/parallel/test-file-write-stream.js b/test/parallel/test-file-write-stream.js index 36ef283528b7c1..b9d9fd76b88df2 100644 --- a/test/parallel/test-file-write-stream.js +++ b/test/parallel/test-file-write-stream.js @@ -7,50 +7,50 @@ var fs = require('fs'); var fn = path.join(common.tmpDir, 'write.txt'); common.refreshTmpDir(); var file = fs.createWriteStream(fn, { - highWaterMark: 10 - }); + highWaterMark: 10 +}); var EXPECTED = '012345678910'; var callbacks = { - open: -1, - drain: -2, - close: -1 - }; + open: -1, + drain: -2, + close: -1 +}; file .on('open', function(fd) { - console.error('open!'); - callbacks.open++; - assert.equal('number', typeof fd); - }) + console.error('open!'); + callbacks.open++; + assert.equal('number', typeof fd); + }) .on('error', function(err) { - throw err; - }) + throw err; + }) .on('drain', function() { - console.error('drain!', callbacks.drain); - callbacks.drain++; - if (callbacks.drain == -1) { - assert.equal(EXPECTED, fs.readFileSync(fn, 'utf8')); - file.write(EXPECTED); - } else if (callbacks.drain == 0) { - assert.equal(EXPECTED + EXPECTED, fs.readFileSync(fn, 'utf8')); - file.end(); - } - }) + console.error('drain!', callbacks.drain); + callbacks.drain++; + if (callbacks.drain == -1) { + assert.equal(EXPECTED, fs.readFileSync(fn, 'utf8')); + file.write(EXPECTED); + } else if (callbacks.drain == 0) { + assert.equal(EXPECTED + EXPECTED, fs.readFileSync(fn, 'utf8')); + file.end(); + } + }) .on('close', function() { - console.error('close!'); - assert.strictEqual(file.bytesWritten, EXPECTED.length * 2); + console.error('close!'); + assert.strictEqual(file.bytesWritten, EXPECTED.length * 2); - callbacks.close++; - assert.throws(function() { - console.error('write after end should not be allowed'); - file.write('should not work anymore'); - }); - - fs.unlinkSync(fn); + callbacks.close++; + assert.throws(function() { + console.error('write after end should not be allowed'); + file.write('should not work anymore'); }); + fs.unlinkSync(fn); + }); + for (var i = 0; i < 11; i++) { (function(i) { file.write('' + i); diff --git a/test/parallel/test-file-write-stream3.js b/test/parallel/test-file-write-stream3.js index a2552d95b215d4..07afeab48310d7 100644 --- a/test/parallel/test-file-write-stream3.js +++ b/test/parallel/test-file-write-stream3.js @@ -1,16 +1,15 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); - -var path = require('path'), - fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); var filepath = path.join(common.tmpDir, 'write_pos.txt'); -var cb_expected = 'write open close write open close write open close ', - cb_occurred = ''; +const cb_expected = 'write open close write open close write open close '; +let cb_occurred = ''; var fileDataInitial = 'abcdefghijklmnopqrstuvwxyz'; @@ -126,8 +125,8 @@ function run_test_2() { function run_test_3() { var file, options; - var data = '\u2026\u2026', // 3 bytes * 2 = 6 bytes in UTF-8 - fileData; + const data = '\u2026\u2026'; // 3 bytes * 2 = 6 bytes in UTF-8 + let fileData; options = { start: 10, flags: 'r+' }; diff --git a/test/parallel/test-fs-chmod.js b/test/parallel/test-fs-chmod.js index 11c8bb6168916e..954916cbdbb365 100644 --- a/test/parallel/test-fs-chmod.js +++ b/test/parallel/test-fs-chmod.js @@ -51,8 +51,8 @@ if (common.isWindows) { mode_sync = 0o644; } -var file1 = path.join(common.fixturesDir, 'a.js'), - file2 = path.join(common.fixturesDir, 'a1.js'); +const file1 = path.join(common.fixturesDir, 'a.js'); +const file2 = path.join(common.fixturesDir, 'a1.js'); fs.chmod(file1, mode_async.toString(8), function(err) { if (err) { diff --git a/test/parallel/test-fs-error-messages.js b/test/parallel/test-fs-error-messages.js index ca0684c1d71363..1a05ef80a44a5c 100644 --- a/test/parallel/test-fs-error-messages.js +++ b/test/parallel/test-fs-error-messages.js @@ -1,14 +1,13 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); - -var path = require('path'), - fs = require('fs'), - fn = path.join(common.fixturesDir, 'non-existent'), - existingFile = path.join(common.fixturesDir, 'exit.js'), - existingFile2 = path.join(common.fixturesDir, 'create-file.js'), - existingDir = path.join(common.fixturesDir, 'empty'), - existingDir2 = path.join(common.fixturesDir, 'keys'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); +const fn = path.join(common.fixturesDir, 'non-existent'); +const existingFile = path.join(common.fixturesDir, 'exit.js'); +const existingFile2 = path.join(common.fixturesDir, 'create-file.js'); +const existingDir = path.join(common.fixturesDir, 'empty'); +const existingDir2 = path.join(common.fixturesDir, 'keys'); // ASYNC_CALL @@ -78,8 +77,8 @@ fs.readFile(fn, function(err) { // Sync -var errors = [], - expected = 0; +const errors = []; +let expected = 0; try { ++expected; diff --git a/test/parallel/test-fs-open-flags.js b/test/parallel/test-fs-open-flags.js index 667abb81765f91..16b3d35cae5a49 100644 --- a/test/parallel/test-fs-open-flags.js +++ b/test/parallel/test-fs-open-flags.js @@ -29,7 +29,8 @@ assert.equal(fs._stringToFlags('xa'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL); assert.equal(fs._stringToFlags('ax+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL); assert.equal(fs._stringToFlags('xa+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL); -('+ +a +r +w rw wa war raw r++ a++ w++' + - 'x +x x+ rx rx+ wxx wax xwx xxx').split(' ').forEach(function(flags) { - assert.throws(function() { fs._stringToFlags(flags); }); -}); +('+ +a +r +w rw wa war raw r++ a++ w++ x +x x+ rx rx+ wxx wax xwx xxx') + .split(' ') + .forEach(function(flags) { + assert.throws(function() { fs._stringToFlags(flags); }); + }); diff --git a/test/parallel/test-fs-read-buffer.js b/test/parallel/test-fs-read-buffer.js index 57a28d477c6575..6b6f0572dacc8a 100644 --- a/test/parallel/test-fs-read-buffer.js +++ b/test/parallel/test-fs-read-buffer.js @@ -1,15 +1,15 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'), - Buffer = require('buffer').Buffer, - fs = require('fs'), - filepath = path.join(common.fixturesDir, 'x.txt'), - fd = fs.openSync(filepath, 'r'), - expected = 'xyz\n', - bufferAsync = new Buffer(expected.length), - bufferSync = new Buffer(expected.length), - readCalled = 0; +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const Buffer = require('buffer').Buffer; +const fs = require('fs'); +const filepath = path.join(common.fixturesDir, 'x.txt'); +const fd = fs.openSync(filepath, 'r'); +const expected = 'xyz\n'; +const bufferAsync = new Buffer(expected.length); +const bufferSync = new Buffer(expected.length); +let readCalled = 0; fs.read(fd, bufferAsync, 0, expected.length, 0, function(err, bytesRead) { readCalled++; diff --git a/test/parallel/test-fs-read.js b/test/parallel/test-fs-read.js index 8b0b6fe0a3844d..6f20656e282b8e 100644 --- a/test/parallel/test-fs-read.js +++ b/test/parallel/test-fs-read.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'), - fs = require('fs'), - filepath = path.join(common.fixturesDir, 'x.txt'), - fd = fs.openSync(filepath, 'r'), - expected = 'xyz\n', - readCalled = 0; +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); +const filepath = path.join(common.fixturesDir, 'x.txt'); +const fd = fs.openSync(filepath, 'r'); +const expected = 'xyz\n'; +let readCalled = 0; fs.read(fd, expected.length, 0, 'utf-8', function(err, str, bytesRead) { readCalled++; diff --git a/test/parallel/test-fs-readfile-empty.js b/test/parallel/test-fs-readfile-empty.js index 2669ce1ad6b121..afc0863673ee49 100644 --- a/test/parallel/test-fs-readfile-empty.js +++ b/test/parallel/test-fs-readfile-empty.js @@ -1,10 +1,9 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); - -var path = require('path'), - fs = require('fs'), - fn = path.join(common.fixturesDir, 'empty.txt'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); +const fn = path.join(common.fixturesDir, 'empty.txt'); fs.readFile(fn, function(err, data) { assert.ok(data); diff --git a/test/parallel/test-fs-readfile-unlink.js b/test/parallel/test-fs-readfile-unlink.js index 15491b71c433ed..dad993aa4ff2b2 100644 --- a/test/parallel/test-fs-readfile-unlink.js +++ b/test/parallel/test-fs-readfile-unlink.js @@ -1,10 +1,10 @@ 'use strict'; -var assert = require('assert'), - common = require('../common'), - fs = require('fs'), - path = require('path'), - dirName = path.resolve(common.fixturesDir, 'test-readfile-unlink'), - fileName = path.resolve(dirName, 'test.bin'); +const assert = require('assert'); +const common = require('../common'); +const fs = require('fs'); +const path = require('path'); +const dirName = path.resolve(common.fixturesDir, 'test-readfile-unlink'); +const fileName = path.resolve(dirName, 'test.bin'); var buf = new Buffer(512 * 1024); buf.fill(42); diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 53312c6e8d7186..b18afac12d4a78 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -85,8 +85,8 @@ function test_simple_relative_symlink(callback) { console.log('1..0 # Skipped: symlink test (no privs)'); return runNextTest(); } - var entry = common.tmpDir + '/symlink', - expected = common.tmpDir + '/cycles/root.js'; + const entry = common.tmpDir + '/symlink'; + const expected = common.tmpDir + '/cycles/root.js'; [ [entry, '../' + common.tmpDirName + '/cycles/root.js'] ].forEach(function(t) { @@ -111,8 +111,8 @@ function test_simple_absolute_symlink(callback) { console.log('using type=%s', type); - var entry = tmpAbsDir + '/symlink', - expected = common.fixturesDir + '/nested-index/one'; + const entry = tmpAbsDir + '/symlink'; + const expected = common.fixturesDir + '/nested-index/one'; [ [entry, expected] ].forEach(function(t) { @@ -490,8 +490,8 @@ function test_lying_cache_liar(cb) { }); assert(called === false); - var test = path.resolve('/a/b/c/d'), - expect = path.resolve('/a/b/d'); + const test = path.resolve('/a/b/c/d'); + const expect = path.resolve('/a/b/d'); var actual = fs.realpathSync(test, cache); assert.equal(expect, actual); fs.realpath(test, cache, function(er, actual) { diff --git a/test/parallel/test-fs-write-buffer.js b/test/parallel/test-fs-write-buffer.js index dace4a19a183a8..55ae8e287613a7 100644 --- a/test/parallel/test-fs-write-buffer.js +++ b/test/parallel/test-fs-write-buffer.js @@ -1,13 +1,13 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'), - Buffer = require('buffer').Buffer, - fs = require('fs'), - filename = path.join(common.tmpDir, 'write.txt'), - expected = new Buffer('hello'), - openCalled = 0, - writeCalled = 0; +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const Buffer = require('buffer').Buffer; +const fs = require('fs'); +const filename = path.join(common.tmpDir, 'write.txt'); +const expected = new Buffer('hello'); +let openCalled = 0; +let writeCalled = 0; common.refreshTmpDir(); diff --git a/test/parallel/test-fs-write-stream-change-open.js b/test/parallel/test-fs-write-stream-change-open.js index a7503e1a603202..a9d31a3074dcd6 100644 --- a/test/parallel/test-fs-write-stream-change-open.js +++ b/test/parallel/test-fs-write-stream-change-open.js @@ -1,17 +1,16 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); - -var path = require('path'), - fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); var file = path.join(common.tmpDir, 'write.txt'); common.refreshTmpDir(); -var stream = fs.WriteStream(file), - _fs_close = fs.close, - _fs_open = fs.open; +const stream = fs.WriteStream(file); +const _fs_close = fs.close; +const _fs_open = fs.open; // change the fs.open with an identical function after the WriteStream // has pushed it onto its internal action queue, but before it's diff --git a/test/parallel/test-fs-write-stream.js b/test/parallel/test-fs-write-stream.js index af3ae17ec7e7e1..5d29e60545f434 100644 --- a/test/parallel/test-fs-write-stream.js +++ b/test/parallel/test-fs-write-stream.js @@ -1,17 +1,16 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); - -var path = require('path'), - fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); var file = path.join(common.tmpDir, 'write.txt'); common.refreshTmpDir(); (function() { - var stream = fs.WriteStream(file), - _fs_close = fs.close; + const stream = fs.WriteStream(file); + const _fs_close = fs.close; fs.close = function(fd) { assert.ok(fd, 'fs.close must not be called without an undefined fd.'); diff --git a/test/parallel/test-global.js b/test/parallel/test-global.js index 82d8ee054c5860..4eeecf36e0ac22 100644 --- a/test/parallel/test-global.js +++ b/test/parallel/test-global.js @@ -11,8 +11,8 @@ assert.equal('foo', global.baseFoo, 'x -> global.x in base level not working'); assert.equal('bar', baseBar, 'global.x -> x in base level not working'); -var module = require('../fixtures/global/plain'), - fooBar = module.fooBar; +var module = require('../fixtures/global/plain'); +const fooBar = module.fooBar; assert.equal('foo', fooBar.foo, 'x -> global.x in sub level not working'); diff --git a/test/parallel/test-http-abort-queued.js b/test/parallel/test-http-abort-queued.js index f2b0120366c374..d28ad01888884d 100644 --- a/test/parallel/test-http-abort-queued.js +++ b/test/parallel/test-http-abort-queued.js @@ -1,7 +1,7 @@ 'use strict'; -var assert = require('assert'), - common = require('../common'), - http = require('http'); +const assert = require('assert'); +const common = require('../common'); +const http = require('http'); var complete; diff --git a/test/parallel/test-http-client-response-domain.js b/test/parallel/test-http-client-response-domain.js index 5809d93aee72c4..59b95144867538 100644 --- a/test/parallel/test-http-client-response-domain.js +++ b/test/parallel/test-http-client-response-domain.js @@ -1,8 +1,8 @@ 'use strict'; -var common = require('../common'), - assert = require('assert'), - http = require('http'), - domain = require('domain'); +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); +const domain = require('domain'); var gotDomainError = false; var d; diff --git a/test/parallel/test-http-client-timeout-agent.js b/test/parallel/test-http-client-timeout-agent.js index 809742f5628df5..51bfb8299b13df 100644 --- a/test/parallel/test-http-client-timeout-agent.js +++ b/test/parallel/test-http-client-timeout-agent.js @@ -15,8 +15,8 @@ var options = { //http.globalAgent.maxSockets = 15; var server = http.createServer(function(req, res) { - var m = /\/(.*)/.exec(req.url), - reqid = parseInt(m[1], 10); + const m = /\/(.*)/.exec(req.url); + const reqid = parseInt(m[1], 10); if ( reqid % 2 ) { // do not reply the request } else { diff --git a/test/parallel/test-http-default-port.js b/test/parallel/test-http-default-port.js index e403b401fb603f..69d81e9b9724ce 100644 --- a/test/parallel/test-http-default-port.js +++ b/test/parallel/test-http-default-port.js @@ -1,19 +1,19 @@ 'use strict'; -var common = require('../common'); -var http = require('http'), - PORT = common.PORT, - SSLPORT = common.PORT + 1, - assert = require('assert'), - hostExpect = 'localhost', - fs = require('fs'), - path = require('path'), - fixtures = path.resolve(__dirname, '../fixtures/keys'), - options = { - key: fs.readFileSync(fixtures + '/agent1-key.pem'), - cert: fs.readFileSync(fixtures + '/agent1-cert.pem') - }, - gotHttpsResp = false, - gotHttpResp = false; +const common = require('../common'); +const http = require('http'); +const PORT = common.PORT; +const SSLPORT = common.PORT + 1; +const assert = require('assert'); +const hostExpect = 'localhost'; +const fs = require('fs'); +const path = require('path'); +const fixtures = path.resolve(__dirname, '../fixtures/keys'); +const options = { + key: fs.readFileSync(fixtures + '/agent1-key.pem'), + cert: fs.readFileSync(fixtures + '/agent1-cert.pem') +}; +let gotHttpsResp = false; +let gotHttpResp = false; if (common.hasCrypto) { var https = require('https'); diff --git a/test/parallel/test-http-header-response-splitting.js b/test/parallel/test-http-header-response-splitting.js index 437793a524f22f..bb1da8ca7ca3ea 100644 --- a/test/parallel/test-http-header-response-splitting.js +++ b/test/parallel/test-http-header-response-splitting.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common'), - assert = require('assert'), - http = require('http'); +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); var testIndex = 0; const testCount = 2 * 4 * 6; @@ -10,24 +10,24 @@ const responseBody = 'Hi mars!'; var server = http.createServer(function(req, res) { function reply(header) { switch (testIndex % 4) { - case 0: - res.writeHead(200, { a: header, b: header }); - break; - case 1: - res.setHeader('a', header); - res.setHeader('b', header); - res.writeHead(200); - break; - case 2: - res.setHeader('a', header); - res.writeHead(200, { b: header }); - break; - case 3: - res.setHeader('a', [header]); - res.writeHead(200, { b: header }); - break; - default: - assert.fail(null, null, 'unreachable'); + case 0: + res.writeHead(200, { a: header, b: header }); + break; + case 1: + res.setHeader('a', header); + res.setHeader('b', header); + res.writeHead(200); + break; + case 2: + res.setHeader('a', header); + res.writeHead(200, { b: header }); + break; + case 3: + res.setHeader('a', [header]); + res.writeHead(200, { b: header }); + break; + default: + assert.fail(null, null, 'unreachable'); } res.write(responseBody); if (testIndex % 8 < 4) { diff --git a/test/parallel/test-http-host-headers.js b/test/parallel/test-http-host-headers.js index b5c083dfdf6d15..f121216801c045 100644 --- a/test/parallel/test-http-host-headers.js +++ b/test/parallel/test-http-host-headers.js @@ -1,8 +1,8 @@ 'use strict'; -var http = require('http'), - common = require('../common'), - assert = require('assert'), - httpServer = http.createServer(reqHandler); +const http = require('http'); +const common = require('../common'); +const assert = require('assert'); +const httpServer = http.createServer(reqHandler); function reqHandler(req, res) { console.log('Got request: ' + req.headers.host + ' ' + req.url); diff --git a/test/parallel/test-http-localaddress.js b/test/parallel/test-http-localaddress.js index ac5de820263787..c7bb9f0301e407 100644 --- a/test/parallel/test-http-localaddress.js +++ b/test/parallel/test-http-localaddress.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common'); -var http = require('http'), - assert = require('assert'); +const common = require('../common'); +const http = require('http'); +const assert = require('assert'); if (!common.hasMultiLocalhost()) { console.log('1..0 # Skipped: platform-specific test.'); diff --git a/test/parallel/test-http-parser.js b/test/parallel/test-http-parser.js index f10f3ac26b4b10..17d5aa1d8f9575 100644 --- a/test/parallel/test-http-parser.js +++ b/test/parallel/test-http-parser.js @@ -333,8 +333,8 @@ function expectBody(expected) { assert.equal(versionMinor, 1); }; - var body_part = 0, - body_parts = ['123', '123456', '1234567890']; + let body_part = 0; + const body_parts = ['123', '123456', '1234567890']; var onBody = function(buf, start, len) { var body = '' + buf.slice(start, start + len); @@ -371,8 +371,8 @@ function expectBody(expected) { assert.equal(versionMinor, 1); }; - var body_part = 0, - body_parts = + let body_part = 0; + const body_parts = ['123', '123456', '123456789', '123456789ABC', '123456789ABCDEF']; var onBody = function(buf, start, len) { diff --git a/test/parallel/test-http-timeout.js b/test/parallel/test-http-timeout.js index f459961517852b..abaa368045d14d 100644 --- a/test/parallel/test-http-timeout.js +++ b/test/parallel/test-http-timeout.js @@ -23,20 +23,22 @@ server.listen(port, function() { var count = 0; function createRequest() { - var req = http.request({port: port, path: '/', agent: agent}, - function(res) { - req.clearTimeout(callback); - - res.on('end', function() { - count++; - - if (count == 11) { - server.close(); - } - }); - - res.resume(); - }); + const req = http.request( + {port: port, path: '/', agent: agent}, + function(res) { + req.clearTimeout(callback); + + res.on('end', function() { + count++; + + if (count == 11) { + server.close(); + } + }); + + res.resume(); + } + ); req.setTimeout(1000, callback); return req; diff --git a/test/parallel/test-https-host-headers.js b/test/parallel/test-https-host-headers.js index 0ea32f320e736b..1e71fd5b9ef5b7 100644 --- a/test/parallel/test-https-host-headers.js +++ b/test/parallel/test-https-host-headers.js @@ -8,12 +8,12 @@ if (!common.hasCrypto) { } var https = require('https'); -var fs = require('fs'), - options = { - key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), - cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') - }, - httpsServer = https.createServer(options, reqHandler); +const fs = require('fs'); +const options = { + key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), + cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') +}; +const httpsServer = https.createServer(options, reqHandler); function reqHandler(req, res) { console.log('Got request: ' + req.headers.host + ' ' + req.url); diff --git a/test/parallel/test-https-localaddress.js b/test/parallel/test-https-localaddress.js index a330c4881a9e47..bce65d58e296f2 100644 --- a/test/parallel/test-https-localaddress.js +++ b/test/parallel/test-https-localaddress.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common'), - fs = require('fs'), - assert = require('assert'); +const common = require('../common'); +const fs = require('fs'); +const assert = require('assert'); if (!common.hasCrypto) { console.log('1..0 # Skipped: missing crypto'); diff --git a/test/parallel/test-net-listen-port-option.js b/test/parallel/test-net-listen-port-option.js index d1eddb6707c274..5c3bc8eb7956ae 100644 --- a/test/parallel/test-net-listen-port-option.js +++ b/test/parallel/test-net-listen-port-option.js @@ -14,7 +14,8 @@ net.Server().listen({ port: '' + common.PORT }, close); 1 / 0, -1 / 0, '+Infinity', - '-Infinity' ].forEach(function(port) { + '-Infinity' +].forEach(function(port) { assert.throws(function() { net.Server().listen({ port: port }, assert.fail); }, /port should be >= 0 and < 65536/i); diff --git a/test/parallel/test-net-pause-resume-connecting.js b/test/parallel/test-net-pause-resume-connecting.js index fb3b66c8cf991c..6be20cecb91159 100644 --- a/test/parallel/test-net-pause-resume-connecting.js +++ b/test/parallel/test-net-pause-resume-connecting.js @@ -1,11 +1,11 @@ 'use strict'; -var common = require('../common'), - assert = require('assert'), - net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); -var connections = 0, - dataEvents = 0, - conn; +let connections = 0; +let dataEvents = 0; +let conn; // Server diff --git a/test/parallel/test-net-stream.js b/test/parallel/test-net-stream.js index 151b1b178f9adc..f2b795f931bd9c 100644 --- a/test/parallel/test-net-stream.js +++ b/test/parallel/test-net-stream.js @@ -38,14 +38,14 @@ var server = net.createServer(function(socket) { socket.end(); }).listen(common.PORT, function() { - var conn = net.connect(common.PORT); - conn.on('data', function(buf) { - conn.pause(); - setTimeout(function() { - conn.destroy(); - }, 20); - }); + var conn = net.connect(common.PORT); + conn.on('data', function(buf) { + conn.pause(); + setTimeout(function() { + conn.destroy(); + }, 20); }); +}); process.on('exit', function() { assert.equal(server.connections, 0); diff --git a/test/parallel/test-next-tick-errors.js b/test/parallel/test-next-tick-errors.js index 7c511b8d5e18ab..fe13d6ed4dac93 100644 --- a/test/parallel/test-next-tick-errors.js +++ b/test/parallel/test-next-tick-errors.js @@ -2,8 +2,8 @@ require('../common'); var assert = require('assert'); -var order = [], - exceptionHandled = false; +const order = []; +let exceptionHandled = false; // This nextTick function will throw an error. It should only be called once. // When it throws an error, it should still get removed from the queue. diff --git a/test/parallel/test-path-parse-format.js b/test/parallel/test-path-parse-format.js index c8913d2dfc56e4..f635f7f010012c 100644 --- a/test/parallel/test-path-parse-format.js +++ b/test/parallel/test-path-parse-format.js @@ -80,7 +80,7 @@ function checkErrors(path) { errors.forEach(function(errorCase) { try { path[errorCase.method].apply(path, errorCase.input); - } catch(err) { + } catch (err) { assert.ok(err instanceof TypeError); assert.ok( errorCase.message.test(err.message), diff --git a/test/parallel/test-preload.js b/test/parallel/test-preload.js index f30ad1d218e645..f94a7eae942493 100644 --- a/test/parallel/test-preload.js +++ b/test/parallel/test-preload.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'), - path = require('path'), - child_process = require('child_process'); +const assert = require('assert'); +const path = require('path'); +const child_process = require('child_process'); var nodeBinary = process.argv[0]; diff --git a/test/parallel/test-promises-unhandled-rejections.js b/test/parallel/test-promises-unhandled-rejections.js index 5e7739daa5b406..8345096445098c 100644 --- a/test/parallel/test-promises-unhandled-rejections.js +++ b/test/parallel/test-promises-unhandled-rejections.js @@ -234,23 +234,27 @@ asyncTest('When re-throwing new errors in a promise catch, only the re-thrown' + var promise2; }); -asyncTest('unhandledRejection should not be triggered if a promise catch is' + - ' attached synchronously upon the promise\'s creation', - function(done) { - var e = new Error(); - onUnhandledFail(done); - Promise.reject(e).then(common.fail, function() {}); -}); - -asyncTest('unhandledRejection should not be triggered if a promise catch is' + - ' attached synchronously upon the promise\'s creation', - function(done) { - var e = new Error(); - onUnhandledFail(done); - new Promise(function(_, reject) { - reject(e); - }).then(common.fail, function() {}); -}); +asyncTest( + 'unhandledRejection should not be triggered if a promise catch is' + + ' attached synchronously upon the promise\'s creation', + function(done) { + var e = new Error(); + onUnhandledFail(done); + Promise.reject(e).then(common.fail, function() {}); + } +); + +asyncTest( + 'unhandledRejection should not be triggered if a promise catch is' + + ' attached synchronously upon the promise\'s creation', + function(done) { + var e = new Error(); + onUnhandledFail(done); + new Promise(function(_, reject) { + reject(e); + }).then(common.fail, function() {}); + } +); asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' + ' prevent unhandledRejection', function(done) { @@ -360,19 +364,21 @@ asyncTest('A rejected promise derived from throwing in a fulfillment handler' + }); }); -asyncTest('A rejected promise derived from returning a synchronously-rejected' + - ' promise in a fulfillment handler does trigger unhandledRejection', - function(done) { - var e = new Error(); - var _promise; - onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(e, reason); - assert.strictEqual(_promise, promise); - }); - _promise = Promise.resolve().then(function() { - return Promise.reject(e); - }); -}); +asyncTest( + 'A rejected promise derived from returning a synchronously-rejected' + + ' promise in a fulfillment handler does trigger unhandledRejection', + function(done) { + var e = new Error(); + var _promise; + onUnhandledSucceed(done, function(reason, promise) { + assert.strictEqual(e, reason); + assert.strictEqual(_promise, promise); + }); + _promise = Promise.resolve().then(function() { + return Promise.reject(e); + }); + } +); // Combinations with Promise.all asyncTest('Catching the Promise.all() of a collection that includes a' + @@ -382,21 +388,23 @@ asyncTest('Catching the Promise.all() of a collection that includes a' + Promise.all([Promise.reject(e)]).then(common.fail, function() {}); }); -asyncTest('Catching the Promise.all() of a collection that includes a ' + - 'nextTick-async rejected promise prevents unhandledRejection', - function(done) { - var e = new Error(); - onUnhandledFail(done); - var p = new Promise(function(_, reject) { +asyncTest( + 'Catching the Promise.all() of a collection that includes a ' + + 'nextTick-async rejected promise prevents unhandledRejection', + function(done) { + var e = new Error(); + onUnhandledFail(done); + var p = new Promise(function(_, reject) { + process.nextTick(function() { + reject(e); + }); + }); + p = Promise.all([p]); process.nextTick(function() { - reject(e); + p.then(common.fail, function() {}); }); - }); - p = Promise.all([p]); - process.nextTick(function() { - p.then(common.fail, function() {}); - }); -}); + } +); asyncTest('Failing to catch the Promise.all() of a collection that includes' + ' a rejected promise triggers unhandledRejection for the returned' + @@ -513,26 +521,28 @@ asyncTest('Waiting for some combination of promise microtasks + ' + }); }); -asyncTest('Waiting for some combination of promise microtasks +' + - ' process.nextTick to attach a catch handler is still soon enough' + - ' to prevent unhandledRejection: inside setImmediate', - function(done) { - var e = new Error(); - onUnhandledFail(done); +asyncTest( + 'Waiting for some combination of promise microtasks +' + + ' process.nextTick to attach a catch handler is still soon enough' + + ' to prevent unhandledRejection: inside setImmediate', + function(done) { + var e = new Error(); + onUnhandledFail(done); - setImmediate(function() { - var a = Promise.reject(e); - Promise.resolve().then(function() { - process.nextTick(function() { - Promise.resolve().then(function() { - process.nextTick(function() { - a.catch(function() {}); + setImmediate(function() { + var a = Promise.reject(e); + Promise.resolve().then(function() { + process.nextTick(function() { + Promise.resolve().then(function() { + process.nextTick(function() { + a.catch(function() {}); + }); }); }); }); }); - }); -}); + } +); asyncTest('Waiting for some combination of promise microtasks +' + ' process.nextTick to attach a catch handler is still soon enough' + @@ -612,28 +622,30 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' + }); }); -asyncTest('Promise unhandledRejection handler does not interfere with domain' + - ' error handlers being given exceptions thrown from nextTick.', - function(done) { - var d = domain.create(); - var domainReceivedError; - d.on('error', function(e) { - domainReceivedError = e; - }); - d.run(function() { - var e = new Error('error'); - var domainError = new Error('domain error'); - onUnhandledSucceed(done, function(reason, promise) { - assert.strictEqual(reason, e); - assert.strictEqual(domainReceivedError, domainError); - d.dispose(); +asyncTest( + 'Promise unhandledRejection handler does not interfere with domain' + + ' error handlers being given exceptions thrown from nextTick.', + function(done) { + var d = domain.create(); + var domainReceivedError; + d.on('error', function(e) { + domainReceivedError = e; }); - Promise.reject(e); - process.nextTick(function() { - throw domainError; + d.run(function() { + var e = new Error('error'); + var domainError = new Error('domain error'); + onUnhandledSucceed(done, function(reason, promise) { + assert.strictEqual(reason, e); + assert.strictEqual(domainReceivedError, domainError); + d.dispose(); + }); + Promise.reject(e); + process.nextTick(function() { + throw domainError; + }); }); - }); -}); + } +); asyncTest('nextTick is immediately scheduled when called inside an event' + ' handler', function(done) { diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js index bb3c361f882a14..f30d0a3cb2597e 100644 --- a/test/parallel/test-querystring.js +++ b/test/parallel/test-querystring.js @@ -182,12 +182,11 @@ assert.equal( // Test removing limit function testUnlimitedKeys() { - var query = {}, - url; + const query = {}; for (var i = 0; i < 2000; i++) query[i] = i; - url = qs.stringify(query); + const url = qs.stringify(query); assert.equal( Object.keys(qs.parse(url, null, null, { maxKeys: 0 })).length, diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index 6d79879615fa28..9697b25ab54259 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -259,7 +259,7 @@ function isWarned(emitter) { }); try { fi.emit('data', 'fooX'); - } catch(e) { } + } catch (e) { } fi.emit('data', 'bar'); assert.equal(keys.join(''), 'fooXbar'); rli.close(); diff --git a/test/parallel/test-regress-GH-7511.js b/test/parallel/test-regress-GH-7511.js index 03813dea003eaf..6194da291c7ae4 100644 --- a/test/parallel/test-regress-GH-7511.js +++ b/test/parallel/test-regress-GH-7511.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'), - vm = require('vm'); +const assert = require('assert'); +const vm = require('vm'); assert.doesNotThrow(function() { var context = vm.createContext({ process: process }); diff --git a/test/parallel/test-repl-console.js b/test/parallel/test-repl-console.js index fe737d841e1651..609822703fef1e 100644 --- a/test/parallel/test-repl-console.js +++ b/test/parallel/test-repl-console.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common'), - assert = require('assert'), - repl = require('repl'); +const common = require('../common'); +const assert = require('assert'); +const repl = require('repl'); // Create a dummy stream that does nothing const stream = new common.ArrayStream(); diff --git a/test/parallel/test-repl-definecommand.js b/test/parallel/test-repl-definecommand.js index a28689a55d1b1e..c0e1b3269a39d2 100644 --- a/test/parallel/test-repl-definecommand.js +++ b/test/parallel/test-repl-definecommand.js @@ -2,9 +2,9 @@ require('../common'); -const stream = require('stream'), - assert = require('assert'), - repl = require('repl'); +const stream = require('stream'); +const assert = require('assert'); +const repl = require('repl'); var output = ''; const inputStream = new stream.PassThrough(); diff --git a/test/parallel/test-repl-end-emits-exit.js b/test/parallel/test-repl-end-emits-exit.js index 2c18b413d68c0f..7f2c4b9eb2893f 100644 --- a/test/parallel/test-repl-end-emits-exit.js +++ b/test/parallel/test-repl-end-emits-exit.js @@ -1,9 +1,9 @@ 'use strict'; -var common = require('../common'), - assert = require('assert'), - repl = require('repl'), - terminalExit = 0, - regularExit = 0; +const common = require('../common'); +const assert = require('assert'); +const repl = require('repl'); +let terminalExit = 0; +let regularExit = 0; // Create a dummy stream that does nothing const stream = new common.ArrayStream(); diff --git a/test/parallel/test-repl-envvars.js b/test/parallel/test-repl-envvars.js index 2c34bbf2da86fa..759b4e15a12f46 100644 --- a/test/parallel/test-repl-envvars.js +++ b/test/parallel/test-repl-envvars.js @@ -8,30 +8,32 @@ const REPL = require('internal/repl'); const assert = require('assert'); const inspect = require('util').inspect; -const tests = [{ - env: {}, - expected: { terminal: true, useColors: true } -}, -{ - env: { NODE_DISABLE_COLORS: '1' }, - expected: { terminal: true, useColors: false } -}, -{ - env: { NODE_NO_READLINE: '1' }, - expected: { terminal: false, useColors: false } -}, -{ - env: { TERM: 'dumb' }, - expected: { terminal: true, useColors: false } -}, -{ - env: { NODE_NO_READLINE: '1', NODE_DISABLE_COLORS: '1' }, - expected: { terminal: false, useColors: false } -}, -{ - env: { NODE_NO_READLINE: '0' }, - expected: { terminal: true, useColors: true } -}]; +const tests = [ + { + env: {}, + expected: { terminal: true, useColors: true } + }, + { + env: { NODE_DISABLE_COLORS: '1' }, + expected: { terminal: true, useColors: false } + }, + { + env: { NODE_NO_READLINE: '1' }, + expected: { terminal: false, useColors: false } + }, + { + env: { TERM: 'dumb' }, + expected: { terminal: true, useColors: false } + }, + { + env: { NODE_NO_READLINE: '1', NODE_DISABLE_COLORS: '1' }, + expected: { terminal: false, useColors: false } + }, + { + env: { NODE_NO_READLINE: '0' }, + expected: { terminal: true, useColors: true } + } +]; function run(test) { const env = test.env; diff --git a/test/parallel/test-repl-options.js b/test/parallel/test-repl-options.js index ec3b144ec0ef77..395cd3e3675635 100644 --- a/test/parallel/test-repl-options.js +++ b/test/parallel/test-repl-options.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common'), - assert = require('assert'), - repl = require('repl'); +const common = require('../common'); +const assert = require('assert'); +const repl = require('repl'); common.globalCheck = false; diff --git a/test/parallel/test-repl-persistent-history.js b/test/parallel/test-repl-persistent-history.js index 7571527b73800d..81e728974f179d 100644 --- a/test/parallel/test-repl-persistent-history.js +++ b/test/parallel/test-repl-persistent-history.js @@ -79,107 +79,109 @@ const enoentHistoryPath = path.join(fixtures, 'enoent-repl-history-file.json'); const emptyHistoryPath = path.join(fixtures, '.empty-repl-history-file'); const defaultHistoryPath = path.join(common.tmpDir, '.node_repl_history'); -const tests = [{ - env: { NODE_REPL_HISTORY: '' }, - test: [UP], - expected: [prompt, replDisabled, prompt] -}, -{ - env: { NODE_REPL_HISTORY: '', - NODE_REPL_HISTORY_FILE: enoentHistoryPath }, - test: [UP], - expected: [prompt, replDisabled, prompt] -}, -{ - env: { NODE_REPL_HISTORY: '', - NODE_REPL_HISTORY_FILE: oldHistoryPath }, - test: [UP], - expected: [prompt, replDisabled, prompt] -}, -{ - env: { NODE_REPL_HISTORY_FILE: emptyHistoryPath }, - test: [UP], - expected: [prompt, convertMsg, prompt] -}, -{ - env: { NODE_REPL_HISTORY_FILE: defaultHistoryPath }, - test: [UP], - expected: [prompt, sameHistoryFilePaths, prompt] -}, -{ - env: { NODE_REPL_HISTORY: historyPath }, - test: [UP, CLEAR], - expected: [prompt, prompt + '\'you look fabulous today\'', prompt] -}, -{ - env: { NODE_REPL_HISTORY: historyPath, - NODE_REPL_HISTORY_FILE: oldHistoryPath }, - test: [UP, CLEAR], - expected: [prompt, prompt + '\'you look fabulous today\'', prompt] -}, -{ - env: { NODE_REPL_HISTORY: historyPath, - NODE_REPL_HISTORY_FILE: '' }, - test: [UP, CLEAR], - expected: [prompt, prompt + '\'you look fabulous today\'', prompt] -}, -{ - env: {}, - test: [UP], - expected: [prompt] -}, -{ - env: { NODE_REPL_HISTORY_FILE: oldHistoryPath }, - test: [UP, CLEAR, '\'42\'', ENTER], - expected: [prompt, convertMsg, prompt, prompt + '\'=^.^=\'', prompt, '\'', - '4', '2', '\'', '\'42\'\n', prompt, prompt], - after: function ensureHistoryFixture() { - // XXX(Fishrock123) Make sure nothing weird happened to our fixture - // or it's temporary copy. - // Sometimes this test used to erase the fixture and I'm not sure why. - const history = fs.readFileSync(historyFixturePath, 'utf8'); - assert.strictEqual(history, - '\'you look fabulous today\'\n\'Stay Fresh~\'\n'); - const historyCopy = fs.readFileSync(historyPath, 'utf8'); - assert.strictEqual(historyCopy, '\'you look fabulous today\'' + os.EOL + - '\'Stay Fresh~\'' + os.EOL); - } -}, -{ // Requires the above testcase - env: {}, - test: [UP, UP, ENTER], - expected: [prompt, prompt + '\'42\'', prompt + '\'=^.^=\'', '\'=^.^=\'\n', - prompt] -}, -{ - env: { NODE_REPL_HISTORY: historyPath, - NODE_REPL_HISTORY_SIZE: 1 }, - test: [UP, UP, CLEAR], - expected: [prompt, prompt + '\'you look fabulous today\'', prompt] -}, -{ - env: { NODE_REPL_HISTORY_FILE: oldHistoryPath, - NODE_REPL_HISTORY_SIZE: 1 }, - test: [UP, UP, UP, CLEAR], - expected: [prompt, convertMsg, prompt, prompt + '\'=^.^=\'', prompt] -}, -{ - env: { NODE_REPL_HISTORY: historyPathFail, - NODE_REPL_HISTORY_SIZE: 1 }, - test: [UP], - expected: [prompt, replFailedRead, prompt, replDisabled, prompt] -}, -{ // Make sure this is always the last test, since we change os.homedir() - before: function mockHomedirFailure() { - // Mock os.homedir() failure - os.homedir = function() { - throw new Error('os.homedir() failure'); - }; +const tests = [ + { + env: { NODE_REPL_HISTORY: '' }, + test: [UP], + expected: [prompt, replDisabled, prompt] + }, + { + env: { NODE_REPL_HISTORY: '', + NODE_REPL_HISTORY_FILE: enoentHistoryPath }, + test: [UP], + expected: [prompt, replDisabled, prompt] + }, + { + env: { NODE_REPL_HISTORY: '', + NODE_REPL_HISTORY_FILE: oldHistoryPath }, + test: [UP], + expected: [prompt, replDisabled, prompt] + }, + { + env: { NODE_REPL_HISTORY_FILE: emptyHistoryPath }, + test: [UP], + expected: [prompt, convertMsg, prompt] + }, + { + env: { NODE_REPL_HISTORY_FILE: defaultHistoryPath }, + test: [UP], + expected: [prompt, sameHistoryFilePaths, prompt] + }, + { + env: { NODE_REPL_HISTORY: historyPath }, + test: [UP, CLEAR], + expected: [prompt, prompt + '\'you look fabulous today\'', prompt] + }, + { + env: { NODE_REPL_HISTORY: historyPath, + NODE_REPL_HISTORY_FILE: oldHistoryPath }, + test: [UP, CLEAR], + expected: [prompt, prompt + '\'you look fabulous today\'', prompt] + }, + { + env: { NODE_REPL_HISTORY: historyPath, + NODE_REPL_HISTORY_FILE: '' }, + test: [UP, CLEAR], + expected: [prompt, prompt + '\'you look fabulous today\'', prompt] }, - env: {}, - test: [UP], - expected: [prompt, homedirErr, prompt, replDisabled, prompt] -}]; + { + env: {}, + test: [UP], + expected: [prompt] + }, + { + env: { NODE_REPL_HISTORY_FILE: oldHistoryPath }, + test: [UP, CLEAR, '\'42\'', ENTER], + expected: [prompt, convertMsg, prompt, prompt + '\'=^.^=\'', prompt, '\'', + '4', '2', '\'', '\'42\'\n', prompt, prompt], + after: function ensureHistoryFixture() { + // XXX(Fishrock123) Make sure nothing weird happened to our fixture + // or it's temporary copy. + // Sometimes this test used to erase the fixture and I'm not sure why. + const history = fs.readFileSync(historyFixturePath, 'utf8'); + assert.strictEqual(history, + '\'you look fabulous today\'\n\'Stay Fresh~\'\n'); + const historyCopy = fs.readFileSync(historyPath, 'utf8'); + assert.strictEqual(historyCopy, '\'you look fabulous today\'' + os.EOL + + '\'Stay Fresh~\'' + os.EOL); + } + }, + { // Requires the above testcase + env: {}, + test: [UP, UP, ENTER], + expected: [prompt, prompt + '\'42\'', prompt + '\'=^.^=\'', '\'=^.^=\'\n', + prompt] + }, + { + env: { NODE_REPL_HISTORY: historyPath, + NODE_REPL_HISTORY_SIZE: 1 }, + test: [UP, UP, CLEAR], + expected: [prompt, prompt + '\'you look fabulous today\'', prompt] + }, + { + env: { NODE_REPL_HISTORY_FILE: oldHistoryPath, + NODE_REPL_HISTORY_SIZE: 1 }, + test: [UP, UP, UP, CLEAR], + expected: [prompt, convertMsg, prompt, prompt + '\'=^.^=\'', prompt] + }, + { + env: { NODE_REPL_HISTORY: historyPathFail, + NODE_REPL_HISTORY_SIZE: 1 }, + test: [UP], + expected: [prompt, replFailedRead, prompt, replDisabled, prompt] + }, + { // Make sure this is always the last test, since we change os.homedir() + before: function mockHomedirFailure() { + // Mock os.homedir() failure + os.homedir = function() { + throw new Error('os.homedir() failure'); + }; + }, + env: {}, + test: [UP], + expected: [prompt, homedirErr, prompt, replDisabled, prompt] + } +]; const numtests = tests.length; diff --git a/test/parallel/test-repl-require-cache.js b/test/parallel/test-repl-require-cache.js index c5f317ac268e2f..8a5d384935efd4 100644 --- a/test/parallel/test-repl-require-cache.js +++ b/test/parallel/test-repl-require-cache.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'), - repl = require('repl'); +const assert = require('assert'); +const repl = require('repl'); // https://github.com/joyent/node/issues/3226 diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 0d05de9bc1863d..5a13597e56966e 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -5,17 +5,17 @@ var assert = require('assert'); common.globalCheck = false; common.refreshTmpDir(); -var net = require('net'), - repl = require('repl'), - message = 'Read, Eval, Print Loop', - prompt_unix = 'node via Unix socket> ', - prompt_tcp = 'node via TCP socket> ', - prompt_multiline = '... ', - prompt_npm = 'npm should be run outside of the ' + - 'node repl, in your normal shell.\n' + - '(Press Control-D to exit.)\n', - expect_npm = prompt_npm + prompt_unix, - server_tcp, server_unix, client_tcp, client_unix, timer; +const net = require('net'); +const repl = require('repl'); +const message = 'Read, Eval, Print Loop'; +const prompt_unix = 'node via Unix socket> '; +const prompt_tcp = 'node via TCP socket> '; +const prompt_multiline = '... '; +const prompt_npm = 'npm should be run outside of the ' + + 'node repl, in your normal shell.\n' + + '(Press Control-D to exit.)\n'; +const expect_npm = prompt_npm + prompt_unix; +var server_tcp, server_unix, client_tcp, client_unix, timer; // absolute path to test/fixtures/a.js diff --git a/test/parallel/test-signal-handler.js b/test/parallel/test-signal-handler.js index bcd8256272005b..dc37a8a1f6704a 100644 --- a/test/parallel/test-signal-handler.js +++ b/test/parallel/test-signal-handler.js @@ -10,8 +10,8 @@ if (common.isWindows) { console.log('process.pid: ' + process.pid); -var first = 0, - second = 0; +let first = 0; +let second = 0; var sighup = false; diff --git a/test/parallel/test-stream-writev.js b/test/parallel/test-stream-writev.js index 5b07dd11198e1a..2aa992b4a9a785 100644 --- a/test/parallel/test-stream-writev.js +++ b/test/parallel/test-stream-writev.js @@ -44,24 +44,24 @@ function test(decode, uncork, multi, next) { }; var expectChunks = decode ? - [ - { encoding: 'buffer', - chunk: [104, 101, 108, 108, 111, 44, 32] }, - { encoding: 'buffer', - chunk: [119, 111, 114, 108, 100] }, - { encoding: 'buffer', - chunk: [33] }, - { encoding: 'buffer', - chunk: [10, 97, 110, 100, 32, 116, 104, 101, 110, 46, 46, 46] }, - { encoding: 'buffer', - chunk: [250, 206, 190, 167, 222, 173, 190, 239, 222, 202, 251, 173]} - ] : [ - { encoding: 'ascii', chunk: 'hello, ' }, - { encoding: 'utf8', chunk: 'world' }, - { encoding: 'buffer', chunk: [33] }, - { encoding: 'binary', chunk: '\nand then...' }, - { encoding: 'hex', chunk: 'facebea7deadbeefdecafbad' } - ]; + [ + { encoding: 'buffer', + chunk: [104, 101, 108, 108, 111, 44, 32] }, + { encoding: 'buffer', + chunk: [119, 111, 114, 108, 100] }, + { encoding: 'buffer', + chunk: [33] }, + { encoding: 'buffer', + chunk: [10, 97, 110, 100, 32, 116, 104, 101, 110, 46, 46, 46] }, + { encoding: 'buffer', + chunk: [250, 206, 190, 167, 222, 173, 190, 239, 222, 202, 251, 173]} + ] : [ + { encoding: 'ascii', chunk: 'hello, ' }, + { encoding: 'utf8', chunk: 'world' }, + { encoding: 'buffer', chunk: [33] }, + { encoding: 'binary', chunk: '\nand then...' }, + { encoding: 'hex', chunk: 'facebea7deadbeefdecafbad' } + ]; var actualChunks; w._writev = function(chunks, cb) { diff --git a/test/parallel/test-stringbytes-external-at-max.js b/test/parallel/test-stringbytes-external-at-max.js index 31f476d66b18ba..5467d05a20104a 100644 --- a/test/parallel/test-stringbytes-external-at-max.js +++ b/test/parallel/test-stringbytes-external-at-max.js @@ -21,7 +21,7 @@ try { // Try to allocate memory first then force gc so future allocations succeed. new Buffer(2 * kStringMaxLength); gc(); -} catch(e) { +} catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Invalid array buffer length') throw (e); console.log(skipMessage); diff --git a/test/parallel/test-stringbytes-external-exceed-max-by-1-ascii.js b/test/parallel/test-stringbytes-external-exceed-max-by-1-ascii.js index 4789089d5e0040..af47a8e779a7a4 100644 --- a/test/parallel/test-stringbytes-external-exceed-max-by-1-ascii.js +++ b/test/parallel/test-stringbytes-external-exceed-max-by-1-ascii.js @@ -21,7 +21,7 @@ try { // Try to allocate memory first then force gc so future allocations succeed. new Buffer(2 * kStringMaxLength); gc(); -} catch(e) { +} catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Invalid array buffer length') throw (e); console.log(skipMessage); diff --git a/test/parallel/test-stringbytes-external-exceed-max-by-1-base64.js b/test/parallel/test-stringbytes-external-exceed-max-by-1-base64.js index 8f52d6ac30dd9f..fb599875a0459b 100644 --- a/test/parallel/test-stringbytes-external-exceed-max-by-1-base64.js +++ b/test/parallel/test-stringbytes-external-exceed-max-by-1-base64.js @@ -21,7 +21,7 @@ try { // Try to allocate memory first then force gc so future allocations succeed. new Buffer(2 * kStringMaxLength); gc(); -} catch(e) { +} catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Invalid array buffer length') throw (e); console.log(skipMessage); diff --git a/test/parallel/test-stringbytes-external-exceed-max-by-1-binary.js b/test/parallel/test-stringbytes-external-exceed-max-by-1-binary.js index 79dac9cc41dcf0..f4904b672cfea7 100644 --- a/test/parallel/test-stringbytes-external-exceed-max-by-1-binary.js +++ b/test/parallel/test-stringbytes-external-exceed-max-by-1-binary.js @@ -21,7 +21,7 @@ try { // Try to allocate memory first then force gc so future allocations succeed. new Buffer(2 * kStringMaxLength); gc(); -} catch(e) { +} catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Invalid array buffer length') throw (e); console.log(skipMessage); diff --git a/test/parallel/test-stringbytes-external-exceed-max-by-1-hex.js b/test/parallel/test-stringbytes-external-exceed-max-by-1-hex.js index 50d0dad5829160..9dd9d23565acf2 100644 --- a/test/parallel/test-stringbytes-external-exceed-max-by-1-hex.js +++ b/test/parallel/test-stringbytes-external-exceed-max-by-1-hex.js @@ -21,7 +21,7 @@ try { // Try to allocate memory first then force gc so future allocations succeed. new Buffer(2 * kStringMaxLength); gc(); -} catch(e) { +} catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Invalid array buffer length') throw (e); console.log(skipMessage); diff --git a/test/parallel/test-stringbytes-external-exceed-max-by-1-utf8.js b/test/parallel/test-stringbytes-external-exceed-max-by-1-utf8.js index ecd6eaf954e191..3ff6f4978878ee 100644 --- a/test/parallel/test-stringbytes-external-exceed-max-by-1-utf8.js +++ b/test/parallel/test-stringbytes-external-exceed-max-by-1-utf8.js @@ -21,7 +21,7 @@ try { // Try to allocate memory first then force gc so future allocations succeed. new Buffer(2 * kStringMaxLength); gc(); -} catch(e) { +} catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Invalid array buffer length') throw (e); console.log(skipMessage); diff --git a/test/parallel/test-stringbytes-external-exceed-max-by-2.js b/test/parallel/test-stringbytes-external-exceed-max-by-2.js index 8350c4532eafdc..1ac5a5c7fe1ced 100644 --- a/test/parallel/test-stringbytes-external-exceed-max-by-2.js +++ b/test/parallel/test-stringbytes-external-exceed-max-by-2.js @@ -21,7 +21,7 @@ try { // Try to allocate memory first then force gc so future allocations succeed. new Buffer(2 * kStringMaxLength); gc(); -} catch(e) { +} catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Invalid array buffer length') throw (e); console.log(skipMessage); diff --git a/test/parallel/test-stringbytes-external-exceed-max.js b/test/parallel/test-stringbytes-external-exceed-max.js index fd19cfb9e20697..61666b8ebc6b48 100644 --- a/test/parallel/test-stringbytes-external-exceed-max.js +++ b/test/parallel/test-stringbytes-external-exceed-max.js @@ -21,7 +21,7 @@ try { // Try to allocate memory first then force gc so future allocations succeed. new Buffer(2 * kStringMaxLength); gc(); -} catch(e) { +} catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Invalid array buffer length') throw (e); console.log(skipMessage); diff --git a/test/parallel/test-timers-immediate.js b/test/parallel/test-timers-immediate.js index 9486465602ce9b..40e91a099815b6 100644 --- a/test/parallel/test-timers-immediate.js +++ b/test/parallel/test-timers-immediate.js @@ -2,15 +2,15 @@ require('../common'); var assert = require('assert'); -var immediateA = false, - immediateB = false, - immediateC = [], - before; +let immediateA = false; +let immediateB = false; +let immediateC = []; +let before; setImmediate(function() { try { immediateA = process.hrtime(before); - } catch(e) { + } catch (e) { console.log('failed to get hrtime with offset'); } clearImmediate(immediateB); diff --git a/test/parallel/test-timers-this.js b/test/parallel/test-timers-this.js index 1882f116fecd2d..e21167581e8944 100644 --- a/test/parallel/test-timers-this.js +++ b/test/parallel/test-timers-this.js @@ -2,8 +2,8 @@ require('../common'); var assert = require('assert'); -var immediateThis, intervalThis, timeoutThis, - immediateArgsThis, intervalArgsThis, timeoutArgsThis; +let immediateThis, intervalThis, timeoutThis; +let immediateArgsThis, intervalArgsThis, timeoutArgsThis; var immediateHandler = setImmediate(function() { immediateThis = this; diff --git a/test/parallel/test-timers-unref.js b/test/parallel/test-timers-unref.js index 671c676e350e3a..134b2ffe4c3967 100644 --- a/test/parallel/test-timers-unref.js +++ b/test/parallel/test-timers-unref.js @@ -2,12 +2,12 @@ require('../common'); var assert = require('assert'); -var interval_fired = false, - timeout_fired = false, - unref_interval = false, - unref_timer = false, - unref_callbacks = 0, - interval, check_unref, checks = 0; +let interval_fired = false; +let timeout_fired = false; +let unref_interval = false; +let unref_timer = false; +let unref_callbacks = 0; +let interval, check_unref, checks = 0; var LONG_TIME = 10 * 1000; var SHORT_TIME = 100; diff --git a/test/parallel/test-tls-connect-no-host.js b/test/parallel/test-tls-connect-no-host.js index 75870bea98b4b5..a6ead6ea6dceae 100644 --- a/test/parallel/test-tls-connect-no-host.js +++ b/test/parallel/test-tls-connect-no-host.js @@ -23,12 +23,12 @@ tls.createServer({ }).listen(common.PORT); var socket = tls.connect({ - port: common.PORT, - ca: cert, - // No host set here. 'localhost' is the default, - // but tls.checkServerIdentity() breaks before the fix with: - // Error: Hostname/IP doesn't match certificate's altnames: - // "Host: undefined. is not cert's CN: localhost" + port: common.PORT, + ca: cert, + // No host set here. 'localhost' is the default, + // but tls.checkServerIdentity() breaks before the fix with: + // Error: Hostname/IP doesn't match certificate's altnames: + // "Host: undefined. is not cert's CN: localhost" }, function() { assert(socket.authorized); process.exit(); diff --git a/test/parallel/test-tls-connect-stream-writes.js b/test/parallel/test-tls-connect-stream-writes.js index 4187c9b439e2f1..8fabc7edaeeda0 100644 --- a/test/parallel/test-tls-connect-stream-writes.js +++ b/test/parallel/test-tls-connect-stream-writes.js @@ -1,16 +1,15 @@ 'use strict'; -var assert = require('assert'), - fs = require('fs'), - path = require('path'), - tls = require('tls'), - stream = require('stream'), - net = require('net'); - -var common = require('../common'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); +const tls = require('tls'); +const stream = require('stream'); +const net = require('net'); var server; -var cert_dir = path.resolve(__dirname, '../fixtures'), - options = { key: fs.readFileSync(cert_dir + '/test_key.pem'), +var cert_dir = path.resolve(__dirname, '../fixtures'); +var options = { key: fs.readFileSync(cert_dir + '/test_key.pem'), cert: fs.readFileSync(cert_dir + '/test_cert.pem'), ca: [ fs.readFileSync(cert_dir + '/test_ca.pem') ], ciphers: 'AES256-GCM-SHA384' }; diff --git a/test/parallel/test-tls-npn-server-client.js b/test/parallel/test-tls-npn-server-client.js index 0a0453633af9ae..211cfc7ed35067 100644 --- a/test/parallel/test-tls-npn-server-client.js +++ b/test/parallel/test-tls-npn-server-client.js @@ -5,9 +5,9 @@ if (!process.features.tls_npn) { return; } -var common = require('../common'), - assert = require('assert'), - fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); if (!common.hasCrypto) { console.log('1..0 # Skipped: missing crypto'); @@ -69,8 +69,8 @@ var clientsOptions = [{ rejectUnauthorized: false }]; -var serverResults = [], - clientsResults = []; +const serverResults = []; +const clientsResults = []; var server = tls.createServer(serverOptions, function(c) { serverResults.push(c.npnProtocol); diff --git a/test/parallel/test-tls-server-verify.js b/test/parallel/test-tls-server-verify.js index fed77357dae04a..c9d4d263f5be7d 100644 --- a/test/parallel/test-tls-server-verify.js +++ b/test/parallel/test-tls-server-verify.js @@ -87,15 +87,14 @@ var testCases = renegotiate: false, CAs: ['ca2-cert'], crl: 'ca2-crl', - clients: - [ + clients: [ { name: 'agent1', shouldReject: true, shouldAuth: false }, { name: 'agent2', shouldReject: true, shouldAuth: false }, { name: 'agent3', shouldReject: false, shouldAuth: true }, // Agent4 has a cert in the CRL. { name: 'agent4', shouldReject: true, shouldAuth: false }, { name: 'nocert', shouldReject: true } - ] + ] } ]; diff --git a/test/parallel/test-tls-sni-option.js b/test/parallel/test-tls-sni-option.js index 8ebc0c3af44705..5b0bd53f4e6343 100644 --- a/test/parallel/test-tls-sni-option.js +++ b/test/parallel/test-tls-sni-option.js @@ -5,9 +5,9 @@ if (!process.features.tls_sni) { return; } -var common = require('../common'), - assert = require('assert'), - fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); if (!common.hasCrypto) { console.log('1..0 # Skipped: missing crypto'); @@ -89,12 +89,12 @@ var clientsOptions = [{ rejectUnauthorized: false }]; -var serverResults = [], - clientResults = [], - serverErrors = [], - clientErrors = [], - serverError, - clientError; +const serverResults = []; +const clientResults = []; +const serverErrors = []; +const clientErrors = []; +let serverError; +let clientError; var server = tls.createServer(serverOptions, function(c) { serverResults.push(c.servername); diff --git a/test/parallel/test-tls-sni-server-client.js b/test/parallel/test-tls-sni-server-client.js index bad5e108784353..8eb80b50e41540 100644 --- a/test/parallel/test-tls-sni-server-client.js +++ b/test/parallel/test-tls-sni-server-client.js @@ -5,9 +5,9 @@ if (!process.features.tls_sni) { return; } -var common = require('../common'), - assert = require('assert'), - fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); if (!common.hasCrypto) { console.log('1..0 # Skipped: missing crypto'); @@ -73,8 +73,8 @@ var clientsOptions = [{ rejectUnauthorized: false }]; -var serverResults = [], - clientResults = []; +const serverResults = []; +const clientResults = []; var server = tls.createServer(serverOptions, function(c) { serverResults.push(c.servername); diff --git a/test/parallel/test-url.js b/test/parallel/test-url.js index cd097be24384eb..9fa087261e0127 100644 --- a/test/parallel/test-url.js +++ b/test/parallel/test-url.js @@ -260,19 +260,19 @@ var parseTests = { }, 'http://user:pass@mt0.google.com/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=': - { - 'href': 'http://user:pass@mt0.google.com/vt/lyrs=m@114???' + - '&hl=en&src=api&x=2&y=2&z=3&s=', - 'protocol': 'http:', - 'slashes': true, - 'host': 'mt0.google.com', - 'auth': 'user:pass', - 'hostname': 'mt0.google.com', - 'search': '???&hl=en&src=api&x=2&y=2&z=3&s=', - 'query': '??&hl=en&src=api&x=2&y=2&z=3&s=', - 'pathname': '/vt/lyrs=m@114', - 'path': '/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=' - }, + { + 'href': 'http://user:pass@mt0.google.com/vt/lyrs=m@114???' + + '&hl=en&src=api&x=2&y=2&z=3&s=', + 'protocol': 'http:', + 'slashes': true, + 'host': 'mt0.google.com', + 'auth': 'user:pass', + 'hostname': 'mt0.google.com', + 'search': '???&hl=en&src=api&x=2&y=2&z=3&s=', + 'query': '??&hl=en&src=api&x=2&y=2&z=3&s=', + 'pathname': '/vt/lyrs=m@114', + 'path': '/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=' + }, 'file:///etc/passwd' : { 'href': 'file:///etc/passwd', @@ -870,8 +870,8 @@ for (var u in parseTests) { assert.deepEqual(actual, expected); assert.deepEqual(spaced, expected); - var expected = parseTests[u].href, - actual = url.format(parseTests[u]); + expected = parseTests[u].href; + actual = url.format(parseTests[u]); assert.equal(actual, expected, 'format(' + u + ') == ' + u + '\nactual:' + actual); @@ -1194,8 +1194,8 @@ var relativeTests = [ ['http://localhost', 'file://foo/Users', 'file://foo/Users'] ]; relativeTests.forEach(function(relativeTest) { - var a = url.resolve(relativeTest[0], relativeTest[1]), - e = relativeTest[2]; + const a = url.resolve(relativeTest[0], relativeTest[1]); + const e = relativeTest[2]; assert.equal(a, e, 'resolve(' + [relativeTest[0], relativeTest[1]] + ') == ' + e + '\n actual=' + a); @@ -1504,8 +1504,8 @@ var relativeTests2 = [ 'http://diff:auth@www.example.com/'] ]; relativeTests2.forEach(function(relativeTest) { - var a = url.resolve(relativeTest[1], relativeTest[0]), - e = relativeTest[2]; + const a = url.resolve(relativeTest[1], relativeTest[0]); + const e = relativeTest[2]; assert.equal(a, e, 'resolve(' + [relativeTest[1], relativeTest[0]] + ') == ' + e + '\n actual=' + a); @@ -1516,8 +1516,8 @@ relativeTests2.forEach(function(relativeTest) { //format: [from, path, expected] relativeTests.forEach(function(relativeTest) { - var actual = url.resolveObject(url.parse(relativeTest[0]), relativeTest[1]), - expected = url.parse(relativeTest[2]); + var actual = url.resolveObject(url.parse(relativeTest[0]), relativeTest[1]); + var expected = url.parse(relativeTest[2]); assert.deepEqual(actual, expected); @@ -1544,13 +1544,13 @@ if (relativeTests2[181][0] === './/g' && relativeTests2.splice(181, 1); } relativeTests2.forEach(function(relativeTest) { - var actual = url.resolveObject(url.parse(relativeTest[1]), relativeTest[0]), - expected = url.parse(relativeTest[2]); + var actual = url.resolveObject(url.parse(relativeTest[1]), relativeTest[0]); + var expected = url.parse(relativeTest[2]); assert.deepEqual(actual, expected); - var expected = relativeTest[2], - actual = url.format(actual); + expected = relativeTest[2]; + actual = url.format(actual); assert.equal(actual, expected, 'format(' + relativeTest[1] + ') == ' + expected + diff --git a/test/parallel/test-util-log.js b/test/parallel/test-util-log.js index fbea5e5a31dbe4..b9e3d9ce3505e0 100644 --- a/test/parallel/test-util-log.js +++ b/test/parallel/test-util-log.js @@ -28,9 +28,9 @@ var tests = [ // test util.log() tests.forEach(function(test) { util.log(test.input); - var result = strings.shift().trim(), - re = (/[0-9]{1,2} [A-Z][a-z]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} - (.+)$/), - match = re.exec(result); + const result = strings.shift().trim(); + const re = (/[0-9]{1,2} [A-Z][a-z]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} - (.+)$/); + const match = re.exec(result); assert.ok(match); assert.equal(match[1], test.output); }); diff --git a/test/parallel/test-zlib-flush.js b/test/parallel/test-zlib-flush.js index 6281b8eb21feb2..69f734617e925e 100644 --- a/test/parallel/test-zlib-flush.js +++ b/test/parallel/test-zlib-flush.js @@ -5,18 +5,18 @@ var zlib = require('zlib'); var path = require('path'); var fs = require('fs'); -var file = fs.readFileSync(path.resolve(common.fixturesDir, 'person.jpg')), - chunkSize = 16, - opts = { level: 0 }, - deflater = zlib.createDeflate(opts); +const file = fs.readFileSync(path.resolve(common.fixturesDir, 'person.jpg')); +const chunkSize = 16; +const opts = { level: 0 }; +const deflater = zlib.createDeflate(opts); -var chunk = file.slice(0, chunkSize), - expectedNone = new Buffer([0x78, 0x01]), - blkhdr = new Buffer([0x00, 0x10, 0x00, 0xef, 0xff]), - adler32 = new Buffer([0x00, 0x00, 0x00, 0xff, 0xff]), - expectedFull = Buffer.concat([blkhdr, chunk, adler32]), - actualNone, - actualFull; +const chunk = file.slice(0, chunkSize); +const expectedNone = new Buffer([0x78, 0x01]); +const blkhdr = new Buffer([0x00, 0x10, 0x00, 0xef, 0xff]); +const adler32 = new Buffer([0x00, 0x00, 0x00, 0xff, 0xff]); +const expectedFull = Buffer.concat([blkhdr, chunk, adler32]); +let actualNone; +let actualFull; deflater.write(chunk, function() { deflater.flush(zlib.Z_NO_FLUSH, function() { diff --git a/test/parallel/test-zlib-invalid-input.js b/test/parallel/test-zlib-invalid-input.js index 9850c6078c5320..91d4efd38831ac 100644 --- a/test/parallel/test-zlib-invalid-input.js +++ b/test/parallel/test-zlib-invalid-input.js @@ -2,8 +2,8 @@ // test uncompressing invalid input require('../common'); -var assert = require('assert'), - zlib = require('zlib'); +const assert = require('assert'); +const zlib = require('zlib'); var nonStringInputs = [1, true, {a: 1}, ['a']]; diff --git a/test/parallel/test-zlib-params.js b/test/parallel/test-zlib-params.js index f349c8dbd0afec..4e02b7bdb9461c 100644 --- a/test/parallel/test-zlib-params.js +++ b/test/parallel/test-zlib-params.js @@ -5,16 +5,16 @@ var zlib = require('zlib'); var path = require('path'); var fs = require('fs'); -var file = fs.readFileSync(path.resolve(common.fixturesDir, 'person.jpg')), - chunkSize = 24 * 1024, - opts = { level: 9, strategy: zlib.Z_DEFAULT_STRATEGY }, - deflater = zlib.createDeflate(opts); +const file = fs.readFileSync(path.resolve(common.fixturesDir, 'person.jpg')); +const chunkSize = 24 * 1024; +const opts = { level: 9, strategy: zlib.Z_DEFAULT_STRATEGY }; +const deflater = zlib.createDeflate(opts); -var chunk1 = file.slice(0, chunkSize), - chunk2 = file.slice(chunkSize), - blkhdr = new Buffer([0x00, 0x48, 0x82, 0xb7, 0x7d]), - expected = Buffer.concat([blkhdr, chunk2]), - actual; +const chunk1 = file.slice(0, chunkSize); +const chunk2 = file.slice(chunkSize); +const blkhdr = new Buffer([0x00, 0x48, 0x82, 0xb7, 0x7d]); +const expected = Buffer.concat([blkhdr, chunk2]); +let actual; deflater.write(chunk1, function() { deflater.params(0, zlib.Z_DEFAULT_STRATEGY, function() { diff --git a/test/pummel/test-dh-regr.js b/test/pummel/test-dh-regr.js index 6fdd416b183669..e6b2f82bd9e465 100644 --- a/test/pummel/test-dh-regr.js +++ b/test/pummel/test-dh-regr.js @@ -11,8 +11,8 @@ var crypto = require('crypto'); var p = crypto.createDiffieHellman(1024).getPrime(); for (var i = 0; i < 2000; i++) { - var a = crypto.createDiffieHellman(p), - b = crypto.createDiffieHellman(p); + const a = crypto.createDiffieHellman(p); + const b = crypto.createDiffieHellman(p); a.generateKeys(); b.generateKeys(); diff --git a/test/pummel/test-exec.js b/test/pummel/test-exec.js index 0ff1e2a7cf61b7..994d859f408d84 100644 --- a/test/pummel/test-exec.js +++ b/test/pummel/test-exec.js @@ -17,19 +17,21 @@ var success_count = 0; var error_count = 0; -exec('"' + process.execPath + '" -p -e process.versions', - function(err, stdout, stderr) { - if (err) { - error_count++; - console.log('error!: ' + err.code); - console.log('stdout: ' + JSON.stringify(stdout)); - console.log('stderr: ' + JSON.stringify(stderr)); - assert.equal(false, err.killed); - } else { - success_count++; - console.dir(stdout); +exec( + '"' + process.execPath + '" -p -e process.versions', + function(err, stdout, stderr) { + if (err) { + error_count++; + console.log('error!: ' + err.code); + console.log('stdout: ' + JSON.stringify(stdout)); + console.log('stderr: ' + JSON.stringify(stderr)); + assert.equal(false, err.killed); + } else { + success_count++; + console.dir(stdout); + } } -}); +); exec('thisisnotavalidcommand', function(err, stdout, stderr) { diff --git a/test/pummel/test-fs-watch-file-slow.js b/test/pummel/test-fs-watch-file-slow.js index cd4b16bf310b99..c21785f233c58f 100644 --- a/test/pummel/test-fs-watch-file-slow.js +++ b/test/pummel/test-fs-watch-file-slow.js @@ -19,19 +19,19 @@ catch (e) { fs.watchFile(FILENAME, {interval:TIMEOUT - 250}, function(curr, prev) { console.log([curr, prev]); switch (++nevents) { - case 1: - assert.equal(common.fileExists(FILENAME), false); - break; - case 2: - case 3: - assert.equal(common.fileExists(FILENAME), true); - break; - case 4: - assert.equal(common.fileExists(FILENAME), false); - fs.unwatchFile(FILENAME); - break; - default: - assert(0); + case 1: + assert.equal(common.fileExists(FILENAME), false); + break; + case 2: + case 3: + assert.equal(common.fileExists(FILENAME), true); + break; + case 4: + assert.equal(common.fileExists(FILENAME), false); + fs.unwatchFile(FILENAME); + break; + default: + assert(0); } }); diff --git a/test/pummel/test-http-client-reconnect-bug.js b/test/pummel/test-http-client-reconnect-bug.js index 12a6fecc7050e8..7b9b8b0da1bcb0 100644 --- a/test/pummel/test-http-client-reconnect-bug.js +++ b/test/pummel/test-http-client-reconnect-bug.js @@ -1,9 +1,8 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); - -var net = require('net'), - http = require('http'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); +const http = require('http'); var errorCount = 0; var eofCount = 0; diff --git a/test/pummel/test-http-upload-timeout.js b/test/pummel/test-http-upload-timeout.js index d1be5311db0c00..6e5a7ed0506ffd 100644 --- a/test/pummel/test-http-upload-timeout.js +++ b/test/pummel/test-http-upload-timeout.js @@ -2,10 +2,10 @@ // This tests setTimeout() by having multiple clients connecting and sending // data in random intervals. Clients are also randomly disconnecting until there // are no more clients left. If no false timeout occurs, this test has passed. -var common = require('../common'), - http = require('http'), - server = http.createServer(), - connections = 0; +const common = require('../common'); +const http = require('http'); +const server = http.createServer(); +let connections = 0; server.on('request', function(req, res) { req.socket.setTimeout(1000); diff --git a/test/sequential/test-child-process-execsync.js b/test/sequential/test-child-process-execsync.js index 205485c9ebbc48..784f2faf8cc373 100644 --- a/test/sequential/test-child-process-execsync.js +++ b/test/sequential/test-child-process-execsync.js @@ -12,8 +12,7 @@ var start = Date.now(); var err; var caught = false; -try -{ +try { var cmd = `"${process.execPath}" -e "setTimeout(function(){}, ${SLEEP});"`; var ret = execSync(cmd, {timeout: TIMER}); } catch (e) { diff --git a/test/sequential/test-init.js b/test/sequential/test-init.js index f68c001f64fffa..6bb727ea1f6184 100644 --- a/test/sequential/test-init.js +++ b/test/sequential/test-init.js @@ -1,9 +1,9 @@ 'use strict'; (function() { - var assert = require('assert'), - child = require('child_process'), - util = require('util'), - common = require('../common'); + const assert = require('assert'); + const child = require('child_process'); + const util = require('util'); + const common = require('../common'); if (process.env['TEST_INIT']) { util.print('Loaded successfully!'); } else { diff --git a/test/sequential/test-module-loading.js b/test/sequential/test-module-loading.js index ead3447320c50a..2235a068ca23f0 100644 --- a/test/sequential/test-module-loading.js +++ b/test/sequential/test-module-loading.js @@ -57,14 +57,14 @@ assert.equal('D', d4.D()); assert.ok((new a.SomeClass()) instanceof c.SomeClass); console.error('test index.js modules ids and relative loading'); -var one = require('../fixtures/nested-index/one'), - two = require('../fixtures/nested-index/two'); +const one = require('../fixtures/nested-index/one'); +const two = require('../fixtures/nested-index/two'); assert.notEqual(one.hello, two.hello); console.error('test index.js in a folder with a trailing slash'); -var three = require('../fixtures/nested-index/three'), - threeFolder = require('../fixtures/nested-index/three/'), - threeIndex = require('../fixtures/nested-index/three/index.js'); +const three = require('../fixtures/nested-index/three'); +const threeFolder = require('../fixtures/nested-index/three/'); +const threeIndex = require('../fixtures/nested-index/three/index.js'); assert.equal(threeFolder, threeIndex); assert.notEqual(threeFolder, three); @@ -75,8 +75,8 @@ assert.equal(require('../fixtures/packages/main-index').ok, 'ok', 'Failed loading package with index.js in main subdir'); console.error('test cycles containing a .. path'); -var root = require('../fixtures/cycles/root'), - foo = require('../fixtures/cycles/folder/foo'); +const root = require('../fixtures/cycles/root'); +const foo = require('../fixtures/cycles/folder/foo'); assert.equal(root.foo, foo); assert.equal(root.sayHello(), root.hello); @@ -141,8 +141,8 @@ try { // Check load order is as expected console.error('load order'); -var loadOrder = '../fixtures/module-load-order/', - msg = 'Load order incorrect.'; +const loadOrder = '../fixtures/module-load-order/'; +const msg = 'Load order incorrect.'; require.extensions['.reg'] = require.extensions['.js']; require.extensions['.reg2'] = require.extensions['.js']; diff --git a/test/sequential/test-regress-GH-1697.js b/test/sequential/test-regress-GH-1697.js index ba7f90ecf00951..bafd389fa8deee 100644 --- a/test/sequential/test-regress-GH-1697.js +++ b/test/sequential/test-regress-GH-1697.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common'); -var net = require('net'), - cp = require('child_process'); +const common = require('../common'); +const net = require('net'); +const cp = require('child_process'); if (process.argv[2] === 'server') { // Server @@ -30,8 +30,8 @@ if (process.argv[2] === 'server') { serverProcess.stdout.once('data', function() { var client = net.createConnection(common.PORT, '127.0.0.1'); client.on('connect', function() { - var alot = new Buffer(1024), - alittle = new Buffer(1); + const alot = new Buffer(1024); + const alittle = new Buffer(1); for (var i = 0; i < 100; i++) { client.write(alot); diff --git a/test/sequential/test-regress-GH-3542.js b/test/sequential/test-regress-GH-3542.js index 2025645ae75d92..77b8cdd69817ac 100644 --- a/test/sequential/test-regress-GH-3542.js +++ b/test/sequential/test-regress-GH-3542.js @@ -1,9 +1,9 @@ 'use strict'; -var common = require('../common'), - assert = require('assert'), - fs = require('fs'), - path = require('path'), - succeeded = 0; +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); +let succeeded = 0; // This test is only relevant on Windows. if (!common.isWindows) {