Browse Source

test: use eslint to fix var->const/let

Manually fix issues that eslint --fix couldn't do automatically.

PR-URL: https://github.com/nodejs/node/pull/10685
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
v6
Gibson Fahnestock 8 years ago
parent
commit
7a0e462f9f
  1. 4
      test/addons/buffer-free-callback/test.js
  2. 6
      test/addons/load-long-path/test.js
  3. 2
      test/addons/make-callback-recurse/test.js
  4. 14
      test/addons/repl-domain-abort/test.js
  5. 3
      test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js
  6. 3
      test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js
  7. 3
      test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js
  8. 5
      test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js
  9. 3
      test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js
  10. 3
      test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js
  11. 3
      test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js
  12. 3
      test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js
  13. 2
      test/common.js
  14. 28
      test/debugger/helper-debugger-repl.js
  15. 4
      test/debugger/test-debugger-repl-restart.js
  16. 2
      test/debugger/test-debugger-repl-term.js
  17. 2
      test/debugger/test-debugger-repl-utf8.js
  18. 2
      test/debugger/test-debugger-repl.js
  19. 8
      test/gc/test-http-client-connaborted.js
  20. 8
      test/gc/test-http-client-onerror.js
  21. 8
      test/gc/test-http-client-timeout.js
  22. 6
      test/gc/test-http-client.js
  23. 7
      test/gc/test-net-timeout.js
  24. 4
      test/inspector/inspector-helper.js
  25. 19
      test/internet/test-dgram-multicast-multi-process.js
  26. 6
      test/internet/test-dgram-send-cb-quelches-error.js
  27. 4
      test/internet/test-dns-cares-domains.js
  28. 96
      test/internet/test-dns.js
  29. 8
      test/internet/test-net-connect-timeout.js
  30. 5
      test/internet/test-net-connect-unref.js
  31. 2
      test/internet/test-tls-connnect-melissadata.js
  32. 8
      test/known_issues/test-url-parse-conformance.js
  33. 8
      test/message/eval_messages.js
  34. 2
      test/message/max_tick_depth.js
  35. 8
      test/message/stdin_messages.js
  36. 2
      test/parallel/test-assert-typedarray-deepequal.js
  37. 31
      test/parallel/test-assert.js
  38. 2
      test/parallel/test-async-wrap-check-providers.js
  39. 6
      test/parallel/test-async-wrap-throw-from-callback.js
  40. 2
      test/parallel/test-async-wrap-uid.js
  41. 2
      test/parallel/test-buffer-ascii.js
  42. 26
      test/parallel/test-buffer-bytelength.js
  43. 2
      test/parallel/test-buffer-concat.js
  44. 2
      test/parallel/test-buffer-copy.js
  45. 6
      test/parallel/test-buffer-fill.js
  46. 10
      test/parallel/test-buffer-includes.js
  47. 39
      test/parallel/test-buffer-indexof.js
  48. 6
      test/parallel/test-buffer-inspect.js
  49. 4
      test/parallel/test-buffer-iterator.js
  50. 48
      test/parallel/test-buffer-swap.js
  51. 4
      test/parallel/test-child-process-constructor.js
  52. 4
      test/parallel/test-child-process-default-options.js
  53. 4
      test/parallel/test-child-process-double-pipe.js
  54. 6
      test/parallel/test-child-process-env.js
  55. 2
      test/parallel/test-child-process-exec-cwd.js
  56. 4
      test/parallel/test-child-process-exec-stdout-stderr-data-string.js
  57. 10
      test/parallel/test-child-process-exit-code.js
  58. 2
      test/parallel/test-child-process-fork-close.js
  59. 4
      test/parallel/test-child-process-fork-dgram.js
  60. 12
      test/parallel/test-child-process-fork-exec-argv.js
  61. 8
      test/parallel/test-child-process-fork-exec-path.js
  62. 32
      test/parallel/test-child-process-fork-net.js
  63. 22
      test/parallel/test-child-process-fork-net2.js
  64. 5
      test/parallel/test-child-process-fork-ref.js
  65. 2
      test/parallel/test-child-process-fork-ref2.js
  66. 6
      test/parallel/test-child-process-fork-regr-gh-2847.js
  67. 4
      test/parallel/test-child-process-fork.js
  68. 8
      test/parallel/test-child-process-internal.js
  69. 2
      test/parallel/test-child-process-send-returns-boolean.js
  70. 4
      test/parallel/test-child-process-set-blocking.js
  71. 12
      test/parallel/test-child-process-silent.js
  72. 2
      test/parallel/test-child-process-spawn-typeerror.js
  73. 4
      test/parallel/test-child-process-spawnsync-env.js
  74. 4
      test/parallel/test-child-process-spawnsync-input.js
  75. 10
      test/parallel/test-child-process-spawnsync-timeout.js
  76. 2
      test/parallel/test-child-process-stdin-ipc.js
  77. 3
      test/parallel/test-child-process-stdio-big-write-end.js
  78. 6
      test/parallel/test-child-process-stdio-inherit.js
  79. 4
      test/parallel/test-cli-eval.js
  80. 20
      test/parallel/test-cli-syntax.js
  81. 5
      test/parallel/test-cluster-basic.js
  82. 2
      test/parallel/test-cluster-bind-privileged-port.js
  83. 12
      test/parallel/test-cluster-dgram-1.js
  84. 6
      test/parallel/test-cluster-dgram-2.js
  85. 6
      test/parallel/test-cluster-dgram-reuse.js
  86. 6
      test/parallel/test-cluster-disconnect-race.js
  87. 2
      test/parallel/test-cluster-disconnect-suicide-race.js
  88. 2
      test/parallel/test-cluster-disconnect-with-no-workers.js
  89. 16
      test/parallel/test-cluster-disconnect.js
  90. 2
      test/parallel/test-cluster-eaccess.js
  91. 4
      test/parallel/test-cluster-eaddrinuse.js
  92. 4
      test/parallel/test-cluster-fork-env.js
  93. 10
      test/parallel/test-cluster-master-error.js
  94. 4
      test/parallel/test-cluster-master-kill.js
  95. 14
      test/parallel/test-cluster-message.js
  96. 5
      test/parallel/test-cluster-rr-domain-listen.js
  97. 10
      test/parallel/test-cluster-send-deadlock.js
  98. 4
      test/parallel/test-cluster-setup-master-argv.js
  99. 4
      test/parallel/test-cluster-setup-master-multiple.js
  100. 12
      test/parallel/test-cluster-setup-master.js

4
test/addons/buffer-free-callback/test.js

@ -5,8 +5,8 @@ const common = require('../../common');
const binding = require(`./build/${common.buildType}/binding`);
function check(size, alignment, offset) {
var buf = binding.alloc(size, alignment, offset);
var slice = buf.slice(size >>> 1);
let buf = binding.alloc(size, alignment, offset);
let slice = buf.slice(size >>> 1);
buf = null;
binding.check(slice);

6
test/addons/load-long-path/test.js

@ -14,9 +14,9 @@ common.refreshTmpDir();
// make a path that is more than 260 chars long.
// Any given folder cannot have a name longer than 260 characters,
// so create 10 nested folders each with 30 character long names.
var addonDestinationDir = path.resolve(common.tmpDir);
let addonDestinationDir = path.resolve(common.tmpDir);
for (var i = 0; i < 10; i++) {
for (let i = 0; i < 10; i++) {
addonDestinationDir = path.join(addonDestinationDir, 'x'.repeat(30));
fs.mkdirSync(addonDestinationDir);
}
@ -28,7 +28,7 @@ const addonPath = path.join(__dirname,
const addonDestinationPath = path.join(addonDestinationDir, 'binding.node');
// Copy binary to long path destination
var contents = fs.readFileSync(addonPath);
const contents = fs.readFileSync(addonPath);
fs.writeFileSync(addonDestinationPath, contents);
// Attempt to load at long path destination

2
test/addons/make-callback-recurse/test.js

@ -65,7 +65,7 @@ assert.throws(function() {
results.push(2);
setImmediate(common.mustCall(function() {
for (var i = 0; i < results.length; i++) {
for (let i = 0; i < results.length; i++) {
assert.strictEqual(results[i], i,
`verifyExecutionOrder(${arg}) results: ${results}`);
}

14
test/addons/repl-domain-abort/test.js

@ -4,27 +4,27 @@ const assert = require('assert');
const repl = require('repl');
const stream = require('stream');
const path = require('path');
var buildType = process.config.target_defaults.default_configuration;
var buildPath = path.join(__dirname, 'build', buildType, 'binding');
const buildType = process.config.target_defaults.default_configuration;
let buildPath = path.join(__dirname, 'build', buildType, 'binding');
// On Windows, escape backslashes in the path before passing it to REPL.
if (common.isWindows)
buildPath = buildPath.replace(/\\/g, '/');
var cb_ran = false;
let cb_ran = false;
process.on('exit', function() {
assert(cb_ran);
console.log('ok');
});
var lines = [
const lines = [
// This line shouldn't cause an assertion error.
'require(\'' + buildPath + '\')' +
// Log output to double check callback ran.
'.method(function() { console.log(\'cb_ran\'); });',
];
var dInput = new stream.Readable();
var dOutput = new stream.Writable();
const dInput = new stream.Readable();
const dOutput = new stream.Writable();
dInput._read = function _read(size) {
while (lines.length > 0 && this.push(lines.shift()));
@ -38,7 +38,7 @@ dOutput._write = function _write(chunk, encoding, cb) {
cb();
};
var options = {
const options = {
input: dInput,
output: dOutput,
terminal: false,

3
test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js

@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
return;
}
let buf;
try {
var buf = Buffer.allocUnsafe(kStringMaxLength);
buf = Buffer.allocUnsafe(kStringMaxLength);
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);

3
test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js

@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
let buf;
try {
var buf = Buffer.allocUnsafe(kStringMaxLength + 1);
buf = Buffer.allocUnsafe(kStringMaxLength + 1);
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);

3
test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js

@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
let buf;
try {
var buf = Buffer.allocUnsafe(kStringMaxLength + 1);
buf = Buffer.allocUnsafe(kStringMaxLength + 1);
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);

5
test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js

@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
let buf;
try {
var buf = Buffer.allocUnsafe(kStringMaxLength + 1);
buf = Buffer.allocUnsafe(kStringMaxLength + 1);
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);
@ -33,7 +34,7 @@ assert.throws(function() {
buf.toString('latin1');
}, /"toString\(\)" failed/);
var maxString = buf.toString('latin1', 1);
let maxString = buf.toString('latin1', 1);
assert.strictEqual(maxString.length, kStringMaxLength);
// Free the memory early instead of at the end of the next assignment
maxString = undefined;

3
test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js

@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
let buf;
try {
var buf = Buffer.allocUnsafe(kStringMaxLength + 1);
buf = Buffer.allocUnsafe(kStringMaxLength + 1);
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);

3
test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js

@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
let buf;
try {
var buf = Buffer.allocUnsafe(kStringMaxLength + 1);
buf = Buffer.allocUnsafe(kStringMaxLength + 1);
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);

3
test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js

@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
let buf;
try {
var buf = Buffer.allocUnsafe(kStringMaxLength + 2);
buf = Buffer.allocUnsafe(kStringMaxLength + 2);
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);

3
test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js

@ -14,8 +14,9 @@ if (!common.enoughTestMem) {
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
let buf;
try {
var buf = Buffer.allocUnsafe(kStringMaxLength * 2 + 2);
buf = Buffer.allocUnsafe(kStringMaxLength * 2 + 2);
} catch (e) {
// If the exception is not due to memory confinement then rethrow it.
if (e.message !== 'Array buffer allocation failed') throw (e);

2
test/common.js

@ -212,7 +212,7 @@ exports.hasIPv6 = Object.keys(ifaces).some(function(name) {
* the process aborts.
*/
exports.childShouldThrowAndAbort = function() {
var testCmd = '';
let testCmd = '';
if (!exports.isWindows) {
// Do not create core files, as it can take a lot of disk space on
// continuous testing and developers' machines

28
test/debugger/helper-debugger-repl.js

@ -4,12 +4,12 @@ const assert = require('assert');
const spawn = require('child_process').spawn;
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
var port = common.PORT;
const port = common.PORT;
var child;
var buffer = '';
var expected = [];
var quit;
let child;
let buffer = '';
const expected = [];
let quit;
function startDebugger(scriptToDebug) {
scriptToDebug = process.env.NODE_DEBUGGER_TEST_SCRIPT ||
@ -34,23 +34,23 @@ function startDebugger(scriptToDebug) {
console.log(line);
assert.ok(expected.length > 0, 'Got unexpected line: ' + line);
var expectedLine = expected[0].lines.shift();
const expectedLine = expected[0].lines.shift();
assert.ok(line.match(expectedLine) !== null, line + ' != ' + expectedLine);
if (expected[0].lines.length === 0) {
var callback = expected[0].callback;
const callback = expected[0].callback;
expected.shift();
callback && callback();
}
});
var childClosed = false;
let childClosed = false;
child.on('close', function(code) {
assert(!code);
childClosed = true;
});
var quitCalled = false;
let quitCalled = false;
quit = function() {
if (quitCalled || childClosed) return;
quitCalled = true;
@ -60,7 +60,7 @@ function startDebugger(scriptToDebug) {
setTimeout(function() {
console.error('dying badly buffer=%j', buffer);
var err = 'Timeout';
let err = 'Timeout';
if (expected.length > 0 && expected[0].lines) {
err = err + '. Expected: ' + expected[0].lines.shift();
}
@ -95,7 +95,7 @@ function addTest(input, output) {
child.stdin.write(expected[0].input + '\n');
if (!expected[0].lines) {
var callback = expected[0].callback;
const callback = expected[0].callback;
expected.shift();
callback && callback();
@ -107,17 +107,17 @@ function addTest(input, output) {
expected.push({input: input, lines: output, callback: next});
}
var handshakeLines = [
const handshakeLines = [
/listening on /,
/connecting.* ok/
];
var initialBreakLines = [
const initialBreakLines = [
/break in .*:1/,
/1/, /2/, /3/
];
var initialLines = handshakeLines.concat(initialBreakLines);
const initialLines = handshakeLines.concat(initialBreakLines);
// Process initial lines
addTest(null, initialLines);

4
test/debugger/test-debugger-repl-restart.js

@ -3,13 +3,13 @@ require('../common');
const repl = require('./helper-debugger-repl.js');
repl.startDebugger('breakpoints.js');
var linesWithBreakpoint = [
const linesWithBreakpoint = [
/1/, /2/, /3/, /4/, /5/, /\* 6/
];
// We slice here, because addTest will change the given array.
repl.addTest('sb(6)', linesWithBreakpoint.slice());
var initialLines = repl.initialLines.slice();
const initialLines = repl.initialLines.slice();
initialLines.splice(2, 0, /Restoring/, /Warning/);
// Restart the debugged script

2
test/debugger/test-debugger-repl-term.js

@ -6,7 +6,7 @@ const repl = require('./helper-debugger-repl.js');
repl.startDebugger('breakpoints.js');
var addTest = repl.addTest;
const addTest = repl.addTest;
// next
addTest('n', [

2
test/debugger/test-debugger-repl-utf8.js

@ -1,6 +1,6 @@
'use strict';
const common = require('../common');
var script = common.fixturesDir + '/breakpoints_utf8.js';
const script = common.fixturesDir + '/breakpoints_utf8.js';
process.env.NODE_DEBUGGER_TEST_SCRIPT = script;
require('./test-debugger-repl.js');

2
test/debugger/test-debugger-repl.js

@ -4,7 +4,7 @@ const repl = require('./helper-debugger-repl.js');
repl.startDebugger('breakpoints.js');
var addTest = repl.addTest;
const addTest = repl.addTest;
// Next
addTest('n', [

8
test/gc/test-http-client-connaborted.js

@ -18,7 +18,7 @@ let countGC = 0;
console.log('We should do ' + todo + ' requests');
var server = http.createServer(serverHandler);
const server = http.createServer(serverHandler);
server.listen(0, getall);
function getall() {
@ -31,7 +31,7 @@ function getall() {
statusLater();
}
var req = http.get({
const req = http.get({
hostname: 'localhost',
pathname: '/',
port: server.address().port
@ -44,14 +44,14 @@ function getall() {
setImmediate(getall);
}
for (var i = 0; i < 10; i++)
for (let i = 0; i < 10; i++)
getall();
function afterGC() {
countGC++;
}
var timer;
let timer;
function statusLater() {
global.gc();
if (timer) clearTimeout(timer);

8
test/gc/test-http-client-onerror.js

@ -20,7 +20,7 @@ let countGC = 0;
console.log('We should do ' + todo + ' requests');
var server = http.createServer(serverHandler);
const server = http.createServer(serverHandler);
server.listen(0, runTest);
function getall() {
@ -37,7 +37,7 @@ function getall() {
throw er;
}
var req = http.get({
const req = http.get({
hostname: 'localhost',
pathname: '/',
port: server.address().port
@ -51,7 +51,7 @@ function getall() {
}
function runTest() {
for (var i = 0; i < 10; i++)
for (let i = 0; i < 10; i++)
getall();
}
@ -59,7 +59,7 @@ function afterGC() {
countGC++;
}
var timer;
let timer;
function statusLater() {
global.gc();
if (timer) clearTimeout(timer);

8
test/gc/test-http-client-timeout.js

@ -22,7 +22,7 @@ let countGC = 0;
console.log('We should do ' + todo + ' requests');
var server = http.createServer(serverHandler);
const server = http.createServer(serverHandler);
server.listen(0, getall);
function getall() {
@ -36,7 +36,7 @@ function getall() {
statusLater();
}
var req = http.get({
const req = http.get({
hostname: 'localhost',
pathname: '/',
port: server.address().port
@ -53,14 +53,14 @@ function getall() {
setImmediate(getall);
}
for (var i = 0; i < 10; i++)
for (let i = 0; i < 10; i++)
getall();
function afterGC() {
countGC++;
}
var timer;
let timer;
function statusLater() {
global.gc();
if (timer) clearTimeout(timer);

6
test/gc/test-http-client.js

@ -18,7 +18,7 @@ let countGC = 0;
console.log('We should do ' + todo + ' requests');
var server = http.createServer(serverHandler);
const server = http.createServer(serverHandler);
server.listen(0, getall);
@ -34,7 +34,7 @@ function getall() {
res.on('end', global.gc);
}
var req = http.get({
const req = http.get({
hostname: 'localhost',
pathname: '/',
port: server.address().port
@ -47,7 +47,7 @@ function getall() {
setImmediate(getall);
}
for (var i = 0; i < 10; i++)
for (let i = 0; i < 10; i++)
getall();
function afterGC() {

7
test/gc/test-net-timeout.js

@ -7,14 +7,13 @@ require('../common');
function serverHandler(sock) {
sock.setTimeout(120000);
sock.resume();
var timer;
sock.on('close', function() {
clearTimeout(timer);
});
sock.on('error', function(err) {
assert.strictEqual(err.code, 'ECONNRESET');
});
timer = setTimeout(function() {
const timer = setTimeout(function() {
sock.end('hello\n');
}, 100);
}
@ -29,7 +28,7 @@ let countGC = 0;
console.log('We should do ' + todo + ' requests');
var server = net.createServer(serverHandler);
const server = net.createServer(serverHandler);
server.listen(0, getall);
function getall() {
@ -50,7 +49,7 @@ function getall() {
setImmediate(getall);
}
for (var i = 0; i < 10; i++)
for (let i = 0; i < 10; i++)
getall();
function afterGC() {

4
test/inspector/inspector-helper.js

@ -110,7 +110,7 @@ function makeBufferingDataCallback(dataCallback) {
buffer = Buffer.alloc(0);
else
buffer = Buffer.from(lines.pop(), 'utf8');
for (var line of lines)
for (const line of lines)
dataCallback(line);
};
}
@ -222,7 +222,7 @@ TestSession.prototype.sendInspectorCommands = function(commands) {
};
TestSession.prototype.createCallbackWithTimeout_ = function(message) {
var promise = new Promise((resolve) => {
const promise = new Promise((resolve) => {
this.enqueue((callback) => {
const timeoutId = timeout(message);
resolve(() => {

19
test/internet/test-dgram-multicast-multi-process.js

@ -13,6 +13,7 @@ const messages = [
];
const workers = {};
const listeners = 3;
let listening, sendSocket, done, timer, dead;
// Skip test in FreeBSD jails.
@ -76,10 +77,10 @@ function launchChildProcess(index) {
Object.keys(workers).forEach(function(pid) {
const worker = workers[pid];
var count = 0;
let count = 0;
worker.messagesReceived.forEach(function(buf) {
for (var i = 0; i < messages.length; ++i) {
for (let i = 0; i < messages.length; ++i) {
if (buf.toString() === messages[i].toString()) {
count++;
break;
@ -110,13 +111,13 @@ function killChildren(children) {
}
if (process.argv[2] !== 'child') {
var listening = 0;
var dead = 0;
var i = 0;
var done = 0;
listening = 0;
dead = 0;
let i = 0;
done = 0;
// Exit the test if it doesn't succeed within TIMEOUT.
var timer = setTimeout(function() {
timer = setTimeout(function() {
console.error('[PARENT] Responses were not received within %d ms.',
TIMEOUT);
console.error('[PARENT] Fail');
@ -127,11 +128,11 @@ if (process.argv[2] !== 'child') {
}, TIMEOUT);
// Launch child processes.
for (var x = 0; x < listeners; x++) {
for (let x = 0; x < listeners; x++) {
launchChildProcess(x);
}
var sendSocket = dgram.createSocket('udp4');
sendSocket = dgram.createSocket('udp4');
// The socket is actually created async now.
sendSocket.on('listening', function() {

6
test/internet/test-dgram-send-cb-quelches-error.js

@ -1,12 +1,12 @@
'use strict';
const common = require('../common');
var mustCall = common.mustCall;
const mustCall = common.mustCall;
const assert = require('assert');
const dgram = require('dgram');
const dns = require('dns');
var socket = dgram.createSocket('udp4');
var buffer = Buffer.from('gary busey');
const socket = dgram.createSocket('udp4');
const buffer = Buffer.from('gary busey');
dns.setServers([]);

4
test/internet/test-dns-cares-domains.js

@ -4,7 +4,7 @@ const assert = require('assert');
const dns = require('dns');
const domain = require('domain');
var methods = [
const methods = [
'resolve4',
'resolve6',
'resolveCname',
@ -18,7 +18,7 @@ var methods = [
];
methods.forEach(function(method) {
var d = domain.create();
const d = domain.create();
d.run(function() {
dns[method]('google.com', function() {
assert.strictEqual(process.domain, d, method + ' retains domain');

96
test/internet/test-dns.js

@ -15,7 +15,7 @@ const queue = [];
function TEST(f) {
function next() {
var f = queue.shift();
const f = queue.shift();
if (f) {
running = true;
console.log(f.name);
@ -44,7 +44,7 @@ function checkWrap(req) {
TEST(function test_reverse_bogus(done) {
var error;
let error;
try {
dns.reverse('bogus ip', function() {
@ -61,12 +61,12 @@ TEST(function test_reverse_bogus(done) {
});
TEST(function test_resolve4_ttl(done) {
var req = dns.resolve4('google.com', { ttl: true }, function(err, result) {
const req = dns.resolve4('google.com', { ttl: true }, function(err, result) {
assert.ifError(err);
assert.ok(result.length > 0);
for (var i = 0; i < result.length; i++) {
var item = result[i];
for (let i = 0; i < result.length; i++) {
const item = result[i];
assert.ok(item);
assert.strictEqual(typeof item, 'object');
assert.strictEqual(typeof item.ttl, 'number');
@ -82,12 +82,12 @@ TEST(function test_resolve4_ttl(done) {
});
TEST(function test_resolve6_ttl(done) {
var req = dns.resolve6('google.com', { ttl: true }, function(err, result) {
const req = dns.resolve6('google.com', { ttl: true }, function(err, result) {
assert.ifError(err);
assert.ok(result.length > 0);
for (var i = 0; i < result.length; i++) {
var item = result[i];
for (let i = 0; i < result.length; i++) {
const item = result[i];
assert.ok(item);
assert.strictEqual(typeof item, 'object');
assert.strictEqual(typeof item.ttl, 'number');
@ -103,12 +103,12 @@ TEST(function test_resolve6_ttl(done) {
});
TEST(function test_resolveMx(done) {
var req = dns.resolveMx('gmail.com', function(err, result) {
const req = dns.resolveMx('gmail.com', function(err, result) {
assert.ifError(err);
assert.ok(result.length > 0);
for (var i = 0; i < result.length; i++) {
var item = result[i];
for (let i = 0; i < result.length; i++) {
const item = result[i];
assert.ok(item);
assert.strictEqual(typeof item, 'object');
@ -125,7 +125,7 @@ TEST(function test_resolveMx(done) {
});
TEST(function test_resolveMx_failure(done) {
var req = dns.resolveMx('something.invalid', function(err, result) {
const req = dns.resolveMx('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
@ -138,12 +138,12 @@ TEST(function test_resolveMx_failure(done) {
});
TEST(function test_resolveNs(done) {
var req = dns.resolveNs('rackspace.com', function(err, names) {
const req = dns.resolveNs('rackspace.com', function(err, names) {
assert.ifError(err);
assert.ok(names.length > 0);
for (var i = 0; i < names.length; i++) {
var name = names[i];
for (let i = 0; i < names.length; i++) {
const name = names[i];
assert.ok(name);
assert.strictEqual(typeof name, 'string');
}
@ -155,7 +155,7 @@ TEST(function test_resolveNs(done) {
});
TEST(function test_resolveNs_failure(done) {
var req = dns.resolveNs('something.invalid', function(err, result) {
const req = dns.resolveNs('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
@ -168,12 +168,12 @@ TEST(function test_resolveNs_failure(done) {
});
TEST(function test_resolveSrv(done) {
var req = dns.resolveSrv('_jabber._tcp.google.com', function(err, result) {
const req = dns.resolveSrv('_jabber._tcp.google.com', function(err, result) {
assert.ifError(err);
assert.ok(result.length > 0);
for (var i = 0; i < result.length; i++) {
var item = result[i];
for (let i = 0; i < result.length; i++) {
const item = result[i];
assert.ok(item);
assert.strictEqual(typeof item, 'object');
@ -192,7 +192,7 @@ TEST(function test_resolveSrv(done) {
});
TEST(function test_resolveSrv_failure(done) {
var req = dns.resolveSrv('something.invalid', function(err, result) {
const req = dns.resolveSrv('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
@ -205,12 +205,12 @@ TEST(function test_resolveSrv_failure(done) {
});
TEST(function test_resolvePtr(done) {
var req = dns.resolvePtr('8.8.8.8.in-addr.arpa', function(err, result) {
const req = dns.resolvePtr('8.8.8.8.in-addr.arpa', function(err, result) {
assert.ifError(err);
assert.ok(result.length > 0);
for (var i = 0; i < result.length; i++) {
var item = result[i];
for (let i = 0; i < result.length; i++) {
const item = result[i];
assert.ok(item);
assert.strictEqual(typeof item, 'string');
}
@ -222,7 +222,7 @@ TEST(function test_resolvePtr(done) {
});
TEST(function test_resolvePtr_failure(done) {
var req = dns.resolvePtr('something.invalid', function(err, result) {
const req = dns.resolvePtr('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
@ -235,12 +235,12 @@ TEST(function test_resolvePtr_failure(done) {
});
TEST(function test_resolveNaptr(done) {
var req = dns.resolveNaptr('sip2sip.info', function(err, result) {
const req = dns.resolveNaptr('sip2sip.info', function(err, result) {
assert.ifError(err);
assert.ok(result.length > 0);
for (var i = 0; i < result.length; i++) {
var item = result[i];
for (let i = 0; i < result.length; i++) {
const item = result[i];
assert.ok(item);
assert.strictEqual(typeof item, 'object');
@ -259,7 +259,7 @@ TEST(function test_resolveNaptr(done) {
});
TEST(function test_resolveNaptr_failure(done) {
var req = dns.resolveNaptr('something.invalid', function(err, result) {
const req = dns.resolveNaptr('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
@ -272,7 +272,7 @@ TEST(function test_resolveNaptr_failure(done) {
});
TEST(function test_resolveSoa(done) {
var req = dns.resolveSoa('nodejs.org', function(err, result) {
const req = dns.resolveSoa('nodejs.org', function(err, result) {
assert.ifError(err);
assert.ok(result);
assert.strictEqual(typeof result, 'object');
@ -305,7 +305,7 @@ TEST(function test_resolveSoa(done) {
});
TEST(function test_resolveSoa_failure(done) {
var req = dns.resolveSoa('something.invalid', function(err, result) {
const req = dns.resolveSoa('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
@ -318,12 +318,12 @@ TEST(function test_resolveSoa_failure(done) {
});
TEST(function test_resolveCname(done) {
var req = dns.resolveCname('www.microsoft.com', function(err, names) {
const req = dns.resolveCname('www.microsoft.com', function(err, names) {
assert.ifError(err);
assert.ok(names.length > 0);
for (var i = 0; i < names.length; i++) {
var name = names[i];
for (let i = 0; i < names.length; i++) {
const name = names[i];
assert.ok(name);
assert.strictEqual(typeof name, 'string');
}
@ -335,7 +335,7 @@ TEST(function test_resolveCname(done) {
});
TEST(function test_resolveCname_failure(done) {
var req = dns.resolveCname('something.invalid', function(err, result) {
const req = dns.resolveCname('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
@ -349,7 +349,7 @@ TEST(function test_resolveCname_failure(done) {
TEST(function test_resolveTxt(done) {
var req = dns.resolveTxt('google.com', function(err, records) {
const req = dns.resolveTxt('google.com', function(err, records) {
assert.ifError(err);
assert.strictEqual(records.length, 1);
assert.ok(util.isArray(records[0]));
@ -361,7 +361,7 @@ TEST(function test_resolveTxt(done) {
});
TEST(function test_resolveTxt_failure(done) {
var req = dns.resolveTxt('something.invalid', function(err, result) {
const req = dns.resolveTxt('something.invalid', function(err, result) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, 'ENOTFOUND');
@ -375,7 +375,7 @@ TEST(function test_resolveTxt_failure(done) {
TEST(function test_lookup_failure(done) {
var req = dns.lookup('does.not.exist', 4, function(err, ip, family) {
const req = dns.lookup('does.not.exist', 4, function(err, ip, family) {
assert.ok(err instanceof Error);
assert.strictEqual(err.errno, dns.NOTFOUND);
assert.strictEqual(err.errno, 'ENOTFOUND');
@ -390,7 +390,7 @@ TEST(function test_lookup_failure(done) {
TEST(function test_lookup_null(done) {
var req = dns.lookup(null, function(err, ip, family) {
const req = dns.lookup(null, function(err, ip, family) {
assert.ifError(err);
assert.strictEqual(ip, null);
assert.strictEqual(family, 4);
@ -403,7 +403,7 @@ TEST(function test_lookup_null(done) {
TEST(function test_lookup_ip_all(done) {
var req = dns.lookup('127.0.0.1', {all: true}, function(err, ips, family) {
const req = dns.lookup('127.0.0.1', {all: true}, function(err, ips, family) {
assert.ifError(err);
assert.ok(Array.isArray(ips));
assert.ok(ips.length > 0);
@ -418,7 +418,7 @@ TEST(function test_lookup_ip_all(done) {
TEST(function test_lookup_null_all(done) {
var req = dns.lookup(null, {all: true}, function(err, ips, family) {
const req = dns.lookup(null, {all: true}, function(err, ips, family) {
assert.ifError(err);
assert.ok(Array.isArray(ips));
assert.strictEqual(ips.length, 0);
@ -431,7 +431,7 @@ TEST(function test_lookup_null_all(done) {
TEST(function test_lookup_all_mixed(done) {
var req = dns.lookup('www.google.com', {all: true}, function(err, ips) {
const req = dns.lookup('www.google.com', {all: true}, function(err, ips) {
assert.ifError(err);
assert.ok(Array.isArray(ips));
assert.ok(ips.length > 0);
@ -453,7 +453,7 @@ TEST(function test_lookup_all_mixed(done) {
TEST(function test_lookupservice_invalid(done) {
var req = dns.lookupService('1.2.3.4', 80, function(err, host, service) {
const req = dns.lookupService('1.2.3.4', 80, function(err, host, service) {
assert(err instanceof Error);
assert.strictEqual(err.code, 'ENOTFOUND');
assert.ok(/1\.2\.3\.4/.test(err.message));
@ -466,7 +466,7 @@ TEST(function test_lookupservice_invalid(done) {
TEST(function test_reverse_failure(done) {
var req = dns.reverse('0.0.0.0', function(err) {
const req = dns.reverse('0.0.0.0', function(err) {
assert(err instanceof Error);
assert.strictEqual(err.code, 'ENOTFOUND'); // Silly error code...
assert.strictEqual(err.hostname, '0.0.0.0');
@ -480,7 +480,7 @@ TEST(function test_reverse_failure(done) {
TEST(function test_lookup_failure(done) {
var req = dns.lookup('nosuchhostimsure', function(err) {
const req = dns.lookup('nosuchhostimsure', function(err) {
assert(err instanceof Error);
assert.strictEqual(err.code, 'ENOTFOUND'); // Silly error code...
assert.strictEqual(err.hostname, 'nosuchhostimsure');
@ -494,7 +494,7 @@ TEST(function test_lookup_failure(done) {
TEST(function test_resolve_failure(done) {
var req = dns.resolve4('nosuchhostimsure', function(err) {
const req = dns.resolve4('nosuchhostimsure', function(err) {
assert(err instanceof Error);
switch (err.code) {
@ -516,12 +516,12 @@ TEST(function test_resolve_failure(done) {
});
var getaddrinfoCallbackCalled = false;
let getaddrinfoCallbackCalled = false;
console.log('looking up nodejs.org...');
var cares = process.binding('cares_wrap');
var req = new cares.GetAddrInfoReqWrap();
const cares = process.binding('cares_wrap');
const req = new cares.GetAddrInfoReqWrap();
cares.getaddrinfo(req, 'nodejs.org', 4);
req.oncomplete = function(err, domains) {

8
test/internet/test-net-connect-timeout.js

@ -7,21 +7,21 @@ const common = require('../common');
const net = require('net');
const assert = require('assert');
var start = new Date();
const start = new Date();
var T = 100;
const T = 100;
// 192.0.2.1 is part of subnet assigned as "TEST-NET" in RFC 5737.
// For use solely in documentation and example source code.
// In short, it should be unreachable.
// In practice, it's a network black hole.
var socket = net.createConnection(9999, '192.0.2.1');
const socket = net.createConnection(9999, '192.0.2.1');
socket.setTimeout(T);
socket.on('timeout', common.mustCall(function() {
console.error('timeout');
var now = new Date();
const now = new Date();
assert.ok(now - start < T + 500);
socket.destroy();
}));

5
test/internet/test-net-connect-unref.js

@ -2,10 +2,9 @@
const common = require('../common');
const net = require('net');
var client;
var TIMEOUT = 10 * 1000;
const TIMEOUT = 10 * 1000;
client = net.createConnection(53, '8.8.8.8', function() {
const client = net.createConnection(53, '8.8.8.8', function() {
client.unref();
});

2
test/internet/test-tls-connnect-melissadata.js

@ -9,7 +9,7 @@ if (!common.hasCrypto) {
}
const tls = require('tls');
var socket = tls.connect(443, 'address.melissadata.net', function() {
const socket = tls.connect(443, 'address.melissadata.net', function() {
socket.resume();
socket.destroy();
});

8
test/known_issues/test-url-parse-conformance.js

@ -9,14 +9,14 @@ const path = require('path');
const tests = require(path.join(common.fixturesDir, 'url-tests.json'));
var failed = 0;
var attempted = 0;
let failed = 0;
let attempted = 0;
tests.forEach((test) => {
attempted++;
// Skip comments
if (typeof test === 'string') return;
var parsed;
let parsed;
try {
// Attempt to parse
@ -28,7 +28,7 @@ tests.forEach((test) => {
} else {
// Test was not supposed to fail, so we're good so far. Now
// check the results of the parse.
var username, password;
let username, password;
try {
assert.strictEqual(test.href, parsed.href);
assert.strictEqual(test.protocol, parsed.protocol);

8
test/message/eval_messages.js

@ -5,16 +5,16 @@ require('../common');
const spawn = require('child_process').spawn;
function run(cmd, strict, cb) {
var args = [];
const args = [];
if (strict) args.push('--use_strict');
args.push('-pe', cmd);
var child = spawn(process.execPath, args);
const child = spawn(process.execPath, args);
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stdout);
child.on('close', cb);
}
var queue =
const queue =
[ 'with(this){__filename}',
'42',
'throw new Error("hello")',
@ -22,7 +22,7 @@ var queue =
'var ______________________________________________; throw 10' ];
function go() {
var c = queue.shift();
const c = queue.shift();
if (!c) return console.log('done');
run(c, false, function() {
run(c, true, go);

2
test/message/max_tick_depth.js

@ -2,7 +2,7 @@
require('../common');
process.maxTickDepth = 10;
var i = 20;
let i = 20;
process.nextTick(function f() {
console.error('tick %d', i);
if (i-- > 0)

8
test/message/stdin_messages.js

@ -5,17 +5,17 @@ require('../common');
const spawn = require('child_process').spawn;
function run(cmd, strict, cb) {
var args = [];
const args = [];
if (strict) args.push('--use_strict');
args.push('-p');
var child = spawn(process.execPath, args);
const child = spawn(process.execPath, args);
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stdout);
child.stdin.end(cmd);
child.on('close', cb);
}
var queue =
const queue =
[ 'with(this){__filename}',
'42',
'throw new Error("hello")',
@ -23,7 +23,7 @@ var queue =
'var ______________________________________________; throw 10' ];
function go() {
var c = queue.shift();
const c = queue.shift();
if (!c) return console.log('done');
run(c, false, function() {
run(c, true, go);

2
test/parallel/test-assert-typedarray-deepequal.js

@ -5,7 +5,7 @@ const assert = require('assert');
const a = require('assert');
function makeBlock(f) {
var args = Array.prototype.slice.call(arguments, 1);
const args = Array.prototype.slice.call(arguments, 1);
return function() {
return f.apply(this, args);
};

31
test/parallel/test-assert.js

@ -4,7 +4,7 @@ const assert = require('assert');
const a = require('assert');
function makeBlock(f) {
var args = Array.prototype.slice.call(arguments, 1);
const args = Array.prototype.slice.call(arguments, 1);
return function() {
return f.apply(this, args);
};
@ -120,8 +120,8 @@ assert.throws(makeBlock(a.deepEqual, {a: 4}, {a: 4, b: true}),
assert.doesNotThrow(makeBlock(a.deepEqual, ['a'], {0: 'a'}));
//(although not necessarily the same order),
assert.doesNotThrow(makeBlock(a.deepEqual, {a: 4, b: '1'}, {b: '1', a: 4}));
var a1 = [1, 2, 3];
var a2 = [1, 2, 3];
const a1 = [1, 2, 3];
const a2 = [1, 2, 3];
a1.a = 'test';
a1.b = true;
a2.b = true;
@ -131,7 +131,7 @@ assert.throws(makeBlock(a.deepEqual, Object.keys(a1), Object.keys(a2)),
assert.doesNotThrow(makeBlock(a.deepEqual, a1, a2));
// having an identical prototype property
var nbRoot = {
const nbRoot = {
toString: function() { return this.first + ' ' + this.last; }
};
@ -149,8 +149,8 @@ function nameBuilder2(first, last) {
}
nameBuilder2.prototype = nbRoot;
var nb1 = new nameBuilder('Ryan', 'Dahl');
var nb2 = new nameBuilder2('Ryan', 'Dahl');
const nb1 = new nameBuilder('Ryan', 'Dahl');
let nb2 = new nameBuilder2('Ryan', 'Dahl');
assert.doesNotThrow(makeBlock(a.deepEqual, nb1, nb2));
@ -267,8 +267,8 @@ function Constructor2(first, last) {
this.last = last;
}
var obj1 = new Constructor1('Ryan', 'Dahl');
var obj2 = new Constructor2('Ryan', 'Dahl');
const obj1 = new Constructor1('Ryan', 'Dahl');
let obj2 = new Constructor2('Ryan', 'Dahl');
assert.throws(makeBlock(a.deepStrictEqual, obj1, obj2), a.AssertionError);
@ -285,7 +285,7 @@ assert.throws(makeBlock(assert.deepStrictEqual, true, 1),
assert.throws(makeBlock(assert.deepStrictEqual, Symbol(), Symbol()),
a.AssertionError);
var s = Symbol();
const s = Symbol();
assert.doesNotThrow(makeBlock(assert.deepStrictEqual, s, s));
@ -326,7 +326,7 @@ assert.throws(makeBlock(thrower, a.AssertionError));
assert.throws(makeBlock(thrower, TypeError));
// when passing a type, only catch errors of the appropriate type
var threw = false;
let threw = false;
try {
a.throws(makeBlock(thrower, TypeError), a.AssertionError);
} catch (e) {
@ -394,10 +394,11 @@ a.throws(makeBlock(thrower, TypeError), function(err) {
// https://github.com/nodejs/node/issues/3188
threw = false;
let AnotherErrorType;
try {
var ES6Error = class extends Error {};
const ES6Error = class extends Error {};
var AnotherErrorType = class extends Error {};
AnotherErrorType = class extends Error {};
const functionThatThrows = function() {
throw new AnotherErrorType('foo');
@ -436,7 +437,7 @@ assert.ok(threw);
a.throws(makeBlock(a.deepStrictEqual, d, e), /AssertionError/);
}
// GH-7178. Ensure reflexivity of deepEqual with `arguments` objects.
var args = (function() { return arguments; })();
const args = (function() { return arguments; })();
a.throws(makeBlock(a.deepEqual, [], args));
a.throws(makeBlock(a.deepEqual, args, []));
@ -455,7 +456,7 @@ a.throws(makeBlock(a.deepEqual, args, []));
a.doesNotThrow(makeBlock(a.deepEqual, someArgs, sameArgs));
}
var circular = {y: 1};
const circular = {y: 1};
circular.x = circular;
function testAssertionMessage(actual, expected) {
@ -520,7 +521,7 @@ try {
// Verify that throws() and doesNotThrow() throw on non-function block
function testBlockTypeError(method, block) {
var threw = true;
let threw = true;
try {
method(block);

2
test/parallel/test-async-wrap-check-providers.js

@ -28,7 +28,7 @@ keyList.splice(0, 1);
// want to improve under https://github.com/nodejs/node/issues/5085.
// strip out fs watch related parts for now
if (common.isAix) {
for (var i = 0; i < keyList.length; i++) {
for (let i = 0; i < keyList.length; i++) {
if ((keyList[i] === 'FSEVENTWRAP') || (keyList[i] === 'STATWATCHER')) {
keyList.splice(i, 1);
}

6
test/parallel/test-async-wrap-throw-from-callback.js

@ -13,8 +13,8 @@ const domain = require('domain');
const spawn = require('child_process').spawn;
const callbacks = [ 'init', 'pre', 'post', 'destroy' ];
const toCall = process.argv[2];
var msgCalled = 0;
var msgReceived = 0;
let msgCalled = 0;
let msgReceived = 0;
function init() {
if (toCall === 'init')
@ -57,7 +57,7 @@ if (typeof process.argv[2] === 'string') {
msgCalled++;
const child = spawn(process.execPath, [__filename, item]);
var errstring = '';
let errstring = '';
child.stderr.on('data', (data) => {
errstring += data.toString();

2
test/parallel/test-async-wrap-uid.js

@ -6,7 +6,7 @@ const assert = require('assert');
const async_wrap = process.binding('async_wrap');
// Give the event loop time to clear out the final uv_close().
var si_cntr = 3;
let si_cntr = 3;
process.on('beforeExit', () => {
if (--si_cntr > 0) setImmediate(() => {});
});

2
test/parallel/test-buffer-ascii.js

@ -16,7 +16,7 @@ const expected = 'Cb\u0000\u0019est, graphiquement, la rC)union ' +
const buf = Buffer.from(input);
for (var i = 0; i < expected.length; ++i) {
for (let i = 0; i < expected.length; ++i) {
assert.strictEqual(buf.slice(i).toString('ascii'), expected.slice(i));
// Skip remainder of multi-byte sequence.

26
test/parallel/test-buffer-bytelength.js

@ -24,37 +24,37 @@ assert(ArrayBuffer.isView(Buffer.allocUnsafeSlow(10)));
assert(ArrayBuffer.isView(Buffer.from('')));
// buffer
var incomplete = Buffer.from([0xe4, 0xb8, 0xad, 0xe6, 0x96]);
const incomplete = Buffer.from([0xe4, 0xb8, 0xad, 0xe6, 0x96]);
assert.strictEqual(Buffer.byteLength(incomplete), 5);
var ascii = Buffer.from('abc');
const ascii = Buffer.from('abc');
assert.strictEqual(Buffer.byteLength(ascii), 3);
// ArrayBuffer
var buffer = new ArrayBuffer(8);
const buffer = new ArrayBuffer(8);
assert.strictEqual(Buffer.byteLength(buffer), 8);
// TypedArray
var int8 = new Int8Array(8);
const int8 = new Int8Array(8);
assert.strictEqual(Buffer.byteLength(int8), 8);
var uint8 = new Uint8Array(8);
const uint8 = new Uint8Array(8);
assert.strictEqual(Buffer.byteLength(uint8), 8);
var uintc8 = new Uint8ClampedArray(2);
const uintc8 = new Uint8ClampedArray(2);
assert.strictEqual(Buffer.byteLength(uintc8), 2);
var int16 = new Int16Array(8);
const int16 = new Int16Array(8);
assert.strictEqual(Buffer.byteLength(int16), 16);
var uint16 = new Uint16Array(8);
const uint16 = new Uint16Array(8);
assert.strictEqual(Buffer.byteLength(uint16), 16);
var int32 = new Int32Array(8);
const int32 = new Int32Array(8);
assert.strictEqual(Buffer.byteLength(int32), 32);
var uint32 = new Uint32Array(8);
const uint32 = new Uint32Array(8);
assert.strictEqual(Buffer.byteLength(uint32), 32);
var float32 = new Float32Array(8);
const float32 = new Float32Array(8);
assert.strictEqual(Buffer.byteLength(float32), 32);
var float64 = new Float64Array(8);
const float64 = new Float64Array(8);
assert.strictEqual(Buffer.byteLength(float64), 64);
// DataView
var dv = new DataView(new ArrayBuffer(2));
const dv = new DataView(new ArrayBuffer(2));
assert.strictEqual(Buffer.byteLength(dv), 2);
// special case: zero length string

2
test/parallel/test-buffer-concat.js

@ -5,7 +5,7 @@ const assert = require('assert');
const zero = [];
const one = [ Buffer.from('asdf') ];
const long = [];
for (var i = 0; i < 10; i++) long.push(Buffer.from('asdf'));
for (let i = 0; i < 10; i++) long.push(Buffer.from('asdf'));
const flatZero = Buffer.concat(zero);
const flatOne = Buffer.concat(one);

2
test/parallel/test-buffer-copy.js

@ -5,7 +5,7 @@ const assert = require('assert');
const b = Buffer.allocUnsafe(1024);
const c = Buffer.allocUnsafe(512);
var cntr = 0;
let cntr = 0;
{
// copy 512 bytes, from 0 to 512.

6
test/parallel/test-buffer-fill.js

@ -243,7 +243,7 @@ function writeToFill(string, offset, end, encoding) {
// Convert "end" to "length" (which write understands).
const length = end - offset < 0 ? 0 : end - offset;
var wasZero = false;
let wasZero = false;
do {
const written = buf2.write(string, offset, length, encoding);
offset += written;
@ -324,7 +324,7 @@ Buffer.alloc(8, '');
{
let elseWasLast = false;
assert.throws(() => {
var ctr = 0;
let ctr = 0;
const start = {
[Symbol.toPrimitive]() {
// We use this condition to get around the check in lib/buffer.js
@ -357,7 +357,7 @@ assert.throws(() => {
{
let elseWasLast = false;
assert.throws(() => {
var ctr = 0;
let ctr = 0;
const end = {
[Symbol.toPrimitive]() {
// We use this condition to get around the check in lib/buffer.js

10
test/parallel/test-buffer-includes.js

@ -140,7 +140,7 @@ assert.strictEqual(
// test usc2 encoding
var twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2');
let twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2');
assert(twoByteString.includes('\u0395', 4, 'ucs2'));
assert(twoByteString.includes('\u03a3', -4, 'ucs2'));
@ -190,7 +190,7 @@ assert(!mixedByteStringUtf8.includes('\u0396'));
// Test complex string includes algorithms. Only trigger for long strings.
// Long string that isn't a simple repeat of a shorter string.
var longString = 'A';
let longString = 'A';
for (let i = 66; i < 76; i++) { // from 'B' to 'K'
longString = longString + String.fromCharCode(i) + longString;
}
@ -198,7 +198,7 @@ for (let i = 66; i < 76; i++) { // from 'B' to 'K'
const longBufferString = Buffer.from(longString);
// pattern of 15 chars, repeated every 16 chars in long
var pattern = 'ABACABADABACABA';
let pattern = 'ABACABADABACABA';
for (let i = 0; i < longBufferString.length - pattern.length; i += 7) {
const includes = longBufferString.includes(pattern, i);
assert(includes, 'Long ABACABA...-string at index ' + i);
@ -229,8 +229,8 @@ assert(!allCharsBufferUtf8.includes('notfound'));
assert(!allCharsBufferUcs2.includes('notfound'));
// Find substrings in Utf8.
var lengths = [1, 3, 15]; // Single char, simple and complex.
var indices = [0x5, 0x60, 0x400, 0x680, 0x7ee, 0xFF02, 0x16610, 0x2f77b];
let lengths = [1, 3, 15]; // Single char, simple and complex.
let indices = [0x5, 0x60, 0x400, 0x680, 0x7ee, 0xFF02, 0x16610, 0x2f77b];
for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) {
for (let i = 0; i < indices.length; i++) {
const index = indices[i];

39
test/parallel/test-buffer-indexof.js

@ -191,7 +191,7 @@ assert.equal(Buffer.from('aaaa00a').indexOf('3030', 'hex'), 4);
assert.equal(-1, twoByteString.indexOf('\u03a3', -2, 'ucs2'));
}
var mixedByteStringUcs2 =
const mixedByteStringUcs2 =
Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395', 'ucs2');
assert.equal(6, mixedByteStringUcs2.indexOf('bc', 0, 'ucs2'));
assert.equal(10, mixedByteStringUcs2.indexOf('\u03a3', 0, 'ucs2'));
@ -226,7 +226,7 @@ assert.equal(
6, twoByteString.indexOf('\u03a3\u0395', 0, 'ucs2'), 'Sigma Epsilon');
}
var mixedByteStringUtf8 = Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395');
const mixedByteStringUtf8 = Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395');
assert.equal(5, mixedByteStringUtf8.indexOf('bc'));
assert.equal(5, mixedByteStringUtf8.indexOf('bc', 5));
assert.equal(5, mixedByteStringUtf8.indexOf('bc', -8));
@ -236,15 +236,15 @@ assert.equal(-1, mixedByteStringUtf8.indexOf('\u0396'));
// Test complex string indexOf algorithms. Only trigger for long strings.
// Long string that isn't a simple repeat of a shorter string.
var longString = 'A';
let longString = 'A';
for (let i = 66; i < 76; i++) { // from 'B' to 'K'
longString = longString + String.fromCharCode(i) + longString;
}
var longBufferString = Buffer.from(longString);
const longBufferString = Buffer.from(longString);
// pattern of 15 chars, repeated every 16 chars in long
var pattern = 'ABACABADABACABA';
let pattern = 'ABACABADABACABA';
for (let i = 0; i < longBufferString.length - pattern.length; i += 7) {
const index = longBufferString.indexOf(pattern, i);
assert.equal((i + 15) & ~0xf, index, 'Long ABACABA...-string at index ' + i);
@ -260,17 +260,17 @@ assert.equal(
1535, longBufferString.indexOf(pattern, 512), 'Long JABACABA..., Second J');
// Search for a non-ASCII string in a pure ASCII string.
var asciiString = Buffer.from(
const asciiString = Buffer.from(
'arglebargleglopglyfarglebargleglopglyfarglebargleglopglyf');
assert.equal(-1, asciiString.indexOf('\x2061'));
assert.equal(3, asciiString.indexOf('leb', 0));
// Search in string containing many non-ASCII chars.
var allCodePoints = [];
const allCodePoints = [];
for (let i = 0; i < 65536; i++) allCodePoints[i] = i;
var allCharsString = String.fromCharCode.apply(String, allCodePoints);
var allCharsBufferUtf8 = Buffer.from(allCharsString);
var allCharsBufferUcs2 = Buffer.from(allCharsString, 'ucs2');
const allCharsString = String.fromCharCode.apply(String, allCodePoints);
const allCharsBufferUtf8 = Buffer.from(allCharsString);
const allCharsBufferUcs2 = Buffer.from(allCharsString, 'ucs2');
// Search for string long enough to trigger complex search with ASCII pattern
// and UC16 subject.
@ -307,10 +307,10 @@ assert.strictEqual(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1);
length = 4 * length;
}
var patternBufferUtf8 = allCharsBufferUtf8.slice(index, index + length);
const patternBufferUtf8 = allCharsBufferUtf8.slice(index, index + length);
assert.equal(index, allCharsBufferUtf8.indexOf(patternBufferUtf8));
var patternStringUtf8 = patternBufferUtf8.toString();
const patternStringUtf8 = patternBufferUtf8.toString();
assert.equal(index, allCharsBufferUtf8.indexOf(patternStringUtf8));
}
}
@ -325,12 +325,12 @@ assert.strictEqual(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1);
const index = indices[i] * 2;
const length = lengths[lengthIndex];
var patternBufferUcs2 =
const patternBufferUcs2 =
allCharsBufferUcs2.slice(index, index + length);
assert.equal(
index, allCharsBufferUcs2.indexOf(patternBufferUcs2, 0, 'ucs2'));
var patternStringUcs2 = patternBufferUcs2.toString('ucs2');
const patternStringUcs2 = patternBufferUcs2.toString('ucs2');
assert.equal(
index, allCharsBufferUcs2.indexOf(patternStringUcs2, 0, 'ucs2'));
}
@ -434,7 +434,7 @@ assert.strictEqual(buf_bc.lastIndexOf('你好', 5, 'binary'), -1);
assert.strictEqual(buf_bc.lastIndexOf(Buffer.from('你好'), 7), -1);
// Test lastIndexOf on a longer buffer:
var bufferString = new Buffer('a man a plan a canal panama');
const bufferString = new Buffer('a man a plan a canal panama');
assert.equal(15, bufferString.lastIndexOf('canal'));
assert.equal(21, bufferString.lastIndexOf('panama'));
assert.equal(0, bufferString.lastIndexOf('a man a plan a canal panama'));
@ -485,16 +485,17 @@ assert.equal(511, longBufferString.lastIndexOf(pattern, 1534));
// countBits returns the number of bits in the binary reprsentation of n.
function countBits(n) {
for (var count = 0; n > 0; count++) {
let count;
for (count = 0; n > 0; count++) {
n = n & (n - 1); // remove top bit
}
return count;
}
var parts = [];
for (var i = 0; i < 1000000; i++) {
const parts = [];
for (let i = 0; i < 1000000; i++) {
parts.push((countBits(i) % 2 === 0) ? 'yolo' : 'swag');
}
var reallyLong = new Buffer(parts.join(' '));
const reallyLong = new Buffer(parts.join(' '));
assert.equal('yolo swag swag yolo', reallyLong.slice(0, 19).toString());
// Expensive reverse searches. Stress test lastIndexOf:

6
test/parallel/test-buffer-inspect.js

@ -6,13 +6,13 @@ const buffer = require('buffer');
buffer.INSPECT_MAX_BYTES = 2;
var b = Buffer.allocUnsafe(4);
let b = Buffer.allocUnsafe(4);
b.fill('1234');
var s = buffer.SlowBuffer(4);
let s = buffer.SlowBuffer(4);
s.fill('1234');
var expected = '<Buffer 31 32 ... >';
let expected = '<Buffer 31 32 ... >';
assert.strictEqual(util.inspect(b), expected);
assert.strictEqual(util.inspect(s), expected);

4
test/parallel/test-buffer-iterator.js

@ -3,8 +3,8 @@ require('../common');
const assert = require('assert');
const buffer = Buffer.from([1, 2, 3, 4, 5]);
var arr;
var b;
let arr;
let b;
// buffers should be iterable

48
test/parallel/test-buffer-swap.js

@ -45,80 +45,80 @@ assert.deepStrictEqual(buf3_64, Buffer.from([0x01, 0x02, 0x0a, 0x09, 0x08, 0x07,
0x0f, 0x10]));
// Force use of native code (Buffer size above threshold limit for js impl)
var buf4A = new Uint32Array(256).fill(0x04030201);
var buf4 = Buffer.from(buf4A.buffer, buf4A.byteOffset);
var buf5A = new Uint32Array(256).fill(0x03040102);
var buf5 = Buffer.from(buf5A.buffer, buf5A.byteOffset);
const buf4A = new Uint32Array(256).fill(0x04030201);
const buf4 = Buffer.from(buf4A.buffer, buf4A.byteOffset);
const buf5A = new Uint32Array(256).fill(0x03040102);
const buf5 = Buffer.from(buf5A.buffer, buf5A.byteOffset);
buf4.swap16();
assert.deepStrictEqual(buf4, buf5);
var buf6A = new Uint32Array(256).fill(0x04030201);
var buf6 = Buffer.from(buf6A.buffer);
var bu7A = new Uint32Array(256).fill(0x01020304);
var buf7 = Buffer.from(bu7A.buffer, bu7A.byteOffset);
const buf6A = new Uint32Array(256).fill(0x04030201);
const buf6 = Buffer.from(buf6A.buffer);
const bu7A = new Uint32Array(256).fill(0x01020304);
const buf7 = Buffer.from(bu7A.buffer, bu7A.byteOffset);
buf6.swap32();
assert.deepStrictEqual(buf6, buf7);
var buf8A = new Uint8Array(256 * 8);
var buf9A = new Uint8Array(256 * 8);
const buf8A = new Uint8Array(256 * 8);
const buf9A = new Uint8Array(256 * 8);
for (let i = 0; i < buf8A.length; i++) {
buf8A[i] = i % 8;
buf9A[buf9A.length - i - 1] = i % 8;
}
var buf8 = Buffer.from(buf8A.buffer, buf8A.byteOffset);
var buf9 = Buffer.from(buf9A.buffer, buf9A.byteOffset);
const buf8 = Buffer.from(buf8A.buffer, buf8A.byteOffset);
const buf9 = Buffer.from(buf9A.buffer, buf9A.byteOffset);
buf8.swap64();
assert.deepStrictEqual(buf8, buf9);
// Test native code with buffers that are not memory-aligned
var buf10A = new Uint8Array(256 * 8);
var buf11A = new Uint8Array(256 * 8 - 2);
const buf10A = new Uint8Array(256 * 8);
const buf11A = new Uint8Array(256 * 8 - 2);
for (let i = 0; i < buf10A.length; i++) {
buf10A[i] = i % 2;
}
for (let i = 1; i < buf11A.length; i++) {
buf11A[buf11A.length - i] = (i + 1) % 2;
}
var buf10 = Buffer.from(buf10A.buffer, buf10A.byteOffset);
const buf10 = Buffer.from(buf10A.buffer, buf10A.byteOffset);
// 0|1 0|1 0|1...
var buf11 = Buffer.from(buf11A.buffer, buf11A.byteOffset);
const buf11 = Buffer.from(buf11A.buffer, buf11A.byteOffset);
// 0|0 1|0 1|0...
buf10.slice(1, buf10.length - 1).swap16();
assert.deepStrictEqual(buf10.slice(0, buf11.length), buf11);
var buf12A = new Uint8Array(256 * 8);
var buf13A = new Uint8Array(256 * 8 - 4);
const buf12A = new Uint8Array(256 * 8);
const buf13A = new Uint8Array(256 * 8 - 4);
for (let i = 0; i < buf12A.length; i++) {
buf12A[i] = i % 4;
}
for (let i = 1; i < buf13A.length; i++) {
buf13A[buf13A.length - i] = (i + 1) % 4;
}
var buf12 = Buffer.from(buf12A.buffer, buf12A.byteOffset);
const buf12 = Buffer.from(buf12A.buffer, buf12A.byteOffset);
// 0|1 2 3 0|1 2 3...
var buf13 = Buffer.from(buf13A.buffer, buf13A.byteOffset);
const buf13 = Buffer.from(buf13A.buffer, buf13A.byteOffset);
// 0|0 3 2 1|0 3 2...
buf12.slice(1, buf12.length - 3).swap32();
assert.deepStrictEqual(buf12.slice(0, buf13.length), buf13);
var buf14A = new Uint8Array(256 * 8);
var buf15A = new Uint8Array(256 * 8 - 8);
const buf14A = new Uint8Array(256 * 8);
const buf15A = new Uint8Array(256 * 8 - 8);
for (let i = 0; i < buf14A.length; i++) {
buf14A[i] = i % 8;
}
for (let i = 1; i < buf15A.length; i++) {
buf15A[buf15A.length - i] = (i + 1) % 8;
}
var buf14 = Buffer.from(buf14A.buffer, buf14A.byteOffset);
const buf14 = Buffer.from(buf14A.buffer, buf14A.byteOffset);
// 0|1 2 3 4 5 6 7 0|1 2 3 4...
var buf15 = Buffer.from(buf15A.buffer, buf15A.byteOffset);
const buf15 = Buffer.from(buf15A.buffer, buf15A.byteOffset);
// 0|0 7 6 5 4 3 2 1|0 7 6 5...
buf14.slice(1, buf14.length - 7).swap64();

4
test/parallel/test-child-process-constructor.js

@ -3,11 +3,11 @@
require('../common');
const assert = require('assert');
const child_process = require('child_process');
var ChildProcess = child_process.ChildProcess;
const ChildProcess = child_process.ChildProcess;
assert.strictEqual(typeof ChildProcess, 'function');
// test that we can call spawn
var child = new ChildProcess();
const child = new ChildProcess();
child.spawn({
file: process.execPath,
args: ['--interactive'],

4
test/parallel/test-child-process-default-options.js

@ -6,14 +6,14 @@ const spawn = require('child_process').spawn;
process.env.HELLO = 'WORLD';
var child;
let child;
if (common.isWindows) {
child = spawn('cmd.exe', ['/c', 'set'], {});
} else {
child = spawn('/usr/bin/env', [], {});
}
var response = '';
let response = '';
child.stdout.setEncoding('utf8');

4
test/parallel/test-child-process-double-pipe.js

@ -8,7 +8,7 @@ const spawn = require('child_process').spawn;
// We're trying to reproduce:
// $ echo "hello\nnode\nand\nworld" | grep o | sed s/o/a/
var grep, sed, echo;
let grep, sed, echo;
if (common.isWindows) {
grep = spawn('grep', ['--binary', 'o']),
@ -82,7 +82,7 @@ grep.stdout.on('end', function(code) {
});
var result = '';
let result = '';
// print sed's output
sed.stdout.on('data', function(data) {

6
test/parallel/test-child-process-env.js

@ -4,14 +4,14 @@ const assert = require('assert');
const spawn = require('child_process').spawn;
var env = {
const env = {
'HELLO': 'WORLD'
};
Object.setPrototypeOf(env, {
'FOO': 'BAR'
});
var child;
let child;
if (common.isWindows) {
child = spawn('cmd.exe', ['/c', 'set'], {env: env});
} else {
@ -19,7 +19,7 @@ if (common.isWindows) {
}
var response = '';
let response = '';
child.stdout.setEncoding('utf8');

2
test/parallel/test-child-process-exec-cwd.js

@ -3,7 +3,7 @@ const common = require('../common');
const assert = require('assert');
const exec = require('child_process').exec;
var pwdcommand, dir;
let pwdcommand, dir;
if (common.isWindows) {
pwdcommand = 'echo %cd%';

4
test/parallel/test-child-process-exec-stdout-stderr-data-string.js

@ -4,8 +4,8 @@ const common = require('../common');
const assert = require('assert');
const exec = require('child_process').exec;
var stdoutCalls = 0;
var stderrCalls = 0;
let stdoutCalls = 0;
let stderrCalls = 0;
const command = common.isWindows ? 'dir' : 'ls';
exec(command).stdout.on('data', (data) => {

10
test/parallel/test-child-process-exit-code.js

@ -4,17 +4,17 @@ const assert = require('assert');
const spawn = require('child_process').spawn;
const path = require('path');
var exitScript = path.join(common.fixturesDir, 'exit.js');
var exitChild = spawn(process.argv[0], [exitScript, 23]);
const exitScript = path.join(common.fixturesDir, 'exit.js');
const exitChild = spawn(process.argv[0], [exitScript, 23]);
exitChild.on('exit', common.mustCall(function(code, signal) {
assert.strictEqual(code, 23);
assert.strictEqual(signal, null);
}));
var errorScript = path.join(common.fixturesDir,
'child_process_should_emit_error.js');
var errorChild = spawn(process.argv[0], [errorScript]);
const errorScript = path.join(common.fixturesDir,
'child_process_should_emit_error.js');
const errorChild = spawn(process.argv[0], [errorScript]);
errorChild.on('exit', common.mustCall(function(code, signal) {
assert.ok(code !== 0);
assert.strictEqual(signal, null);

2
test/parallel/test-child-process-fork-close.js

@ -3,7 +3,7 @@ const common = require('../common');
const assert = require('assert');
const fork = require('child_process').fork;
var cp = fork(common.fixturesDir + '/child-process-message-and-exit.js');
const cp = fork(common.fixturesDir + '/child-process-message-and-exit.js');
let gotMessage = false;
let gotExit = false;

4
test/parallel/test-child-process-fork-dgram.js

@ -37,8 +37,8 @@ if (process.argv[2] === 'child') {
const msg = Buffer.from('Some bytes');
var childGotMessage = false;
var parentGotMessage = false;
let childGotMessage = false;
let parentGotMessage = false;
parentServer.once('message', function(msg, rinfo) {
parentGotMessage = true;

12
test/parallel/test-child-process-fork-exec-argv.js

@ -2,8 +2,8 @@
require('../common');
const assert = require('assert');
const child_process = require('child_process');
var spawn = child_process.spawn;
var fork = child_process.fork;
const spawn = child_process.spawn;
const fork = child_process.fork;
if (process.argv[2] === 'fork') {
process.stdout.write(JSON.stringify(process.execArgv), function() {
@ -12,11 +12,11 @@ if (process.argv[2] === 'fork') {
} else if (process.argv[2] === 'child') {
fork(__filename, ['fork']);
} else {
var execArgv = ['--stack-size=256'];
var args = [__filename, 'child', 'arg0'];
const execArgv = ['--stack-size=256'];
const args = [__filename, 'child', 'arg0'];
var child = spawn(process.execPath, execArgv.concat(args));
var out = '';
const child = spawn(process.execPath, execArgv.concat(args));
let out = '';
child.stdout.on('data', function(chunk) {
out += chunk;

8
test/parallel/test-child-process-fork-exec-path.js

@ -3,9 +3,9 @@ const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
var msg = {test: 'this'};
var nodePath = process.execPath;
var copyPath = path.join(common.tmpDir, 'node-copy.exe');
const msg = {test: 'this'};
const nodePath = process.execPath;
const copyPath = path.join(common.tmpDir, 'node-copy.exe');
if (process.env.FORK) {
assert(process.send);
@ -23,7 +23,7 @@ if (process.env.FORK) {
fs.chmodSync(copyPath, '0755');
// slow but simple
var envCopy = JSON.parse(JSON.stringify(process.env));
const envCopy = JSON.parse(JSON.stringify(process.env));
envCopy.FORK = 'true';
const child = require('child_process').fork(__filename, {
execPath: copyPath,

32
test/parallel/test-child-process-fork-net.js

@ -19,7 +19,7 @@ ProgressTracker.prototype.check = function() {
if (process.argv[2] === 'child') {
var serverScope;
let serverScope;
process.on('message', function onServer(msg, server) {
if (msg.what !== 'server') return;
@ -58,17 +58,17 @@ if (process.argv[2] === 'child') {
process.send({what: 'ready'});
} else {
var child = fork(process.argv[1], ['child']);
const child = fork(process.argv[1], ['child']);
child.on('exit', function() {
console.log('CHILD: died');
});
// send net.Server to child and test by connecting
var testServer = function(callback) {
const testServer = function(callback) {
// destroy server execute callback when done
var progress = new ProgressTracker(2, function() {
const progress = new ProgressTracker(2, function() {
server.on('close', function() {
console.log('PARENT: server closed');
child.send({what: 'close'});
@ -77,11 +77,11 @@ if (process.argv[2] === 'child') {
});
// we expect 4 connections and close events
var connections = new ProgressTracker(4, progress.done.bind(progress));
var closed = new ProgressTracker(4, progress.done.bind(progress));
const connections = new ProgressTracker(4, progress.done.bind(progress));
const closed = new ProgressTracker(4, progress.done.bind(progress));
// create server and send it to child
var server = net.createServer();
const server = net.createServer();
server.on('connection', function(socket) {
console.log('PARENT: got connection');
socket.destroy();
@ -94,12 +94,12 @@ if (process.argv[2] === 'child') {
server.listen(0);
// handle client messages
var messageHandlers = function(msg) {
const messageHandlers = function(msg) {
if (msg.what === 'listening') {
// make connections
var socket;
for (var i = 0; i < 4; i++) {
let socket;
for (let i = 0; i < 4; i++) {
socket = net.connect(server.address().port, function() {
console.log('CLIENT: connected');
});
@ -122,11 +122,11 @@ if (process.argv[2] === 'child') {
};
// send net.Socket to child
var testSocket = function(callback) {
const testSocket = function(callback) {
// create a new server and connect to it,
// but the socket will be handled by the child
var server = net.createServer();
const server = net.createServer();
server.on('connection', function(socket) {
socket.on('close', function() {
console.log('CLIENT: socket closed');
@ -145,8 +145,8 @@ if (process.argv[2] === 'child') {
// will have to do.
server.listen(0, function() {
console.error('testSocket, listening');
var connect = net.connect(server.address().port);
var store = '';
const connect = net.connect(server.address().port);
let store = '';
connect.on('data', function(chunk) {
store += chunk;
console.log('CLIENT: got data');
@ -160,8 +160,8 @@ if (process.argv[2] === 'child') {
};
// create server and send it to child
var serverSuccess = false;
var socketSuccess = false;
let serverSuccess = false;
let socketSuccess = false;
child.on('message', function onReady(msg) {
if (msg.what !== 'ready') return;
child.removeListener('message', onReady);

22
test/parallel/test-child-process-fork-net2.js

@ -3,11 +3,11 @@ const common = require('../common');
const assert = require('assert');
const fork = require('child_process').fork;
const net = require('net');
var count = 12;
const count = 12;
if (process.argv[2] === 'child') {
var needEnd = [];
var id = process.argv[3];
const needEnd = [];
const id = process.argv[3];
process.on('message', function(m, socket) {
if (!socket) return;
@ -60,11 +60,11 @@ if (process.argv[2] === 'child') {
} else {
var child1 = fork(process.argv[1], ['child', '1']);
var child2 = fork(process.argv[1], ['child', '2']);
var child3 = fork(process.argv[1], ['child', '3']);
const child1 = fork(process.argv[1], ['child', '1']);
const child2 = fork(process.argv[1], ['child', '2']);
const child3 = fork(process.argv[1], ['child', '3']);
var server = net.createServer();
const server = net.createServer();
let connected = 0;
let closed = 0;
@ -94,10 +94,10 @@ if (process.argv[2] === 'child') {
}
});
var disconnected = 0;
let disconnected = 0;
server.on('listening', function() {
var j = count, client;
let j = count, client;
while (j--) {
client = net.connect(this.address().port, '127.0.0.1');
client.on('error', function() {
@ -112,7 +112,7 @@ if (process.argv[2] === 'child') {
}
});
var closeEmitted = false;
let closeEmitted = false;
server.on('close', common.mustCall(function() {
closeEmitted = true;
@ -123,7 +123,7 @@ if (process.argv[2] === 'child') {
server.listen(0, '127.0.0.1');
var closeServer = function() {
const closeServer = function() {
server.close();
setTimeout(function() {

5
test/parallel/test-child-process-fork-ref.js

@ -16,9 +16,10 @@ if (process.argv[2] === 'child') {
});
} else {
var child = fork(__filename, ['child'], {silent: true});
const child = fork(__filename, ['child'], {silent: true});
var ipc = [], stdout = '';
const ipc = [];
let stdout = '';
child.on('message', function(msg) {
ipc.push(msg);

2
test/parallel/test-child-process-fork-ref2.js

@ -12,7 +12,7 @@ if (process.argv[2] === 'child') {
}, 400);
} else {
var child = fork(__filename, ['child']);
const child = fork(__filename, ['child']);
child.on('disconnect', function() {
console.log('parent -> disconnect');

6
test/parallel/test-child-process-fork-regr-gh-2847.js

@ -14,7 +14,7 @@ if (!cluster.isMaster) {
return;
}
var server = net.createServer(function(s) {
const server = net.createServer(function(s) {
if (common.isWindows) {
s.on('error', function(err) {
// Prevent possible ECONNRESET errors from popping up
@ -26,10 +26,10 @@ var server = net.createServer(function(s) {
s.destroy();
}, 100);
}).listen(0, function() {
var worker = cluster.fork();
const worker = cluster.fork();
function send(callback) {
var s = net.connect(server.address().port, function() {
const s = net.connect(server.address().port, function() {
worker.send({}, s, callback);
});

4
test/parallel/test-child-process-fork.js

@ -2,9 +2,9 @@
const common = require('../common');
const assert = require('assert');
const fork = require('child_process').fork;
var args = ['foo', 'bar'];
const args = ['foo', 'bar'];
var n = fork(common.fixturesDir + '/child-process-spawn-node.js', args);
const n = fork(common.fixturesDir + '/child-process-spawn-node.js', args);
assert.strictEqual(n.channel, n._channel);
assert.deepStrictEqual(args, ['foo', 'bar']);

8
test/parallel/test-child-process-internal.js

@ -3,9 +3,9 @@ const common = require('../common');
const assert = require('assert');
//messages
var PREFIX = 'NODE_';
var normal = {cmd: 'foo' + PREFIX};
var internal = {cmd: PREFIX + 'bar'};
const PREFIX = 'NODE_';
const normal = {cmd: 'foo' + PREFIX};
const internal = {cmd: PREFIX + 'bar'};
if (process.argv[2] === 'child') {
//send non-internal message containing PREFIX at a non prefix position
@ -19,7 +19,7 @@ if (process.argv[2] === 'child') {
} else {
const fork = require('child_process').fork;
var child = fork(process.argv[1], ['child']);
const child = fork(process.argv[1], ['child']);
child.once('message', common.mustCall(function(data) {
assert.deepStrictEqual(data, normal);

2
test/parallel/test-child-process-send-returns-boolean.js

@ -15,7 +15,7 @@ assert.strictEqual(rv, true);
const spawnOptions = { stdio: ['pipe', 'pipe', 'pipe', 'ipc'] };
const s = spawn(process.execPath, [emptyFile], spawnOptions);
var handle = null;
let handle = null;
s.on('exit', function() {
handle.close();
});

4
test/parallel/test-child-process-set-blocking.js

@ -3,9 +3,9 @@ const common = require('../common');
const assert = require('assert');
const ch = require('child_process');
var SIZE = 100000;
const SIZE = 100000;
var cp = ch.spawn('python', ['-c', 'print ' + SIZE + ' * "C"'], {
const cp = ch.spawn('python', ['-c', 'print ' + SIZE + ' * "C"'], {
stdio: 'inherit'
});

12
test/parallel/test-child-process-silent.js

@ -32,15 +32,15 @@ if (process.argv[2] === 'pipe') {
// testcase | start parent && child IPC test
// testing: is stderr and stdout piped to parent
var args = [process.argv[1], 'parent'];
var parent = childProcess.spawn(process.execPath, args);
const args = [process.argv[1], 'parent'];
const parent = childProcess.spawn(process.execPath, args);
//got any stderr or std data
var stdoutData = false;
let stdoutData = false;
parent.stdout.on('data', function() {
stdoutData = true;
});
var stderrData = false;
let stderrData = false;
parent.stdout.on('data', function() {
stderrData = true;
});
@ -52,8 +52,8 @@ if (process.argv[2] === 'pipe') {
child.stderr.pipe(process.stderr, {end: false});
child.stdout.pipe(process.stdout, {end: false});
var childSending = false;
var childReciveing = false;
let childSending = false;
let childReciveing = false;
child.on('message', function(message) {
if (childSending === false) {
childSending = (message === 'message from child');

2
test/parallel/test-child-process-spawn-typeerror.js

@ -14,7 +14,7 @@ const invalidFileMsg =
const empty = common.fixturesDir + '/empty.js';
assert.throws(function() {
var child = spawn(invalidcmd, 'this is not an array');
const child = spawn(invalidcmd, 'this is not an array');
child.on('error', common.fail);
}, TypeError);

4
test/parallel/test-child-process-spawnsync-env.js

@ -6,8 +6,8 @@ const cp = require('child_process');
if (process.argv[2] === 'child') {
console.log(process.env.foo);
} else {
var expected = 'bar';
var child = cp.spawnSync(process.execPath, [__filename, 'child'], {
const expected = 'bar';
const child = cp.spawnSync(process.execPath, [__filename, 'child'], {
env: Object.assign(process.env, { foo: expected })
});

4
test/parallel/test-child-process-spawnsync-input.js

@ -17,7 +17,7 @@ const args = [
`console.log("${msgOut}"); console.error("${msgErr}");`
];
var ret;
let ret;
function checkSpawnSyncRet(ret) {
@ -51,7 +51,7 @@ if (process.argv.indexOf('spawnchild') !== -1) {
verifyBufOutput(spawnSync(process.execPath, [__filename, 'spawnchild', 1]));
verifyBufOutput(spawnSync(process.execPath, [__filename, 'spawnchild', 2]));
var options = {
let options = {
input: 1234
};

10
test/parallel/test-child-process-spawnsync-timeout.js

@ -4,8 +4,8 @@ const assert = require('assert');
const spawnSync = require('child_process').spawnSync;
var TIMER = 200;
var SLEEP = 5000;
const TIMER = 200;
const SLEEP = 5000;
switch (process.argv[2]) {
case 'child':
@ -15,12 +15,12 @@ switch (process.argv[2]) {
}, SLEEP);
break;
default:
var start = Date.now();
var ret = spawnSync(process.execPath, [__filename, 'child'],
const start = Date.now();
const ret = spawnSync(process.execPath, [__filename, 'child'],
{timeout: TIMER});
assert.strictEqual(ret.error.errno, 'ETIMEDOUT');
console.log(ret);
var end = Date.now() - start;
const end = Date.now() - start;
assert(end < SLEEP);
assert(ret.status > 128 || ret.signal);
break;

2
test/parallel/test-child-process-stdin-ipc.js

@ -10,7 +10,7 @@ if (process.argv[2] === 'child') {
return;
}
var proc = spawn(process.execPath, [__filename, 'child'], {
const proc = spawn(process.execPath, [__filename, 'child'], {
stdio: ['ipc', 'inherit', 'inherit']
});

3
test/parallel/test-child-process-stdio-big-write-end.js

@ -28,8 +28,9 @@ function parent() {
});
// Write until the buffer fills up.
let buf;
do {
var buf = Buffer.alloc(BUFSIZE, '.');
buf = Buffer.alloc(BUFSIZE, '.');
sent += BUFSIZE;
} while (child.stdin.write(buf));

6
test/parallel/test-child-process-stdio-inherit.js

@ -9,10 +9,10 @@ else
grandparent();
function grandparent() {
var child = spawn(process.execPath, [__filename, 'parent']);
const child = spawn(process.execPath, [__filename, 'parent']);
child.stderr.pipe(process.stderr);
var output = '';
var input = 'asdfasdf';
let output = '';
const input = 'asdfasdf';
child.stdout.on('data', function(chunk) {
output += chunk;

4
test/parallel/test-cli-eval.js

@ -14,7 +14,7 @@ const nodejs = '"' + process.execPath + '"';
// replace \ by / because windows uses backslashes in paths, but they're still
// interpreted as the escape character when put between quotes.
var filename = __filename.replace(/\\/g, '/');
const filename = __filename.replace(/\\/g, '/');
// assert that nothing is written to stdout
child.exec(nodejs + ' --eval 42',
@ -32,7 +32,7 @@ child.exec(nodejs + ' --eval "console.error(42)"',
// assert that the expected output is written to stdout
['--print', '-p -e', '-pe', '-p'].forEach(function(s) {
var cmd = nodejs + ' ' + s + ' ';
const cmd = nodejs + ' ' + s + ' ';
child.exec(cmd + '42',
function(err, stdout, stderr) {

20
test/parallel/test-cli-syntax.js

@ -5,10 +5,10 @@ const assert = require('assert');
const spawnSync = require('child_process').spawnSync;
const path = require('path');
var node = process.execPath;
const node = process.execPath;
// test both sets of arguments that check syntax
var syntaxArgs = [
const syntaxArgs = [
['-c'],
['--check']
];
@ -25,8 +25,8 @@ var syntaxArgs = [
// loop each possible option, `-c` or `--check`
syntaxArgs.forEach(function(args) {
var _args = args.concat(file);
var c = spawnSync(node, _args, {encoding: 'utf8'});
const _args = args.concat(file);
const c = spawnSync(node, _args, {encoding: 'utf8'});
// no output should be produced
assert.strictEqual(c.stdout, '', 'stdout produced');
@ -46,14 +46,14 @@ var syntaxArgs = [
// loop each possible option, `-c` or `--check`
syntaxArgs.forEach(function(args) {
var _args = args.concat(file);
var c = spawnSync(node, _args, {encoding: 'utf8'});
const _args = args.concat(file);
const c = spawnSync(node, _args, {encoding: 'utf8'});
// no stdout should be produced
assert.strictEqual(c.stdout, '', 'stdout produced');
// stderr should have a syntax error message
var match = c.stderr.match(/^SyntaxError: Unexpected identifier$/m);
const match = c.stderr.match(/^SyntaxError: Unexpected identifier$/m);
assert(match, 'stderr incorrect');
assert.strictEqual(c.status, 1, 'code == ' + c.status);
@ -69,14 +69,14 @@ var syntaxArgs = [
// loop each possible option, `-c` or `--check`
syntaxArgs.forEach(function(args) {
var _args = args.concat(file);
var c = spawnSync(node, _args, {encoding: 'utf8'});
const _args = args.concat(file);
const c = spawnSync(node, _args, {encoding: 'utf8'});
// no stdout should be produced
assert.strictEqual(c.stdout, '', 'stdout produced');
// stderr should have a module not found error message
var match = c.stderr.match(/^Error: Cannot find module/m);
const match = c.stderr.match(/^Error: Cannot find module/m);
assert(match, 'stderr incorrect');
assert.strictEqual(c.status, 1, 'code == ' + c.status);

5
test/parallel/test-cluster-basic.js

@ -56,7 +56,6 @@ if (cluster.isWorker) {
}
};
var worker;
const stateNames = Object.keys(checks.worker.states);
//Check events, states, and emit arguments
@ -72,7 +71,7 @@ if (cluster.isWorker) {
checks.cluster.equal[name] = worker === arguments[0];
//Check state
var state = stateNames[index];
const state = stateNames[index];
checks.worker.states[state] = (state === worker.state);
}));
});
@ -86,7 +85,7 @@ if (cluster.isWorker) {
cluster.on('exit', common.mustCall(() => {}));
//Create worker
worker = cluster.fork();
const worker = cluster.fork();
assert.strictEqual(worker.id, 1);
assert(worker instanceof cluster.Worker,
'the worker is not a instance of the Worker constructor');

2
test/parallel/test-cluster-bind-privileged-port.js

@ -19,7 +19,7 @@ if (cluster.isMaster) {
assert.strictEqual(exitCode, 0);
}));
} else {
var s = net.createServer(common.fail);
const s = net.createServer(common.fail);
s.listen(42, common.fail.bind(null, 'listen should have failed'));
s.on('error', common.mustCall((err) => {
assert.strictEqual(err.code, 'EACCES');

12
test/parallel/test-cluster-dgram-1.js

@ -21,10 +21,10 @@ else
function master() {
var listening = 0;
let listening = 0;
// Fork 4 workers.
for (var i = 0; i < NUM_WORKERS; i++)
for (let i = 0; i < NUM_WORKERS; i++)
cluster.fork();
// Wait until all workers are listening.
@ -35,7 +35,7 @@ function master() {
// Start sending messages.
const buf = Buffer.from('hello world');
const socket = dgram.createSocket('udp4');
var sent = 0;
let sent = 0;
doSend();
function doSend() {
@ -60,7 +60,7 @@ function master() {
}
function setupWorker(worker) {
var received = 0;
let received = 0;
worker.on('message', common.mustCall((msg) => {
received = msg.received;
@ -75,10 +75,10 @@ function master() {
function worker() {
var received = 0;
let received = 0;
// Create udp socket and start listening.
var socket = dgram.createSocket('udp4');
const socket = dgram.createSocket('udp4');
socket.on('message', common.mustCall((data, info) => {
received++;

6
test/parallel/test-cluster-dgram-2.js

@ -20,10 +20,10 @@ else
function master() {
var received = 0;
let received = 0;
// Start listening on a socket.
var socket = dgram.createSocket('udp4');
const socket = dgram.createSocket('udp4');
socket.bind(common.PORT);
// Disconnect workers when the expected number of messages have been
@ -42,7 +42,7 @@ function master() {
}, NUM_WORKERS * PACKETS_PER_WORKER));
// Fork workers.
for (var i = 0; i < NUM_WORKERS; i++)
for (let i = 0; i < NUM_WORKERS; i++)
cluster.fork();
}

6
test/parallel/test-cluster-dgram-reuse.js

@ -25,16 +25,16 @@ function next() {
// Work around health check issue
process.nextTick(() => {
for (var i = 0; i < sockets.length; i++)
for (let i = 0; i < sockets.length; i++)
sockets[i].close(close);
});
}
var waiting = 2;
let waiting = 2;
function close() {
if (--waiting === 0)
cluster.worker.disconnect();
}
for (var i = 0; i < 2; i++)
for (let i = 0; i < 2; i++)
dgram.createSocket({ type: 'udp4', reuseAddr: true }).bind(common.PORT, next);

6
test/parallel/test-cluster-disconnect-race.js

@ -16,9 +16,9 @@ if (common.isWindows) {
cluster.schedulingPolicy = cluster.SCHED_NONE;
if (cluster.isMaster) {
var worker1, worker2;
let worker2;
worker1 = cluster.fork();
const worker1 = cluster.fork();
worker1.on('message', common.mustCall(function() {
worker2 = cluster.fork();
worker1.disconnect();
@ -32,7 +32,7 @@ if (cluster.isMaster) {
return;
}
var server = net.createServer();
const server = net.createServer();
server.listen(common.PORT, function() {
process.send('listening');

2
test/parallel/test-cluster-disconnect-suicide-race.js

@ -14,7 +14,7 @@ if (cluster.isMaster) {
return cluster.fork();
}
var eventFired = false;
let eventFired = false;
cluster.worker.disconnect();

2
test/parallel/test-cluster-disconnect-with-no-workers.js

@ -3,7 +3,7 @@ require('../common');
const assert = require('assert');
const cluster = require('cluster');
var disconnected;
let disconnected;
process.on('exit', function() {
assert(disconnected);

16
test/parallel/test-cluster-disconnect.js

@ -14,13 +14,13 @@ if (cluster.isWorker) {
}).listen(common.PORT + 1, '127.0.0.1');
} else if (cluster.isMaster) {
var servers = 2;
const servers = 2;
// test a single TCP server
const testConnection = function(port, cb) {
var socket = net.connect(port, '127.0.0.1', () => {
const socket = net.connect(port, '127.0.0.1', () => {
// buffer result
var result = '';
let result = '';
socket.on('data', common.mustCall((chunk) => { result += chunk; }));
// check result
@ -32,9 +32,9 @@ if (cluster.isWorker) {
// test both servers created in the cluster
const testCluster = function(cb) {
var done = 0;
let done = 0;
for (var i = 0, l = servers; i < l; i++) {
for (let i = 0, l = servers; i < l; i++) {
testConnection(common.PORT + i, (success) => {
assert.ok(success);
done += 1;
@ -47,10 +47,10 @@ if (cluster.isWorker) {
// start two workers and execute callback when both is listening
const startCluster = function(cb) {
var workers = 8;
var online = 0;
const workers = 8;
let online = 0;
for (var i = 0, l = workers; i < l; i++) {
for (let i = 0, l = workers; i < l; i++) {
cluster.fork().on('listening', common.mustCall(() => {
online += 1;
if (online === workers * servers) {

2
test/parallel/test-cluster-eaccess.js

@ -37,7 +37,7 @@ if (cluster.isMaster) {
} else {
common.refreshTmpDir();
var cp = fork(common.fixturesDir + '/listen-on-socket-and-exit.js',
const cp = fork(common.fixturesDir + '/listen-on-socket-and-exit.js',
{ stdio: 'inherit' });
// message from the child indicates it's ready and listening

4
test/parallel/test-cluster-eaddrinuse.js

@ -8,12 +8,12 @@ const assert = require('assert');
const fork = require('child_process').fork;
const net = require('net');
var id = '' + process.argv[2];
const id = '' + process.argv[2];
if (id === 'undefined') {
const server = net.createServer(common.fail);
server.listen(common.PORT, function() {
var worker = fork(__filename, ['worker']);
const worker = fork(__filename, ['worker']);
worker.on('message', function(msg) {
if (msg !== 'stop-listening') return;
server.close(function() {

4
test/parallel/test-cluster-fork-env.js

@ -12,7 +12,7 @@ if (cluster.isWorker) {
assert.strictEqual(result, true);
} else if (cluster.isMaster) {
var checks = {
const checks = {
using: false,
overwrite: false
};
@ -22,7 +22,7 @@ if (cluster.isWorker) {
process.env['cluster_test_overwrite'] = 'old';
// Fork worker
var worker = cluster.fork({
const worker = cluster.fork({
'cluster_test_prop': 'custom',
'cluster_test_overwrite': 'new'
});

10
test/parallel/test-cluster-master-error.js

@ -15,7 +15,7 @@ if (cluster.isWorker) {
} else if (process.argv[2] === 'cluster') {
// Send PID to testcase process
var forkNum = 0;
let forkNum = 0;
cluster.on('fork', common.mustCall(function forkEvent(worker) {
// Send PID
@ -31,7 +31,7 @@ if (cluster.isWorker) {
}));
// Throw accidental error when all workers are listening
var listeningNum = 0;
let listeningNum = 0;
cluster.on('listening', common.mustCall(function listeningEvent() {
// When all workers are listening
@ -56,8 +56,8 @@ if (cluster.isWorker) {
const fork = require('child_process').fork;
var masterExited = false;
var workersExited = false;
let masterExited = false;
let workersExited = false;
// List all workers
const workers = [];
@ -82,7 +82,7 @@ if (cluster.isWorker) {
const pollWorkers = function() {
// When master is dead all workers should be dead too
var alive = false;
let alive = false;
workers.forEach((pid) => alive = common.isAlive(pid));
if (alive) {
setTimeout(pollWorkers, 50);

4
test/parallel/test-cluster-master-kill.js

@ -34,13 +34,13 @@ if (cluster.isWorker) {
const master = fork(process.argv[1], ['cluster']);
// get pid info
var pid = null;
let pid = null;
master.once('message', (data) => {
pid = data.pid;
});
// When master is dead
var alive = true;
let alive = true;
master.on('exit', common.mustCall((code) => {
// make sure that the master died on purpose

14
test/parallel/test-cluster-message.js

@ -13,8 +13,8 @@ function forEach(obj, fn) {
if (cluster.isWorker) {
// Create a tcp server. This will be used as cluster-shared-server and as an
// alternative IPC channel.
var server = net.Server();
var socket, message;
const server = net.Server();
let socket, message;
function maybeReply() {
if (!socket || !message) return;
@ -42,7 +42,7 @@ if (cluster.isWorker) {
server.listen(common.PORT, '127.0.0.1');
} else if (cluster.isMaster) {
var checks = {
const checks = {
global: {
'receive': false,
'correct': false
@ -58,13 +58,13 @@ if (cluster.isWorker) {
};
var client;
var check = function(type, result) {
let client;
const check = function(type, result) {
checks[type].receive = true;
checks[type].correct = result;
console.error('check', checks);
var missing = false;
let missing = false;
forEach(checks, function(type) {
if (type.receive === false) missing = true;
});
@ -76,7 +76,7 @@ if (cluster.isWorker) {
};
// Spawn worker
var worker = cluster.fork();
const worker = cluster.fork();
// When a IPC message is received from the worker
worker.on('message', function(message) {

5
test/parallel/test-cluster-rr-domain-listen.js

@ -7,14 +7,13 @@ const domain = require('domain');
// cluster.schedulingPolicy = cluster.SCHED_RR;
if (cluster.isWorker) {
var d = domain.create();
const d = domain.create();
d.run(function() { });
const http = require('http');
http.Server(function() { }).listen(common.PORT, '127.0.0.1');
} else if (cluster.isMaster) {
var worker;
//Kill worker when listening
cluster.on('listening', function() {
@ -27,5 +26,5 @@ if (cluster.isWorker) {
});
//Create worker
worker = cluster.fork();
const worker = cluster.fork();
}

10
test/parallel/test-cluster-send-deadlock.js

@ -8,14 +8,14 @@ const cluster = require('cluster');
const net = require('net');
if (cluster.isMaster) {
var worker = cluster.fork();
const worker = cluster.fork();
worker.on('exit', function(code, signal) {
assert.strictEqual(code, 0, 'Worker exited with an error code');
assert(!signal, 'Worker exited by a signal');
server.close();
});
var server = net.createServer(function(socket) {
const server = net.createServer(function(socket) {
worker.send('handle', socket);
});
@ -25,9 +25,9 @@ if (cluster.isMaster) {
} else {
process.on('message', function(msg, handle) {
if (msg === 'listen') {
var client1 = net.connect({ host: 'localhost', port: common.PORT });
var client2 = net.connect({ host: 'localhost', port: common.PORT });
var waiting = 2;
const client1 = net.connect({ host: 'localhost', port: common.PORT });
const client2 = net.connect({ host: 'localhost', port: common.PORT });
let waiting = 2;
client1.on('close', onclose);
client2.on('close', onclose);
function onclose() {

4
test/parallel/test-cluster-setup-master-argv.js

@ -6,8 +6,8 @@ const cluster = require('cluster');
setTimeout(common.fail.bind(assert, 'setup not emitted'), 1000).unref();
cluster.on('setup', common.mustCall(function() {
var clusterArgs = cluster.settings.args;
var realArgs = process.argv;
const clusterArgs = cluster.settings.args;
const realArgs = process.argv;
assert.strictEqual(clusterArgs[clusterArgs.length - 1],
realArgs[realArgs.length - 1]);
}));

4
test/parallel/test-cluster-setup-master-multiple.js

@ -13,7 +13,7 @@ function cheapClone(obj) {
return JSON.parse(JSON.stringify(obj));
}
var configs = [];
const configs = [];
// Capture changes
cluster.on('setup', function() {
@ -21,7 +21,7 @@ cluster.on('setup', function() {
configs.push(cheapClone(cluster.settings));
});
var execs = [
const execs = [
'node-next',
'node-next-2',
'node-next-3',

12
test/parallel/test-cluster-setup-master.js

@ -10,14 +10,14 @@ if (cluster.isWorker) {
} else if (cluster.isMaster) {
var checks = {
const checks = {
args: false,
setupEvent: false,
settingsObject: false
};
var totalWorkers = 2;
var onlineWorkers = 0;
const totalWorkers = 2;
let onlineWorkers = 0;
// Setup master
cluster.setupMaster({
@ -28,7 +28,7 @@ if (cluster.isWorker) {
cluster.once('setup', function() {
checks.setupEvent = true;
var settings = cluster.settings;
const settings = cluster.settings;
if (settings &&
settings.args && settings.args[0] === 'custom argument' &&
settings.silent === true &&
@ -37,7 +37,7 @@ if (cluster.isWorker) {
}
});
var correctIn = 0;
let correctIn = 0;
cluster.on('online', function lisenter(worker) {
@ -66,7 +66,7 @@ if (cluster.isWorker) {
assert.ok(checks.workers, 'Not all workers went online');
assert.ok(checks.args, 'The arguments was noy send to the worker');
assert.ok(checks.setupEvent, 'The setup event was never emitted');
var m = 'The settingsObject do not have correct properties';
const m = 'The settingsObject do not have correct properties';
assert.ok(checks.settingsObject, m);
});

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save