diff --git a/test/addons/async-hello-world/test.js b/test/addons/async-hello-world/test.js
index 7c27382c1c60f4..a6aa8aa20fffbc 100644
--- a/test/addons/async-hello-world/test.js
+++ b/test/addons/async-hello-world/test.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../../common');
-var assert = require('assert');
+const assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);
binding(5, common.mustCall(function(err, val) {
diff --git a/test/addons/buffer-free-callback/test.js b/test/addons/buffer-free-callback/test.js
index 8dbc2d57725c56..d25130a905ac90 100644
--- a/test/addons/buffer-free-callback/test.js
+++ b/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);
diff --git a/test/addons/hello-world-function-export/test.js b/test/addons/hello-world-function-export/test.js
index 74ea66c79c548c..173cf5428e086f 100644
--- a/test/addons/hello-world-function-export/test.js
+++ b/test/addons/hello-world-function-export/test.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../../common');
-var assert = require('assert');
+const assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);
assert.strictEqual(binding(), 'world');
console.log('binding.hello() =', binding());
diff --git a/test/addons/hello-world/test.js b/test/addons/hello-world/test.js
index 32066388efe6cb..b0148e9d9e9014 100644
--- a/test/addons/hello-world/test.js
+++ b/test/addons/hello-world/test.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../../common');
-var assert = require('assert');
+const assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);
assert.strictEqual(binding.hello(), 'world');
console.log('binding.hello() =', binding.hello());
diff --git a/test/addons/load-long-path/test.js b/test/addons/load-long-path/test.js
index b17942b45a6f34..ff612b66488f75 100644
--- a/test/addons/load-long-path/test.js
+++ b/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,10 +28,10 @@ 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
-var addon = require(addonDestinationPath);
+const addon = require(addonDestinationPath);
assert.notEqual(addon, null);
assert.strictEqual(addon.hello(), 'world');
diff --git a/test/addons/make-callback-recurse/test.js b/test/addons/make-callback-recurse/test.js
index 0145a142e40f09..46b1327d7dedac 100644
--- a/test/addons/make-callback-recurse/test.js
+++ b/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}`);
}
diff --git a/test/addons/repl-domain-abort/test.js b/test/addons/repl-domain-abort/test.js
index 5591b4f2b38e90..95536f99711324 100644
--- a/test/addons/repl-domain-abort/test.js
+++ b/test/addons/repl-domain-abort/test.js
@@ -1,30 +1,30 @@
'use strict';
-var common = require('../../common');
-var assert = require('assert');
-var repl = require('repl');
-var stream = require('stream');
-var path = require('path');
-var buildType = process.config.target_defaults.default_configuration;
-var buildPath = path.join(__dirname, 'build', buildType, 'binding');
+const common = require('../../common');
+const assert = require('assert');
+const repl = require('repl');
+const stream = require('stream');
+const path = require('path');
+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,
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js
index 2ce695852e25ae..5dd727f8ffddd3 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js
+++ b/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);
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js
index 4be525d79fa39e..2466c8ec42ed57 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js
+++ b/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);
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js
index 47426bf6352bbb..16f0f5392e5206 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js
+++ b/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);
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js
index 51324a3f337731..1028706b1d1aa9 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js
+++ b/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;
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js
index ae6966d0545194..caf6112011e2a8 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js
+++ b/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);
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js
index cea175aa93ab5c..4d3199a033e6d5 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js
+++ b/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);
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js
index 0fab606e4663ec..786d0b679895e1 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js
+++ b/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);
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js
index f984179525abeb..36b0d4174a030b 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js
+++ b/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);
diff --git a/test/common.js b/test/common.js
index 0721ad94ec7c2b..af6e27c4db3c46 100644
--- a/test/common.js
+++ b/test/common.js
@@ -208,7 +208,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
diff --git a/test/debugger/helper-debugger-repl.js b/test/debugger/helper-debugger-repl.js
index 602ab1c05e53d6..38c65a03fa590d 100644
--- a/test/debugger/helper-debugger-repl.js
+++ b/test/debugger/helper-debugger-repl.js
@@ -1,15 +1,15 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
+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);
diff --git a/test/debugger/test-debugger-client.js b/test/debugger/test-debugger-client.js
index 869dabc6ef0c43..660d8e286ee250 100644
--- a/test/debugger/test-debugger-client.js
+++ b/test/debugger/test-debugger-client.js
@@ -1,12 +1,12 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var debug = require('_debugger');
+const assert = require('assert');
+const debug = require('_debugger');
process.env.NODE_DEBUGGER_TIMEOUT = 2000;
-var debugPort = common.PORT;
+const debugPort = common.PORT;
debug.port = debugPort;
-var spawn = require('child_process').spawn;
+const spawn = require('child_process').spawn;
setTimeout(function() {
if (nodeProcess) nodeProcess.kill('SIGTERM');
@@ -14,8 +14,8 @@ setTimeout(function() {
}, 10000).unref();
-var resCount = 0;
-var p = new debug.Protocol();
+let resCount = 0;
+const p = new debug.Protocol();
p.onResponse = function() {
resCount++;
};
@@ -29,12 +29,12 @@ assert.strictEqual(resCount, 1);
// Make sure split messages go in.
-var parts = [];
+const parts = [];
parts.push('Content-Length: 336\r\n');
assert.strictEqual(parts[0].length, 21);
parts.push('\r\n');
assert.strictEqual(parts[1].length, 2);
-var bodyLength = 0;
+let bodyLength = 0;
parts.push('{"seq":12,"type":"event","event":"break","body":' +
'{"invocationText":"#');
@@ -55,7 +55,7 @@ bodyLength += parts[4].length;
assert.strictEqual(bodyLength, 336);
-for (var i = 0; i < parts.length; i++) {
+for (let i = 0; i < parts.length; i++) {
p.execute(parts[i]);
}
assert.strictEqual(resCount, 2);
@@ -63,24 +63,24 @@ assert.strictEqual(resCount, 2);
// Make sure that if we get backed up, we still manage to get all the
// messages
-var d = 'Content-Length: 466\r\n\r\n' +
- '{"seq":10,"type":"event","event":"afterCompile","success":true,' +
- '"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
- '"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,' +
- '"sourceStart":"(function(module, exports, require) {' +
- 'var dns = process.binding(\'cares\')' +
- ';\\nvar ne","sourceLength":6137,"scriptType":2,"compilationType":0,' +
- '"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' +
- '[{"handle":0' +
- ',"type":"context","text":"#"}],"running":true}' +
- '\r\n\r\nContent-Length: 119\r\n\r\n' +
- '{"seq":11,"type":"event","event":"scriptCollected","success":true,' +
- '"body":{"script":{"id":26}},"refs":[],"running":true}';
+const d = 'Content-Length: 466\r\n\r\n' +
+ '{"seq":10,"type":"event","event":"afterCompile","success":true,' +
+ '"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
+ '"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,' +
+ '"sourceStart":"(function(module, exports, require) {' +
+ 'let dns = process.binding(\'cares\')' +
+ ';\\nlet ne","sourceLength":6137,"scriptType":2,"compilationType":0' +
+ ',"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' +
+ '[{"handle":0' +
+ ',"type":"context","text":"#"}],"running":true}' +
+ '\r\n\r\nContent-Length: 119\r\n\r\n' +
+ '{"seq":11,"type":"event","event":"scriptCollected","success":true,' +
+ '"body":{"script":{"id":26}},"refs":[],"running":true}';
p.execute(d);
assert.strictEqual(resCount, 4);
-var expectedConnections = 0;
-var tests = [];
+let expectedConnections = 0;
+const tests = [];
function addTest(cb) {
expectedConnections++;
tests.push(cb);
@@ -102,9 +102,9 @@ addTest(function(client, done) {
assert.ifError(err);
console.error('got %d scripts', Object.keys(client.scripts).length);
- var foundMainScript = false;
- for (var k in client.scripts) {
- var script = client.scripts[k];
+ let foundMainScript = false;
+ for (const k in client.scripts) {
+ const script = client.scripts[k];
if (script && script.name === 'bootstrap_node.js') {
foundMainScript = true;
break;
@@ -127,19 +127,19 @@ addTest(function(client, done) {
});
-var connectCount = 0;
-var script = 'setTimeout(function() { console.log("blah"); });' +
- 'setInterval(function() {}, 1000000);';
+let connectCount = 0;
+const script = 'setTimeout(function() { console.log("blah"); });' +
+ 'setInterval(function() {}, 1000000);';
-var nodeProcess;
+let nodeProcess;
function doTest(cb, done) {
- var args = ['--debug=' + debugPort, '-e', script];
+ const args = ['--debug=' + debugPort, '-e', script];
nodeProcess = spawn(process.execPath, args);
nodeProcess.stdout.once('data', function() {
console.log('>>> new node process: %d', nodeProcess.pid);
- var failed = true;
+ let failed = true;
try {
process._debugProcess(nodeProcess.pid);
failed = false;
@@ -151,9 +151,9 @@ function doTest(cb, done) {
console.log('>>> starting debugger session');
});
- var didTryConnect = false;
+ let didTryConnect = false;
nodeProcess.stderr.setEncoding('utf8');
- var b = '';
+ let b = '';
nodeProcess.stderr.on('data', function(data) {
console.error('got stderr data %j', data);
nodeProcess.stderr.resume();
diff --git a/test/debugger/test-debugger-repl-break-in-module.js b/test/debugger/test-debugger-repl-break-in-module.js
index 91782ae6e3ef28..2e7b9a58aacb0e 100644
--- a/test/debugger/test-debugger-repl-break-in-module.js
+++ b/test/debugger/test-debugger-repl-break-in-module.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var repl = require('./helper-debugger-repl.js');
+const repl = require('./helper-debugger-repl.js');
repl.startDebugger('break-in-module/main.js');
diff --git a/test/debugger/test-debugger-repl-restart.js b/test/debugger/test-debugger-repl-restart.js
index 206cd2e7417627..f5de9f5ee95778 100644
--- a/test/debugger/test-debugger-repl-restart.js
+++ b/test/debugger/test-debugger-repl-restart.js
@@ -1,15 +1,15 @@
'use strict';
require('../common');
-var repl = require('./helper-debugger-repl.js');
+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
diff --git a/test/debugger/test-debugger-repl-term.js b/test/debugger/test-debugger-repl-term.js
index 6872f6ce2f9c72..4932df12e713bb 100644
--- a/test/debugger/test-debugger-repl-term.js
+++ b/test/debugger/test-debugger-repl-term.js
@@ -2,11 +2,11 @@
require('../common');
process.env.NODE_FORCE_READLINE = 1;
-var repl = require('./helper-debugger-repl.js');
+const repl = require('./helper-debugger-repl.js');
repl.startDebugger('breakpoints.js');
-var addTest = repl.addTest;
+const addTest = repl.addTest;
// next
addTest('n', [
diff --git a/test/debugger/test-debugger-repl-utf8.js b/test/debugger/test-debugger-repl-utf8.js
index 6654a498219859..90214158884371 100644
--- a/test/debugger/test-debugger-repl-utf8.js
+++ b/test/debugger/test-debugger-repl-utf8.js
@@ -1,6 +1,6 @@
'use strict';
-var common = require('../common');
-var script = common.fixturesDir + '/breakpoints_utf8.js';
+const common = require('../common');
+const script = common.fixturesDir + '/breakpoints_utf8.js';
process.env.NODE_DEBUGGER_TEST_SCRIPT = script;
require('./test-debugger-repl.js');
diff --git a/test/debugger/test-debugger-repl.js b/test/debugger/test-debugger-repl.js
index ab0468448bef4d..32dbfa22c0d3a9 100644
--- a/test/debugger/test-debugger-repl.js
+++ b/test/debugger/test-debugger-repl.js
@@ -1,10 +1,10 @@
'use strict';
-var common = require('../common');
-var repl = require('./helper-debugger-repl.js');
+const common = require('../common');
+const repl = require('./helper-debugger-repl.js');
repl.startDebugger('breakpoints.js');
-var addTest = repl.addTest;
+const addTest = repl.addTest;
// Next
addTest('n', [
diff --git a/test/gc/test-http-client-connaborted.js b/test/gc/test-http-client-connaborted.js
index 071baf738ee9d3..6ff2a282d89c98 100644
--- a/test/gc/test-http-client-connaborted.js
+++ b/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);
diff --git a/test/gc/test-http-client-onerror.js b/test/gc/test-http-client-onerror.js
index a2ef0fa4bee9b7..b17ab428a2ccd7 100644
--- a/test/gc/test-http-client-onerror.js
+++ b/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);
diff --git a/test/gc/test-http-client-timeout.js b/test/gc/test-http-client-timeout.js
index 27baf837ca8282..fb4e8ba0f7058d 100644
--- a/test/gc/test-http-client-timeout.js
+++ b/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);
diff --git a/test/gc/test-http-client.js b/test/gc/test-http-client.js
index 06bd08b2651d1b..f81cab0b09d2c2 100644
--- a/test/gc/test-http-client.js
+++ b/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() {
diff --git a/test/gc/test-net-timeout.js b/test/gc/test-net-timeout.js
index 9bc19a04256108..34893707a07d84 100644
--- a/test/gc/test-net-timeout.js
+++ b/test/gc/test-net-timeout.js
@@ -7,7 +7,7 @@ require('../common');
function serverHandler(sock) {
sock.setTimeout(120000);
sock.resume();
- var timer;
+ let timer;
sock.on('close', function() {
clearTimeout(timer);
});
@@ -29,7 +29,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 +50,7 @@ function getall() {
setImmediate(getall);
}
-for (var i = 0; i < 10; i++)
+for (let i = 0; i < 10; i++)
getall();
function afterGC() {
diff --git a/test/inspector/inspector-helper.js b/test/inspector/inspector-helper.js
index 3e517123fe27f9..e22ca87dff7858 100644
--- a/test/inspector/inspector-helper.js
+++ b/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(() => {
diff --git a/test/internet/test-dgram-multicast-multi-process.js b/test/internet/test-dgram-multicast-multi-process.js
index 36b429d6cf3f68..13141a9d44fb04 100644
--- a/test/internet/test-dgram-multicast-multi-process.js
+++ b/test/internet/test-dgram-multicast-multi-process.js
@@ -13,7 +13,7 @@ const messages = [
];
const workers = {};
const listeners = 3;
-
+let dead, listening, sendSocket, done, timer;
// Skip test in FreeBSD jails.
if (common.inFreeBSDJail) {
@@ -76,10 +76,10 @@ function launchChildProcess() {
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 +110,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 +127,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() {
diff --git a/test/internet/test-dgram-send-cb-quelches-error.js b/test/internet/test-dgram-send-cb-quelches-error.js
index 56612edead4fd2..abcc36859b96d9 100644
--- a/test/internet/test-dgram-send-cb-quelches-error.js
+++ b/test/internet/test-dgram-send-cb-quelches-error.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var mustCall = common.mustCall;
-var assert = require('assert');
-var dgram = require('dgram');
-var dns = require('dns');
+const common = require('../common');
+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([]);
diff --git a/test/internet/test-dns-cares-domains.js b/test/internet/test-dns-cares-domains.js
index 76ebf0d628b1c4..5328d7e3d97925 100644
--- a/test/internet/test-dns-cares-domains.js
+++ b/test/internet/test-dns-cares-domains.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
-var dns = require('dns');
-var domain = require('domain');
+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');
diff --git a/test/internet/test-dns-txt-sigsegv.js b/test/internet/test-dns-txt-sigsegv.js
index 4c2f12f7a97c28..3c85d546cfcddd 100644
--- a/test/internet/test-dns-txt-sigsegv.js
+++ b/test/internet/test-dns-txt-sigsegv.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var dns = require('dns');
+const assert = require('assert');
+const dns = require('dns');
dns.resolveTxt('www.microsoft.com', function(err, records) {
assert.equal(err, null);
diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js
index 893992e66096db..6fc939ee3a3b6c 100644
--- a/test/internet/test-dns.js
+++ b/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() {
@@ -62,13 +62,13 @@ TEST(function test_reverse_bogus(done) {
TEST(function test_resolveMx(done) {
- var req = dns.resolveMx('gmail.com', function(err, result) {
+ const req = dns.resolveMx('gmail.com', function(err, result) {
if (err) throw 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');
@@ -85,7 +85,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');
@@ -98,13 +98,13 @@ 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) {
if (err) throw 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');
}
@@ -116,7 +116,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');
@@ -129,13 +129,13 @@ 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) {
if (err) throw 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');
@@ -154,7 +154,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');
@@ -167,13 +167,13 @@ 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) {
if (err) throw 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');
}
@@ -185,7 +185,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');
@@ -198,13 +198,13 @@ 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) {
if (err) throw 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');
@@ -223,7 +223,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');
@@ -236,7 +236,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) {
if (err) throw err;
assert.ok(result);
@@ -270,7 +270,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');
@@ -283,13 +283,13 @@ 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) {
if (err) throw 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');
}
@@ -301,7 +301,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');
@@ -315,7 +315,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) {
if (err) throw err;
assert.strictEqual(records.length, 1);
assert.ok(util.isArray(records[0]));
@@ -327,7 +327,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');
@@ -341,7 +341,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');
@@ -356,7 +356,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) {
if (err) throw err;
assert.strictEqual(ip, null);
assert.strictEqual(family, 4);
@@ -369,7 +369,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) {
if (err) throw err;
assert.ok(Array.isArray(ips));
assert.ok(ips.length > 0);
@@ -384,7 +384,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) {
if (err) throw err;
assert.ok(Array.isArray(ips));
assert.strictEqual(ips.length, 0);
@@ -397,7 +397,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) {
if (err) throw err;
assert.ok(Array.isArray(ips));
assert.ok(ips.length > 0);
@@ -419,7 +419,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));
@@ -432,7 +432,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');
@@ -446,7 +446,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');
@@ -460,7 +460,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) {
@@ -482,12 +482,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) {
diff --git a/test/internet/test-http-https-default-ports.js b/test/internet/test-http-https-default-ports.js
index 8b00e434e9cba6..c7e6b3baf7ccdc 100644
--- a/test/internet/test-http-https-default-ports.js
+++ b/test/internet/test-http-https-default-ports.js
@@ -1,13 +1,13 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var http = require('http');
+const http = require('http');
https.get('https://www.google.com/', common.mustCall(function(res) {
res.resume();
diff --git a/test/internet/test-net-connect-timeout.js b/test/internet/test-net-connect-timeout.js
index 0f58622aa19912..95e25614ffa2b7 100644
--- a/test/internet/test-net-connect-timeout.js
+++ b/test/internet/test-net-connect-timeout.js
@@ -4,24 +4,24 @@
// https://groups.google.com/forum/#!topic/nodejs-dev/jR7-5UDqXkw
const common = require('../common');
-var net = require('net');
-var assert = require('assert');
+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();
}));
diff --git a/test/internet/test-net-connect-unref.js b/test/internet/test-net-connect-unref.js
index 52929d2152774d..f3be8409844702 100644
--- a/test/internet/test-net-connect-unref.js
+++ b/test/internet/test-net-connect-unref.js
@@ -1,11 +1,10 @@
'use strict';
const common = require('../common');
-var net = require('net');
+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();
});
diff --git a/test/internet/test-tls-connnect-melissadata.js b/test/internet/test-tls-connnect-melissadata.js
index 7ab7f2aa7a7895..f57b897099fc2d 100644
--- a/test/internet/test-tls-connnect-melissadata.js
+++ b/test/internet/test-tls-connnect-melissadata.js
@@ -2,14 +2,14 @@
// Test for authorized access to the server which has a cross root
// certification between Starfield Class 2 and ValiCert Class 2
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
-var socket = tls.connect(443, 'address.melissadata.net', function() {
+const tls = require('tls');
+const socket = tls.connect(443, 'address.melissadata.net', function() {
socket.resume();
socket.destroy();
});
diff --git a/test/known_issues/test-url-parse-conformance.js b/test/known_issues/test-url-parse-conformance.js
index d70a322d6b7455..f7fcec821c8e50 100644
--- a/test/known_issues/test-url-parse-conformance.js
+++ b/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);
diff --git a/test/message/error_exit.js b/test/message/error_exit.js
index 18d9dfb4ee998c..7235801514dd45 100644
--- a/test/message/error_exit.js
+++ b/test/message/error_exit.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
process.on('exit', function(code) {
console.error('Exiting with code=%d', code);
diff --git a/test/message/eval_messages.js b/test/message/eval_messages.js
index bb1569601c889f..d50df9081b2d25 100644
--- a/test/message/eval_messages.js
+++ b/test/message/eval_messages.js
@@ -2,19 +2,19 @@
require('../common');
-var spawn = require('child_process').spawn;
+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);
diff --git a/test/message/max_tick_depth.js b/test/message/max_tick_depth.js
index 1d2ec175c5d957..c433c0bab3f100 100644
--- a/test/message/max_tick_depth.js
+++ b/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)
diff --git a/test/message/stdin_messages.js b/test/message/stdin_messages.js
index 6e1ced4124f2a6..b32004c329dead 100644
--- a/test/message/stdin_messages.js
+++ b/test/message/stdin_messages.js
@@ -2,20 +2,20 @@
require('../common');
-var spawn = require('child_process').spawn;
+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);
diff --git a/test/message/undefined_reference_in_new_context.js b/test/message/undefined_reference_in_new_context.js
index 73821ae53d4f5f..77c5e1e29111b9 100644
--- a/test/message/undefined_reference_in_new_context.js
+++ b/test/message/undefined_reference_in_new_context.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var vm = require('vm');
+const vm = require('vm');
console.error('before');
diff --git a/test/message/vm_display_runtime_error.js b/test/message/vm_display_runtime_error.js
index a7ca9907444181..861e87f2f2bb93 100644
--- a/test/message/vm_display_runtime_error.js
+++ b/test/message/vm_display_runtime_error.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var vm = require('vm');
+const vm = require('vm');
console.error('beginning');
diff --git a/test/message/vm_display_syntax_error.js b/test/message/vm_display_syntax_error.js
index 62bbd432a2f98a..02612fb92d9a22 100644
--- a/test/message/vm_display_syntax_error.js
+++ b/test/message/vm_display_syntax_error.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var vm = require('vm');
+const vm = require('vm');
console.error('beginning');
diff --git a/test/message/vm_dont_display_runtime_error.js b/test/message/vm_dont_display_runtime_error.js
index 19d0120a90abfd..6a96243a83cf4a 100644
--- a/test/message/vm_dont_display_runtime_error.js
+++ b/test/message/vm_dont_display_runtime_error.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var vm = require('vm');
+const vm = require('vm');
console.error('beginning');
diff --git a/test/message/vm_dont_display_syntax_error.js b/test/message/vm_dont_display_syntax_error.js
index bff0433a144b09..76c3043330946d 100644
--- a/test/message/vm_dont_display_syntax_error.js
+++ b/test/message/vm_dont_display_syntax_error.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var vm = require('vm');
+const vm = require('vm');
console.error('beginning');
diff --git a/test/parallel/test-assert-typedarray-deepequal.js b/test/parallel/test-assert-typedarray-deepequal.js
index 2e6c88848a809f..f5ecb274a86a32 100644
--- a/test/parallel/test-assert-typedarray-deepequal.js
+++ b/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);
};
diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js
index 003cbdcc90d4e7..44723ef45bb964 100644
--- a/test/parallel/test-assert.js
+++ b/test/parallel/test-assert.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
-var a = require('assert');
+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);
};
@@ -127,8 +127,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;
@@ -138,7 +138,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; }
};
@@ -156,8 +156,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));
@@ -289,8 +289,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);
@@ -307,7 +307,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));
@@ -348,7 +348,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) {
@@ -417,10 +417,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');
@@ -459,7 +460,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, []));
@@ -478,7 +479,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) {
@@ -543,7 +544,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);
diff --git a/test/parallel/test-async-wrap-check-providers.js b/test/parallel/test-async-wrap-check-providers.js
index a130e130e98a8e..f4b50df576fb6f 100644
--- a/test/parallel/test-async-wrap-check-providers.js
+++ b/test/parallel/test-async-wrap-check-providers.js
@@ -23,7 +23,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);
}
diff --git a/test/parallel/test-async-wrap-throw-from-callback.js b/test/parallel/test-async-wrap-throw-from-callback.js
index 93b5bee470ce3f..41e3e4efa2d607 100644
--- a/test/parallel/test-async-wrap-throw-from-callback.js
+++ b/test/parallel/test-async-wrap-throw-from-callback.js
@@ -8,8 +8,8 @@ const domain = require('domain');
const spawn = require('child_process').spawn;
const callbacks = [ 'init', 'pre', 'post' ];
const toCall = process.argv[2];
-var msgCalled = 0;
-var msgReceived = 0;
+let msgCalled = 0;
+let msgReceived = 0;
function init() {
if (toCall === 'init')
@@ -48,7 +48,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();
diff --git a/test/parallel/test-async-wrap-uid.js b/test/parallel/test-async-wrap-uid.js
index 19cb01cfa83c7a..f16388cfe766f0 100644
--- a/test/parallel/test-async-wrap-uid.js
+++ b/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(() => {});
});
diff --git a/test/parallel/test-beforeexit-event-exit.js b/test/parallel/test-beforeexit-event-exit.js
index 67676a7990041f..6878135ce4d6d3 100644
--- a/test/parallel/test-beforeexit-event-exit.js
+++ b/test/parallel/test-beforeexit-event-exit.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
process.on('beforeExit', function() {
assert(false, 'exit should not allow this to occur');
diff --git a/test/parallel/test-buffer-ascii.js b/test/parallel/test-buffer-ascii.js
index ea125283f23f93..cf5b529183cabf 100644
--- a/test/parallel/test-buffer-ascii.js
+++ b/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.
diff --git a/test/parallel/test-buffer-bytelength.js b/test/parallel/test-buffer-bytelength.js
index 58286e61b4899b..9bb3b759e0208f 100644
--- a/test/parallel/test-buffer-bytelength.js
+++ b/test/parallel/test-buffer-bytelength.js
@@ -20,37 +20,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
diff --git a/test/parallel/test-buffer-concat.js b/test/parallel/test-buffer-concat.js
index 800f1055aa6222..1016dd8103447d 100644
--- a/test/parallel/test-buffer-concat.js
+++ b/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);
diff --git a/test/parallel/test-buffer-copy.js b/test/parallel/test-buffer-copy.js
index 0fb37cc0b41cf7..1b10dadb5b709b 100644
--- a/test/parallel/test-buffer-copy.js
+++ b/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.
diff --git a/test/parallel/test-buffer-fill.js b/test/parallel/test-buffer-fill.js
index 8cfeeabe91eebe..06a9044bec3103 100644
--- a/test/parallel/test-buffer-fill.js
+++ b/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
diff --git a/test/parallel/test-buffer-includes.js b/test/parallel/test-buffer-includes.js
index 15e1eedeb54d15..9b0aef0ad7652d 100644
--- a/test/parallel/test-buffer-includes.js
+++ b/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];
diff --git a/test/parallel/test-buffer-indexof.js b/test/parallel/test-buffer-indexof.js
index d0379ec17162e9..5bb7424581bc6a 100644
--- a/test/parallel/test-buffer-indexof.js
+++ b/test/parallel/test-buffer-indexof.js
@@ -193,7 +193,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'));
@@ -228,7 +228,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));
@@ -238,15 +238,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);
@@ -262,17 +262,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.
@@ -309,10 +309,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));
}
}
@@ -327,12 +327,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'));
}
@@ -491,7 +491,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'));
@@ -542,16 +542,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:
diff --git a/test/parallel/test-buffer-inspect.js b/test/parallel/test-buffer-inspect.js
index 4fed249207611b..41e8197da6a38a 100644
--- a/test/parallel/test-buffer-inspect.js
+++ b/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 = '';
+let expected = '';
assert.strictEqual(util.inspect(b), expected);
assert.strictEqual(util.inspect(s), expected);
diff --git a/test/parallel/test-buffer-iterator.js b/test/parallel/test-buffer-iterator.js
index 7a25682ebc27d9..3120ff1d2ab457 100644
--- a/test/parallel/test-buffer-iterator.js
+++ b/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
diff --git a/test/parallel/test-buffer-swap.js b/test/parallel/test-buffer-swap.js
index f72b638f75a30b..bcb636edb1733f 100644
--- a/test/parallel/test-buffer-swap.js
+++ b/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();
diff --git a/test/parallel/test-buffer.js b/test/parallel/test-buffer.js
index ba564d758d9757..d07ccc3550aece 100644
--- a/test/parallel/test-buffer.js
+++ b/test/parallel/test-buffer.js
@@ -1,14 +1,14 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var Buffer = require('buffer').Buffer;
-var SlowBuffer = require('buffer').SlowBuffer;
+const Buffer = require('buffer').Buffer;
+const SlowBuffer = require('buffer').SlowBuffer;
// counter to ensure unique value is always copied
-var cntr = 0;
+let cntr = 0;
-var b = Buffer(1024); // safe constructor
+const b = Buffer(1024); // safe constructor
console.log('b.length == %d', b.length);
assert.strictEqual(1024, b.length);
@@ -24,15 +24,15 @@ for (let i = 0; i < 1024; i++) {
assert.strictEqual(i % 256, b[i]);
}
-var c = Buffer(512);
+const c = Buffer(512);
console.log('c.length == %d', c.length);
assert.strictEqual(512, c.length);
-var d = new Buffer([]);
+const d = new Buffer([]);
assert.strictEqual(0, d.length);
-var ui32 = new Uint32Array(4).fill(42);
-var e = Buffer(ui32);
+const ui32 = new Uint32Array(4).fill(42);
+const e = Buffer(ui32);
for (const [key, value] of e.entries()) {
assert.deepStrictEqual(value, ui32[key]);
}
@@ -179,7 +179,7 @@ Buffer(8).fill('');
}
// copy string longer than buffer length (failure will segfault)
-var bb = Buffer(10);
+const bb = Buffer(10);
bb.fill('hello crazy world');
@@ -214,7 +214,7 @@ assert.equal(b.copy(c, 0, 100, 10), 0);
// when targetStart > targetLength, zero copied
assert.equal(b.copy(c, 512, 0, 10), 0);
-var caught_error;
+let caught_error;
// invalid encoding for Buffer.toString
caught_error = null;
@@ -352,7 +352,7 @@ assert.equal(rangeBuffer.toString({toString: function() {
}}), 'abc');
// testing for smart defaults and ability to pass string values as offset
-var writeTest = new Buffer('abcdes');
+const writeTest = new Buffer('abcdes');
writeTest.write('n', 'ascii');
writeTest.write('o', '1', 'ascii');
writeTest.write('d', '2', 'ascii');
@@ -394,20 +394,20 @@ assert.equal(writeTest.toString(), 'nodejs');
// UTF-8 slice test
-var utf8String = '¡hέlló wôrld!';
-var offset = 100;
+const utf8String = '¡hέlló wôrld!';
+const offset = 100;
b.write(utf8String, 0, Buffer.byteLength(utf8String), 'utf8');
-var utf8Slice = b.toString('utf8', 0, Buffer.byteLength(utf8String));
+let utf8Slice = b.toString('utf8', 0, Buffer.byteLength(utf8String));
assert.equal(utf8String, utf8Slice);
-var written = b.write(utf8String, offset, 'utf8');
+let written = b.write(utf8String, offset, 'utf8');
assert.equal(Buffer.byteLength(utf8String), written);
utf8Slice = b.toString('utf8', offset, offset + Buffer.byteLength(utf8String));
assert.equal(utf8String, utf8Slice);
-var sliceA = b.slice(offset, offset + Buffer.byteLength(utf8String));
-var sliceB = b.slice(offset, offset + Buffer.byteLength(utf8String));
+const sliceA = b.slice(offset, offset + Buffer.byteLength(utf8String));
+const sliceB = b.slice(offset, offset + Buffer.byteLength(utf8String));
for (let i = 0; i < Buffer.byteLength(utf8String); i++) {
assert.equal(sliceA[i], sliceB[i]);
}
@@ -514,10 +514,10 @@ for (let i = 0; i < Buffer.byteLength(utf8String); i++) {
}
-var arrayIsh = {0: 0, 1: 1, 2: 2, 3: 3, length: 4};
-var g = new Buffer(arrayIsh);
+const arrayIsh = {0: 0, 1: 1, 2: 2, 3: 3, length: 4};
+let g = new Buffer(arrayIsh);
assert.deepStrictEqual(g, new Buffer([0, 1, 2, 3]));
-var strArrayIsh = {0: '0', 1: '1', 2: '2', 3: '3', length: 4};
+const strArrayIsh = {0: '0', 1: '1', 2: '2', 3: '3', length: 4};
g = new Buffer(strArrayIsh);
assert.deepStrictEqual(g, new Buffer([0, 1, 2, 3]));
@@ -670,7 +670,7 @@ assert.equal(
);
// This string encodes single '.' character in UTF-16
-var dot = new Buffer('//4uAA==', 'base64');
+const dot = new Buffer('//4uAA==', 'base64');
assert.equal(dot[0], 0xff);
assert.equal(dot[1], 0xfe);
assert.equal(dot[2], 0x2e);
@@ -722,11 +722,11 @@ assert.equal(0, Buffer('hello').slice(0, 0).length);
// test hex toString
console.log('Create hex string from buffer');
-var hexb = new Buffer(256);
+const hexb = new Buffer(256);
for (let i = 0; i < 256; i++) {
hexb[i] = i;
}
-var hexStr = hexb.toString('hex');
+const hexStr = hexb.toString('hex');
assert.equal(hexStr,
'000102030405060708090a0b0c0d0e0f' +
'101112131415161718191a1b1c1d1e1f' +
@@ -746,7 +746,7 @@ assert.equal(hexStr,
'f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff');
console.log('Create buffer from hex string');
-var hexb2 = new Buffer(hexStr, 'hex');
+const hexb2 = new Buffer(hexStr, 'hex');
for (let i = 0; i < 256; i++) {
assert.equal(hexb2[i], hexb[i]);
}
@@ -773,7 +773,7 @@ assert.strictEqual(Buffer.from('A', 'base64').length, 0);
function buildBuffer(data) {
if (Array.isArray(data)) {
- var buffer = Buffer(data.length);
+ const buffer = Buffer(data.length);
data.forEach(function(v, k) {
buffer[k] = v;
});
@@ -782,7 +782,7 @@ function buildBuffer(data) {
return null;
}
-var x = buildBuffer([0x81, 0xa3, 0x66, 0x6f, 0x6f, 0xa3, 0x62, 0x61, 0x72]);
+const x = buildBuffer([0x81, 0xa3, 0x66, 0x6f, 0x6f, 0xa3, 0x62, 0x61, 0x72]);
console.log(x.inspect());
assert.equal('', x.inspect());
@@ -991,7 +991,7 @@ assert.equal(0, Buffer('hello').slice(0, 0).length);
{
// test for buffer overrun
const buf = new Buffer([0, 0, 0, 0, 0]); // length: 5
- var sub = buf.slice(0, 4); // length: 4
+ const sub = buf.slice(0, 4); // length: 4
written = sub.write('12345', 'latin1');
assert.equal(written, 4);
assert.equal(buf[4], 0);
@@ -1087,55 +1087,55 @@ assert.throws(function() {
// issue GH-5587
assert.throws(function() {
- var buf = new Buffer(8);
+ const buf = new Buffer(8);
buf.writeFloatLE(0, 5);
}, RangeError);
assert.throws(function() {
- var buf = new Buffer(16);
+ const buf = new Buffer(16);
buf.writeDoubleLE(0, 9);
}, RangeError);
// attempt to overflow buffers, similar to previous bug in array buffers
assert.throws(function() {
- var buf = Buffer(8);
+ const buf = Buffer(8);
buf.readFloatLE(0xffffffff);
}, RangeError);
assert.throws(function() {
- var buf = Buffer(8);
+ const buf = Buffer(8);
buf.writeFloatLE(0.0, 0xffffffff);
}, RangeError);
assert.throws(function() {
- var buf = Buffer(8);
+ const buf = Buffer(8);
buf.readFloatLE(0xffffffff);
}, RangeError);
assert.throws(function() {
- var buf = Buffer(8);
+ const buf = Buffer(8);
buf.writeFloatLE(0.0, 0xffffffff);
}, RangeError);
// ensure negative values can't get past offset
assert.throws(function() {
- var buf = Buffer(8);
+ const buf = Buffer(8);
buf.readFloatLE(-1);
}, RangeError);
assert.throws(function() {
- var buf = Buffer(8);
+ const buf = Buffer(8);
buf.writeFloatLE(0.0, -1);
}, RangeError);
assert.throws(function() {
- var buf = Buffer(8);
+ const buf = Buffer(8);
buf.readFloatLE(-1);
}, RangeError);
assert.throws(function() {
- var buf = Buffer(8);
+ const buf = Buffer(8);
buf.writeFloatLE(0.0, -1);
}, RangeError);
@@ -1155,7 +1155,7 @@ assert.throws(function() {
}
[16, 32].forEach(function(bits) {
- var buf = new Buffer(bits / 8 - 1);
+ const buf = new Buffer(bits / 8 - 1);
assert.throws(function() { buf['readUInt' + bits + 'BE'](0); },
RangeError,
@@ -1175,7 +1175,7 @@ assert.throws(function() {
});
[16, 32].forEach(function(bits) {
- var buf = new Buffer([0xFF, 0xFF, 0xFF, 0xFF]);
+ const buf = new Buffer([0xFF, 0xFF, 0xFF, 0xFF]);
assert.equal(buf['readUInt' + bits + 'BE'](0),
(0xFFFFFFFF >>> (32 - bits)));
@@ -1389,10 +1389,10 @@ assert.throws(function() {
if (common.hasCrypto) {
// Test truncation after decode
- var crypto = require('crypto');
+ const crypto = require('crypto');
- var b1 = new Buffer('YW55=======', 'base64');
- var b2 = new Buffer('YW55', 'base64');
+ const b1 = new Buffer('YW55=======', 'base64');
+ const b2 = new Buffer('YW55', 'base64');
assert.equal(
crypto.createHash('sha1').update(b1).digest('hex'),
@@ -1426,17 +1426,17 @@ if (common.hasCrypto) {
}
assert.throws(function() {
- var b = Buffer(1);
+ const b = Buffer(1);
Buffer.compare(b, 'abc');
});
assert.throws(function() {
- var b = Buffer(1);
+ const b = Buffer(1);
Buffer.compare('abc', b);
});
assert.throws(function() {
- var b = Buffer(1);
+ const b = Buffer(1);
b.compare('abc');
});
@@ -1454,14 +1454,14 @@ assert.throws(function() {
}
assert.throws(function() {
- var b = Buffer(1);
+ const b = Buffer(1);
b.equals('abc');
});
// Regression test for https://github.com/nodejs/node/issues/649.
assert.throws(function() { Buffer(1422561062959).toString('utf8'); });
-var ps = Buffer.poolSize;
+const ps = Buffer.poolSize;
Buffer.poolSize = 0;
assert.equal(Buffer(1).parent, undefined);
Buffer.poolSize = ps;
diff --git a/test/parallel/test-child-process-constructor.js b/test/parallel/test-child-process-constructor.js
index 0abf1289f0737d..d33c7ae3acf626 100644
--- a/test/parallel/test-child-process-constructor.js
+++ b/test/parallel/test-child-process-constructor.js
@@ -1,13 +1,13 @@
'use strict';
require('../common');
-var assert = require('assert');
-var child_process = require('child_process');
-var ChildProcess = child_process.ChildProcess;
+const assert = require('assert');
+const child_process = require('child_process');
+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'],
diff --git a/test/parallel/test-child-process-default-options.js b/test/parallel/test-child-process-default-options.js
index 38a1b291b9967c..37e7ea7494670e 100644
--- a/test/parallel/test-child-process-default-options.js
+++ b/test/parallel/test-child-process-default-options.js
@@ -1,19 +1,19 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var spawn = require('child_process').spawn;
+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');
diff --git a/test/parallel/test-child-process-double-pipe.js b/test/parallel/test-child-process-double-pipe.js
index c5b7c093af8a4a..dac48a2db7212a 100644
--- a/test/parallel/test-child-process-double-pipe.js
+++ b/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) {
diff --git a/test/parallel/test-child-process-env.js b/test/parallel/test-child-process-env.js
index 2ebc653e9a067d..ad41f978e21768 100644
--- a/test/parallel/test-child-process-env.js
+++ b/test/parallel/test-child-process-env.js
@@ -1,17 +1,17 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var spawn = require('child_process').spawn;
+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');
diff --git a/test/parallel/test-child-process-exec-cwd.js b/test/parallel/test-child-process-exec-cwd.js
index 3b6e428a4aca65..95feb42314fc8d 100644
--- a/test/parallel/test-child-process-exec-cwd.js
+++ b/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%';
diff --git a/test/parallel/test-child-process-exec-stdout-stderr-data-string.js b/test/parallel/test-child-process-exec-stdout-stderr-data-string.js
index 8ab834c98f8d79..472d31f16ac920 100644
--- a/test/parallel/test-child-process-exec-stdout-stderr-data-string.js
+++ b/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) => {
diff --git a/test/parallel/test-child-process-exit-code.js b/test/parallel/test-child-process-exit-code.js
index 3a393f126fbe13..9596a202223993 100644
--- a/test/parallel/test-child-process-exit-code.js
+++ b/test/parallel/test-child-process-exit-code.js
@@ -1,20 +1,20 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
-var path = require('path');
+const common = require('../common');
+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);
diff --git a/test/parallel/test-child-process-fork-close.js b/test/parallel/test-child-process-fork-close.js
index d6e9675ba82012..d8b1aa0bf3267c 100644
--- a/test/parallel/test-child-process-fork-close.js
+++ b/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;
diff --git a/test/parallel/test-child-process-fork-dgram.js b/test/parallel/test-child-process-fork-dgram.js
index 8bdf006a743e0d..7b9f0b8e23fbf4 100644
--- a/test/parallel/test-child-process-fork-dgram.js
+++ b/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;
diff --git a/test/parallel/test-child-process-fork-exec-argv.js b/test/parallel/test-child-process-fork-exec-argv.js
index 5ccc17fb3fc7c4..97d1e21a2f6d7a 100644
--- a/test/parallel/test-child-process-fork-exec-argv.js
+++ b/test/parallel/test-child-process-fork-exec-argv.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
-var child_process = require('child_process');
-var spawn = child_process.spawn;
-var fork = child_process.fork;
+const assert = require('assert');
+const child_process = require('child_process');
+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;
diff --git a/test/parallel/test-child-process-fork-exec-path.js b/test/parallel/test-child-process-fork-exec-path.js
index e2f7e4b4d20eef..5af0184a21f55d 100644
--- a/test/parallel/test-child-process-fork-exec-path.js
+++ b/test/parallel/test-child-process-fork-exec-path.js
@@ -1,11 +1,11 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
-var path = require('path');
-var msg = {test: 'this'};
-var nodePath = process.execPath;
-var copyPath = path.join(common.tmpDir, 'node-copy.exe');
+const assert = require('assert');
+const fs = require('fs');
+const path = require('path');
+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,9 +23,9 @@ 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';
- var child = require('child_process').fork(__filename, {
+ const child = require('child_process').fork(__filename, {
execPath: copyPath,
env: envCopy
});
diff --git a/test/parallel/test-child-process-fork-net.js b/test/parallel/test-child-process-fork-net.js
index cbafcb13fbb068..063028e8280582 100644
--- a/test/parallel/test-child-process-fork-net.js
+++ b/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();
+ let 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);
diff --git a/test/parallel/test-child-process-fork-net2.js b/test/parallel/test-child-process-fork-net2.js
index be1ee5d3a4145a..760645932069bb 100644
--- a/test/parallel/test-child-process-fork-net2.js
+++ b/test/parallel/test-child-process-fork-net2.js
@@ -1,13 +1,13 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var fork = require('child_process').fork;
-var net = require('net');
-var count = 12;
+const assert = require('assert');
+const fork = require('child_process').fork;
+const net = require('net');
+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() {
+ let closeServer = function() {
server.close();
setTimeout(function() {
diff --git a/test/parallel/test-child-process-fork-ref.js b/test/parallel/test-child-process-fork-ref.js
index 50a944e71ba83c..1f8816c0cfaf1c 100644
--- a/test/parallel/test-child-process-fork-ref.js
+++ b/test/parallel/test-child-process-fork-ref.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var fork = require('child_process').fork;
+const assert = require('assert');
+const fork = require('child_process').fork;
if (process.argv[2] === 'child') {
process.send('1');
@@ -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);
diff --git a/test/parallel/test-child-process-fork-ref2.js b/test/parallel/test-child-process-fork-ref2.js
index 42c43ed8882b78..9f59aa344aa2c9 100644
--- a/test/parallel/test-child-process-fork-ref2.js
+++ b/test/parallel/test-child-process-fork-ref2.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var fork = require('child_process').fork;
+const fork = require('child_process').fork;
if (process.argv[2] === 'child') {
console.log('child -> call disconnect');
@@ -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');
diff --git a/test/parallel/test-child-process-fork-regr-gh-2847.js b/test/parallel/test-child-process-fork-regr-gh-2847.js
index 7b4c262fbdcf61..fe95e8dbb5b4ac 100644
--- a/test/parallel/test-child-process-fork-regr-gh-2847.js
+++ b/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);
});
diff --git a/test/parallel/test-child-process-fork.js b/test/parallel/test-child-process-fork.js
index 5ae231ef0357ac..36864cbd663ce0 100644
--- a/test/parallel/test-child-process-fork.js
+++ b/test/parallel/test-child-process-fork.js
@@ -1,10 +1,10 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var fork = require('child_process').fork;
-var args = ['foo', 'bar'];
+const assert = require('assert');
+const fork = require('child_process').fork;
+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.deepStrictEqual(args, ['foo', 'bar']);
n.on('message', function(m) {
diff --git a/test/parallel/test-child-process-fork3.js b/test/parallel/test-child-process-fork3.js
index fe0e68b6a6436e..5588c41422e21b 100644
--- a/test/parallel/test-child-process-fork3.js
+++ b/test/parallel/test-child-process-fork3.js
@@ -1,5 +1,5 @@
'use strict';
-var common = require('../common');
-var child_process = require('child_process');
+const common = require('../common');
+const child_process = require('child_process');
child_process.fork(common.fixturesDir + '/empty.js'); // should not hang
diff --git a/test/parallel/test-child-process-internal.js b/test/parallel/test-child-process-internal.js
index f3e452ef87ea76..d795b69d7ee0e5 100644
--- a/test/parallel/test-child-process-internal.js
+++ b/test/parallel/test-child-process-internal.js
@@ -1,11 +1,11 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+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
@@ -18,8 +18,8 @@ if (process.argv[2] === 'child') {
} else {
- var fork = require('child_process').fork;
- var child = fork(process.argv[1], ['child']);
+ const fork = require('child_process').fork;
+ const child = fork(process.argv[1], ['child']);
child.once('message', common.mustCall(function(data) {
assert.deepStrictEqual(data, normal);
diff --git a/test/parallel/test-child-process-send-returns-boolean.js b/test/parallel/test-child-process-send-returns-boolean.js
index 941a2da645f958..460c2b0022fc6b 100644
--- a/test/parallel/test-child-process-send-returns-boolean.js
+++ b/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();
});
diff --git a/test/parallel/test-child-process-set-blocking.js b/test/parallel/test-child-process-set-blocking.js
index fb0b11f433130a..54037aea69feb2 100644
--- a/test/parallel/test-child-process-set-blocking.js
+++ b/test/parallel/test-child-process-set-blocking.js
@@ -1,11 +1,11 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var ch = require('child_process');
+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'
});
diff --git a/test/parallel/test-child-process-silent.js b/test/parallel/test-child-process-silent.js
index ce5e28cc320af4..562b34ad823e17 100644
--- a/test/parallel/test-child-process-silent.js
+++ b/test/parallel/test-child-process-silent.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var childProcess = require('child_process');
+const assert = require('assert');
+const childProcess = require('child_process');
// Child pipe test
if (process.argv[2] === 'pipe') {
@@ -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');
diff --git a/test/parallel/test-child-process-spawn-typeerror.js b/test/parallel/test-child-process-spawn-typeerror.js
index b6eac63c4eb048..3e3e38153de35c 100644
--- a/test/parallel/test-child-process-spawn-typeerror.js
+++ b/test/parallel/test-child-process-spawn-typeerror.js
@@ -12,7 +12,7 @@ const invalidOptionsMsg = /"options" argument must be an object/;
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);
diff --git a/test/parallel/test-child-process-spawnsync-env.js b/test/parallel/test-child-process-spawnsync-env.js
index 4455b867e30108..6f5ea3dc83d107 100644
--- a/test/parallel/test-child-process-spawnsync-env.js
+++ b/test/parallel/test-child-process-spawnsync-env.js
@@ -1,13 +1,13 @@
'use strict';
require('../common');
-var assert = require('assert');
-var cp = require('child_process');
+const assert = require('assert');
+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 })
});
diff --git a/test/parallel/test-child-process-spawnsync-input.js b/test/parallel/test-child-process-spawnsync-input.js
index fdd29aa7d0cc50..1bda3d5dcf9da2 100644
--- a/test/parallel/test-child-process-spawnsync-input.js
+++ b/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
};
diff --git a/test/parallel/test-child-process-spawnsync-timeout.js b/test/parallel/test-child-process-spawnsync-timeout.js
index c804f7502755bb..38f22deef26ae7 100644
--- a/test/parallel/test-child-process-spawnsync-timeout.js
+++ b/test/parallel/test-child-process-spawnsync-timeout.js
@@ -2,7 +2,7 @@
const common = require('../common');
const assert = require('assert');
-var spawnSync = require('child_process').spawnSync;
+const spawnSync = require('child_process').spawnSync;
const TIMER = 200;
const SLEEP = common.platformTimeout(5000);
@@ -15,8 +15,8 @@ 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');
const end = Date.now() - start;
diff --git a/test/parallel/test-child-process-stdin-ipc.js b/test/parallel/test-child-process-stdin-ipc.js
index 2ce7c66c2053e0..2623e2deeeee8a 100644
--- a/test/parallel/test-child-process-stdin-ipc.js
+++ b/test/parallel/test-child-process-stdin-ipc.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var spawn = require('child_process').spawn;
+const spawn = require('child_process').spawn;
if (process.argv[2] === 'child') {
// Just reference stdin, it should start it
@@ -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']
});
diff --git a/test/parallel/test-child-process-stdio-big-write-end.js b/test/parallel/test-child-process-stdio-big-write-end.js
index 4c9f4159d0d8bc..24991492f63d32 100644
--- a/test/parallel/test-child-process-stdio-big-write-end.js
+++ b/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));
diff --git a/test/parallel/test-child-process-stdio-inherit.js b/test/parallel/test-child-process-stdio-inherit.js
index dc3bb3e9aa9391..d2b64aeb30dd31 100644
--- a/test/parallel/test-child-process-stdio-inherit.js
+++ b/test/parallel/test-child-process-stdio-inherit.js
@@ -1,7 +1,7 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
+const common = require('../common');
+const assert = require('assert');
+const spawn = require('child_process').spawn;
if (process.argv[2] === 'parent')
parent();
@@ -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;
diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js
index 8db7ad30872223..9a1714cb6ea7c2 100644
--- a/test/parallel/test-cli-eval.js
+++ b/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) {
diff --git a/test/parallel/test-cli-syntax.js b/test/parallel/test-cli-syntax.js
index 839e50d7d94b40..d7781eddffbb42 100644
--- a/test/parallel/test-cli-syntax.js
+++ b/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);
diff --git a/test/parallel/test-cluster-basic.js b/test/parallel/test-cluster-basic.js
index 0ffdcf180bd8a8..89413c154ef937 100644
--- a/test/parallel/test-cluster-basic.js
+++ b/test/parallel/test-cluster-basic.js
@@ -56,7 +56,7 @@ if (cluster.isWorker) {
}
};
- var worker;
+ let worker;
const stateNames = Object.keys(checks.worker.states);
//Check events, states, and emit arguments
@@ -72,7 +72,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);
}));
});
diff --git a/test/parallel/test-cluster-bind-privileged-port.js b/test/parallel/test-cluster-bind-privileged-port.js
index 228e1f0f1eaab0..3e062697fd2fea 100644
--- a/test/parallel/test-cluster-bind-privileged-port.js
+++ b/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');
diff --git a/test/parallel/test-cluster-dgram-1.js b/test/parallel/test-cluster-dgram-1.js
index 3b27fa8e20cb6c..25391997755f6b 100644
--- a/test/parallel/test-cluster-dgram-1.js
+++ b/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++;
diff --git a/test/parallel/test-cluster-dgram-2.js b/test/parallel/test-cluster-dgram-2.js
index 863e0fa358c73e..37aea29e1a4263 100644
--- a/test/parallel/test-cluster-dgram-2.js
+++ b/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();
}
diff --git a/test/parallel/test-cluster-dgram-reuse.js b/test/parallel/test-cluster-dgram-reuse.js
index 27fc1be985d4b7..aed565a3806e97 100644
--- a/test/parallel/test-cluster-dgram-reuse.js
+++ b/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);
diff --git a/test/parallel/test-cluster-disconnect-race.js b/test/parallel/test-cluster-disconnect-race.js
index e89b9e134fa83f..09966cbab84496 100644
--- a/test/parallel/test-cluster-disconnect-race.js
+++ b/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');
diff --git a/test/parallel/test-cluster-disconnect-suicide-race.js b/test/parallel/test-cluster-disconnect-suicide-race.js
index 6f23b23fd2d4ff..15d07002252ee9 100644
--- a/test/parallel/test-cluster-disconnect-suicide-race.js
+++ b/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();
diff --git a/test/parallel/test-cluster-disconnect-with-no-workers.js b/test/parallel/test-cluster-disconnect-with-no-workers.js
index 4c2425d82d656b..15c5898a7d6f69 100644
--- a/test/parallel/test-cluster-disconnect-with-no-workers.js
+++ b/test/parallel/test-cluster-disconnect-with-no-workers.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
+const assert = require('assert');
+const cluster = require('cluster');
-var disconnected;
+let disconnected;
process.on('exit', function() {
assert(disconnected);
diff --git a/test/parallel/test-cluster-disconnect.js b/test/parallel/test-cluster-disconnect.js
index 4609724130f2ec..0fc1611e2d9577 100644
--- a/test/parallel/test-cluster-disconnect.js
+++ b/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) {
diff --git a/test/parallel/test-cluster-eaccess.js b/test/parallel/test-cluster-eaccess.js
index 2de4af8b1a108b..75b60248a22381 100644
--- a/test/parallel/test-cluster-eaccess.js
+++ b/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
diff --git a/test/parallel/test-cluster-eaddrinuse.js b/test/parallel/test-cluster-eaddrinuse.js
index 88b6de2dde4230..a0936ef4b9d471 100644
--- a/test/parallel/test-cluster-eaddrinuse.js
+++ b/test/parallel/test-cluster-eaddrinuse.js
@@ -3,17 +3,17 @@
// leave the master process in a confused state. Releasing the port and
// trying again should Just Work[TM].
-var common = require('../common');
-var assert = require('assert');
-var fork = require('child_process').fork;
-var net = require('net');
+const common = require('../common');
+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() {
diff --git a/test/parallel/test-cluster-fork-env.js b/test/parallel/test-cluster-fork-env.js
index 17b7af3d061926..55ea684f3b4ce3 100644
--- a/test/parallel/test-cluster-fork-env.js
+++ b/test/parallel/test-cluster-fork-env.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
+const assert = require('assert');
+const cluster = require('cluster');
if (cluster.isWorker) {
const result = cluster.worker.send({
@@ -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'
});
diff --git a/test/parallel/test-cluster-listening-port.js b/test/parallel/test-cluster-listening-port.js
index b0fbf9499041d2..ce86205c1e792a 100644
--- a/test/parallel/test-cluster-listening-port.js
+++ b/test/parallel/test-cluster-listening-port.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const cluster = require('cluster');
+const net = require('net');
if (cluster.isMaster) {
cluster.fork();
diff --git a/test/parallel/test-cluster-master-error.js b/test/parallel/test-cluster-master-error.js
index 6f9c78a7ba601f..11ed09c64ed04e 100644
--- a/test/parallel/test-cluster-master-error.js
+++ b/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);
diff --git a/test/parallel/test-cluster-master-kill.js b/test/parallel/test-cluster-master-kill.js
index 44eedec47b58e5..094e5ad256de7d 100644
--- a/test/parallel/test-cluster-master-kill.js
+++ b/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
diff --git a/test/parallel/test-cluster-message.js b/test/parallel/test-cluster-message.js
index 0587eecb4dd4b5..5b537bbe73a755 100644
--- a/test/parallel/test-cluster-message.js
+++ b/test/parallel/test-cluster-message.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const cluster = require('cluster');
+const net = require('net');
function forEach(obj, fn) {
Object.keys(obj).forEach(function(name, index) {
@@ -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) {
diff --git a/test/parallel/test-cluster-rr-domain-listen.js b/test/parallel/test-cluster-rr-domain-listen.js
index 1328483abb72df..ee507cd47b2a23 100644
--- a/test/parallel/test-cluster-rr-domain-listen.js
+++ b/test/parallel/test-cluster-rr-domain-listen.js
@@ -1,20 +1,20 @@
'use strict';
-var common = require('../common');
-var cluster = require('cluster');
-var domain = require('domain');
+const common = require('../common');
+const cluster = require('cluster');
+const domain = require('domain');
// RR is the default for v0.11.9+ so the following line is redundant:
// cluster.schedulingPolicy = cluster.SCHED_RR;
if (cluster.isWorker) {
- var d = domain.create();
+ const d = domain.create();
d.run(function() { });
- var http = require('http');
+ const http = require('http');
http.Server(function() { }).listen(common.PORT, '127.0.0.1');
} else if (cluster.isMaster) {
- var worker;
+ let worker;
//Kill worker when listening
cluster.on('listening', function() {
diff --git a/test/parallel/test-cluster-send-deadlock.js b/test/parallel/test-cluster-send-deadlock.js
index fa3e1138248221..d9eac63a92f84c 100644
--- a/test/parallel/test-cluster-send-deadlock.js
+++ b/test/parallel/test-cluster-send-deadlock.js
@@ -2,20 +2,20 @@
// Testing mutual send of handles: from master to worker, and from worker to
// master.
-var common = require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+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) {
+ let 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() {
diff --git a/test/parallel/test-cluster-setup-master-argv.js b/test/parallel/test-cluster-setup-master-argv.js
index 32c5a91b3caab4..72211918eff0cb 100644
--- a/test/parallel/test-cluster-setup-master-argv.js
+++ b/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]);
}));
diff --git a/test/parallel/test-cluster-setup-master-cumulative.js b/test/parallel/test-cluster-setup-master-cumulative.js
index 6a55df29d4411f..977c89a56aa573 100644
--- a/test/parallel/test-cluster-setup-master-cumulative.js
+++ b/test/parallel/test-cluster-setup-master-cumulative.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
+const assert = require('assert');
+const cluster = require('cluster');
assert(cluster.isMaster);
diff --git a/test/parallel/test-cluster-setup-master-emit.js b/test/parallel/test-cluster-setup-master-emit.js
index aad1cea75eda97..5b828e7b8e360f 100644
--- a/test/parallel/test-cluster-setup-master-emit.js
+++ b/test/parallel/test-cluster-setup-master-emit.js
@@ -1,7 +1,7 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
+const assert = require('assert');
+const cluster = require('cluster');
assert(cluster.isMaster);
diff --git a/test/parallel/test-cluster-setup-master-multiple.js b/test/parallel/test-cluster-setup-master-multiple.js
index 5ceff2bddfaf9d..25cff7cb33e0c1 100644
--- a/test/parallel/test-cluster-setup-master-multiple.js
+++ b/test/parallel/test-cluster-setup-master-multiple.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
+const assert = require('assert');
+const cluster = require('cluster');
assert(cluster.isMaster);
@@ -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',
diff --git a/test/parallel/test-cluster-setup-master.js b/test/parallel/test-cluster-setup-master.js
index 66193203fdc665..5a92b988e61e5e 100644
--- a/test/parallel/test-cluster-setup-master.js
+++ b/test/parallel/test-cluster-setup-master.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
+const assert = require('assert');
+const cluster = require('cluster');
if (cluster.isWorker) {
@@ -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);
});
diff --git a/test/parallel/test-cluster-shared-leak.js b/test/parallel/test-cluster-shared-leak.js
index ad13a869b2b8e0..d578ee6373f3b6 100644
--- a/test/parallel/test-cluster-shared-leak.js
+++ b/test/parallel/test-cluster-shared-leak.js
@@ -10,9 +10,9 @@ const cluster = require('cluster');
cluster.schedulingPolicy = cluster.SCHED_NONE;
if (cluster.isMaster) {
- var conn, worker1, worker2;
+ let conn, worker2;
- worker1 = cluster.fork();
+ const worker1 = cluster.fork();
worker1.on('message', common.mustCall(function() {
worker2 = cluster.fork();
worker2.on('online', function() {
diff --git a/test/parallel/test-cluster-worker-death.js b/test/parallel/test-cluster-worker-death.js
index ac32705106e03c..7a33721a9aba17 100644
--- a/test/parallel/test-cluster-worker-death.js
+++ b/test/parallel/test-cluster-worker-death.js
@@ -1,12 +1,12 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
+const assert = require('assert');
+const cluster = require('cluster');
if (!cluster.isMaster) {
process.exit(42);
} else {
- var worker = cluster.fork();
+ const worker = cluster.fork();
worker.on('exit', common.mustCall(function(exitCode, signalCode) {
assert.strictEqual(exitCode, 42);
assert.strictEqual(signalCode, null);
diff --git a/test/parallel/test-cluster-worker-destroy.js b/test/parallel/test-cluster-worker-destroy.js
index c802177530e4af..91091318afa1d3 100644
--- a/test/parallel/test-cluster-worker-destroy.js
+++ b/test/parallel/test-cluster-worker-destroy.js
@@ -8,8 +8,8 @@
*/
const common = require('../common');
-var cluster = require('cluster');
-var worker1, worker2;
+const cluster = require('cluster');
+let worker1, worker2;
if (cluster.isMaster) {
worker1 = cluster.fork();
diff --git a/test/parallel/test-cluster-worker-events.js b/test/parallel/test-cluster-worker-events.js
index 08bf456a735b7d..6c2e278f5e4639 100644
--- a/test/parallel/test-cluster-worker-events.js
+++ b/test/parallel/test-cluster-worker-events.js
@@ -1,13 +1,13 @@
'use strict';
require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
+const assert = require('assert');
+const cluster = require('cluster');
-var OK = 2;
+const OK = 2;
if (cluster.isMaster) {
- var worker = cluster.fork();
+ const worker = cluster.fork();
worker.on('exit', function(code) {
assert.strictEqual(code, OK);
@@ -25,8 +25,8 @@ if (cluster.isMaster) {
assert(cluster.isWorker);
-var sawProcess;
-var sawWorker;
+let sawProcess;
+let sawWorker;
process.on('message', function(m) {
assert(!sawProcess);
@@ -40,7 +40,7 @@ cluster.worker.on('message', function(m) {
check(m);
});
-var messages = [];
+const messages = [];
function check(m) {
messages.push(m);
diff --git a/test/parallel/test-cluster-worker-forced-exit.js b/test/parallel/test-cluster-worker-forced-exit.js
index 3e1f7905ee50d1..828188254724ae 100644
--- a/test/parallel/test-cluster-worker-forced-exit.js
+++ b/test/parallel/test-cluster-worker-forced-exit.js
@@ -1,9 +1,9 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
+const assert = require('assert');
+const cluster = require('cluster');
-var SENTINEL = 42;
+const SENTINEL = 42;
// workers forcibly exit when control channel is disconnected, if
// their .exitedAfterDisconnect flag isn't set
diff --git a/test/parallel/test-cluster-worker-isconnected.js b/test/parallel/test-cluster-worker-isconnected.js
index 985d15ce6475e6..8b2ad865899c60 100644
--- a/test/parallel/test-cluster-worker-isconnected.js
+++ b/test/parallel/test-cluster-worker-isconnected.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var cluster = require('cluster');
-var assert = require('assert');
+const cluster = require('cluster');
+const assert = require('assert');
if (cluster.isMaster) {
- var worker = cluster.fork();
+ const worker = cluster.fork();
assert.ok(worker.isConnected(),
'isConnected() should return true as soon as the worker has ' +
diff --git a/test/parallel/test-cluster-worker-isdead.js b/test/parallel/test-cluster-worker-isdead.js
index 90454cb86089a7..cd360ff248aa13 100644
--- a/test/parallel/test-cluster-worker-isdead.js
+++ b/test/parallel/test-cluster-worker-isdead.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var cluster = require('cluster');
-var assert = require('assert');
+const cluster = require('cluster');
+const assert = require('assert');
if (cluster.isMaster) {
- var worker = cluster.fork();
+ const worker = cluster.fork();
assert.ok(!worker.isDead(),
'isDead() should return false right after the worker has been ' +
'created.');
diff --git a/test/parallel/test-cluster-worker-no-exit.js b/test/parallel/test-cluster-worker-no-exit.js
index 0cec652b68648c..9cfd8401a0c678 100644
--- a/test/parallel/test-cluster-worker-no-exit.js
+++ b/test/parallel/test-cluster-worker-no-exit.js
@@ -1,13 +1,13 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
-var net = require('net');
+const assert = require('assert');
+const cluster = require('cluster');
+const net = require('net');
-var destroyed;
-var success;
-var worker;
-var server;
+let destroyed;
+let success;
+let worker;
+let server;
// workers do not exit on disconnect, they exit under normal node rules: when
// they have nothing keeping their loop alive, like an active connection
@@ -35,7 +35,7 @@ if (cluster.isMaster) {
});
}).listen(common.PORT, function() {
- var port = this.address().port;
+ const port = this.address().port;
worker = cluster.fork()
.on('online', function() {
diff --git a/test/parallel/test-cluster-worker-wait-server-close.js b/test/parallel/test-cluster-worker-wait-server-close.js
index bdf60971fee5c1..d1a0d73678d67a 100644
--- a/test/parallel/test-cluster-worker-wait-server-close.js
+++ b/test/parallel/test-cluster-worker-wait-server-close.js
@@ -1,14 +1,14 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const cluster = require('cluster');
+const net = require('net');
-var serverClosed = false;
+let serverClosed = false;
if (cluster.isWorker) {
- var server = net.createServer(function(socket) {
+ const server = net.createServer(function(socket) {
// Wait for any data, then close connection
socket.write('.');
socket.on('data', function discard() {});
@@ -20,7 +20,7 @@ if (cluster.isWorker) {
// Although not typical, the worker process can exit before the disconnect
// event fires. Use this to keep the process open until the event has fired.
- var keepOpen = setInterval(function() {}, 9999);
+ const keepOpen = setInterval(function() {}, 9999);
// Check worker events and properties
process.once('disconnect', function() {
@@ -30,7 +30,7 @@ if (cluster.isWorker) {
});
} else if (cluster.isMaster) {
// start worker
- var worker = cluster.fork();
+ const worker = cluster.fork();
// Disconnect worker when it is ready
worker.once('listening', function() {
diff --git a/test/parallel/test-common.js b/test/parallel/test-common.js
index 59485eec4a327f..17f41840e4ffa5 100644
--- a/test/parallel/test-common.js
+++ b/test/parallel/test-common.js
@@ -1,6 +1,6 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
common.globalCheck = false;
global.gc = 42; // Not a valid global unless --expose_gc is set.
diff --git a/test/parallel/test-console-instance.js b/test/parallel/test-console-instance.js
index ab5e5c9e6b3ce7..328adfde0ed803 100644
--- a/test/parallel/test-console-instance.js
+++ b/test/parallel/test-console-instance.js
@@ -29,7 +29,7 @@ assert.throws(() => {
out.write = err.write = (d) => {};
-var c = new Console(out, err);
+const c = new Console(out, err);
out.write = err.write = common.mustCall((d) => {
assert.strictEqual(d, 'test\n');
diff --git a/test/parallel/test-console-not-call-toString.js b/test/parallel/test-console-not-call-toString.js
index f152e33e98f087..0c1c209374ac17 100644
--- a/test/parallel/test-console-not-call-toString.js
+++ b/test/parallel/test-console-not-call-toString.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var func = function() {};
-var toStringCalled = false;
+const func = function() {};
+let toStringCalled = false;
func.toString = function() {
toStringCalled = true;
};
diff --git a/test/parallel/test-crypto-binary-default.js b/test/parallel/test-crypto-binary-default.js
index 33a0783fe99963..6ee3aeac36dd89 100644
--- a/test/parallel/test-crypto-binary-default.js
+++ b/test/parallel/test-crypto-binary-default.js
@@ -53,7 +53,7 @@ const hmacHash = crypto.createHmac('sha1', 'Node')
assert.strictEqual(hmacHash, '19fd6e1ba73d9ed2224dd5094a71babe85d9a892');
// Test HMAC-SHA-* (rfc 4231 Test Cases)
-var rfc4231 = [
+const rfc4231 = [
{
key: Buffer.from('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
data: Buffer.from('4869205468657265', 'hex'), // 'Hi There'
@@ -200,8 +200,8 @@ var rfc4231 = [
];
for (let i = 0, l = rfc4231.length; i < l; i++) {
- for (var hash in rfc4231[i]['hmac']) {
- var result = crypto.createHmac(hash, rfc4231[i]['key'])
+ for (const hash in rfc4231[i]['hmac']) {
+ let result = crypto.createHmac(hash, rfc4231[i]['key'])
.update(rfc4231[i]['data'])
.digest('hex');
if (rfc4231[i]['truncate']) {
@@ -216,7 +216,7 @@ for (let i = 0, l = rfc4231.length; i < l; i++) {
}
// Test HMAC-MD5/SHA1 (rfc 2202 Test Cases)
-var rfc2202_md5 = [
+const rfc2202_md5 = [
{
key: Buffer.from('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
data: 'Hi There',
@@ -269,7 +269,7 @@ var rfc2202_md5 = [
hmac: '6f630fad67cda0ee1fb1f562db3aa53e'
}
];
-var rfc2202_sha1 = [
+const rfc2202_sha1 = [
{
key: Buffer.from('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
data: 'Hi There',
@@ -346,13 +346,13 @@ for (let i = 0, l = rfc2202_sha1.length; i < l; i++) {
}
// Test hashing
-var a1 = crypto.createHash('sha1').update('Test123').digest('hex');
-var a2 = crypto.createHash('sha256').update('Test123').digest('base64');
-var a3 = crypto.createHash('sha512').update('Test123').digest(); // binary
-var a4 = crypto.createHash('sha1').update('Test123').digest('buffer');
+const a1 = crypto.createHash('sha1').update('Test123').digest('hex');
+const a2 = crypto.createHash('sha256').update('Test123').digest('base64');
+const a3 = crypto.createHash('sha512').update('Test123').digest(); // binary
+const a4 = crypto.createHash('sha1').update('Test123').digest('buffer');
if (!common.hasFipsCrypto) {
- var a0 = crypto.createHash('md5').update('Test123').digest('latin1');
+ const a0 = crypto.createHash('md5').update('Test123').digest('latin1');
assert.strictEqual(
a0,
'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c',
@@ -382,14 +382,14 @@ assert.deepStrictEqual(
);
// Test multiple updates to same hash
-var h1 = crypto.createHash('sha1').update('Test123').digest('hex');
-var h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex');
+const h1 = crypto.createHash('sha1').update('Test123').digest('hex');
+const h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex');
assert.strictEqual(h1, h2, 'multipled updates');
// Test hashing for binary files
-var fn = path.join(common.fixturesDir, 'sample.png');
-var sha1Hash = crypto.createHash('sha1');
-var fileStream = fs.createReadStream(fn);
+const fn = path.join(common.fixturesDir, 'sample.png');
+const sha1Hash = crypto.createHash('sha1');
+const fileStream = fs.createReadStream(fn);
fileStream.on('data', function(data) {
sha1Hash.update(data);
});
@@ -407,28 +407,28 @@ assert.throws(function() {
}, /^Error: Digest method not supported$/);
// Test signing and verifying
-var s1 = crypto.createSign('RSA-SHA1')
+const s1 = crypto.createSign('RSA-SHA1')
.update('Test123')
.sign(keyPem, 'base64');
-var s1Verified = crypto.createVerify('RSA-SHA1')
+const s1Verified = crypto.createVerify('RSA-SHA1')
.update('Test')
.update('123')
.verify(certPem, s1, 'base64');
assert.strictEqual(s1Verified, true, 'sign and verify (base 64)');
-var s2 = crypto.createSign('RSA-SHA256')
+const s2 = crypto.createSign('RSA-SHA256')
.update('Test123')
.sign(keyPem); // binary
-var s2Verified = crypto.createVerify('RSA-SHA256')
+const s2Verified = crypto.createVerify('RSA-SHA256')
.update('Test')
.update('123')
.verify(certPem, s2); // binary
assert.strictEqual(s2Verified, true, 'sign and verify (binary)');
-var s3 = crypto.createSign('RSA-SHA1')
+const s3 = crypto.createSign('RSA-SHA1')
.update('Test123')
.sign(keyPem, 'buffer');
-var s3Verified = crypto.createVerify('RSA-SHA1')
+const s3Verified = crypto.createVerify('RSA-SHA1')
.update('Test')
.update('123')
.verify(certPem, s3);
@@ -437,17 +437,17 @@ assert.strictEqual(s3Verified, true, 'sign and verify (buffer)');
function testCipher1(key) {
// Test encryption and decryption
- var plaintext = 'Keep this a secret? No! Tell everyone about node.js!';
- var cipher = crypto.createCipher('aes192', key);
+ const plaintext = 'Keep this a secret? No! Tell everyone about node.js!';
+ const cipher = crypto.createCipher('aes192', key);
// encrypt plaintext which is in utf8 format
// to a ciphertext which will be in hex
- var ciph = cipher.update(plaintext, 'utf8', 'hex');
+ let ciph = cipher.update(plaintext, 'utf8', 'hex');
// Only use binary or hex, not base64.
ciph += cipher.final('hex');
- var decipher = crypto.createDecipher('aes192', key);
- var txt = decipher.update(ciph, 'hex', 'utf8');
+ const decipher = crypto.createDecipher('aes192', key);
+ let txt = decipher.update(ciph, 'hex', 'utf8');
txt += decipher.final('utf8');
assert.strictEqual(txt, plaintext, 'encryption and decryption');
@@ -457,19 +457,19 @@ function testCipher1(key) {
function testCipher2(key) {
// encryption and decryption with Base64
// reported in https://github.com/joyent/node/issues/738
- var plaintext =
+ const plaintext =
'32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' +
'jAfaFg**';
- var cipher = crypto.createCipher('aes256', key);
+ const cipher = crypto.createCipher('aes256', key);
// encrypt plaintext which is in utf8 format
// to a ciphertext which will be in Base64
- var ciph = cipher.update(plaintext, 'utf8', 'base64');
+ let ciph = cipher.update(plaintext, 'utf8', 'base64');
ciph += cipher.final('base64');
- var decipher = crypto.createDecipher('aes256', key);
- var txt = decipher.update(ciph, 'base64', 'utf8');
+ const decipher = crypto.createDecipher('aes256', key);
+ let txt = decipher.update(ciph, 'base64', 'utf8');
txt += decipher.final('utf8');
assert.strictEqual(txt, plaintext, 'encryption and decryption with Base64');
@@ -478,16 +478,16 @@ function testCipher2(key) {
function testCipher3(key, iv) {
// Test encyrption and decryption with explicit key and iv
- var plaintext =
+ const plaintext =
'32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' +
'jAfaFg**';
- var cipher = crypto.createCipheriv('des-ede3-cbc', key, iv);
- var ciph = cipher.update(plaintext, 'utf8', 'hex');
+ const cipher = crypto.createCipheriv('des-ede3-cbc', key, iv);
+ let ciph = cipher.update(plaintext, 'utf8', 'hex');
ciph += cipher.final('hex');
- var decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv);
- var txt = decipher.update(ciph, 'hex', 'utf8');
+ const decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv);
+ let txt = decipher.update(ciph, 'hex', 'utf8');
txt += decipher.final('utf8');
assert.strictEqual(txt, plaintext,
@@ -497,16 +497,16 @@ function testCipher3(key, iv) {
function testCipher4(key, iv) {
// Test encyrption and decryption with explicit key and iv
- var plaintext =
+ const plaintext =
'32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' +
'jAfaFg**';
- var cipher = crypto.createCipheriv('des-ede3-cbc', key, iv);
- var ciph = cipher.update(plaintext, 'utf8', 'buffer');
+ const cipher = crypto.createCipheriv('des-ede3-cbc', key, iv);
+ let ciph = cipher.update(plaintext, 'utf8', 'buffer');
ciph = Buffer.concat([ciph, cipher.final('buffer')]);
- var decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv);
- var txt = decipher.update(ciph, 'buffer', 'utf8');
+ const decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv);
+ let txt = decipher.update(ciph, 'buffer', 'utf8');
txt += decipher.final('utf8');
assert.strictEqual(txt, plaintext,
@@ -537,20 +537,20 @@ assert.throws(function() {
// Test Diffie-Hellman with two parties sharing a secret,
// using various encodings as we go along
-var dh1 = crypto.createDiffieHellman(common.hasFipsCrypto ? 1024 : 256);
-var p1 = dh1.getPrime('buffer');
-var dh2 = crypto.createDiffieHellman(p1, 'base64');
-var key1 = dh1.generateKeys();
-var key2 = dh2.generateKeys('hex');
-var secret1 = dh1.computeSecret(key2, 'hex', 'base64');
-var secret2 = dh2.computeSecret(key1, 'latin1', 'buffer');
+const dh1 = crypto.createDiffieHellman(common.hasFipsCrypto ? 1024 : 256);
+const p1 = dh1.getPrime('buffer');
+const dh2 = crypto.createDiffieHellman(p1, 'base64');
+const key1 = dh1.generateKeys();
+const key2 = dh2.generateKeys('hex');
+const secret1 = dh1.computeSecret(key2, 'hex', 'base64');
+const secret2 = dh2.computeSecret(key1, 'latin1', 'buffer');
assert.strictEqual(secret1, secret2.toString('base64'));
// Create "another dh1" using generated keys from dh1,
// and compute secret again
-var dh3 = crypto.createDiffieHellman(p1, 'buffer');
-var privkey1 = dh1.getPrivateKey();
+const dh3 = crypto.createDiffieHellman(p1, 'buffer');
+const privkey1 = dh1.getPrivateKey();
dh3.setPublicKey(key1);
dh3.setPrivateKey(privkey1);
@@ -559,26 +559,26 @@ assert.strictEqual(dh1.getGenerator(), dh3.getGenerator());
assert.strictEqual(dh1.getPublicKey(), dh3.getPublicKey());
assert.strictEqual(dh1.getPrivateKey(), dh3.getPrivateKey());
-var secret3 = dh3.computeSecret(key2, 'hex', 'base64');
+const secret3 = dh3.computeSecret(key2, 'hex', 'base64');
assert.strictEqual(secret1, secret3);
// https://github.com/joyent/node/issues/2338
-var p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
- '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' +
- '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' +
- 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF';
-var d = crypto.createDiffieHellman(p, 'hex');
+const p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
+ '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' +
+ '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' +
+ 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF';
+const d = crypto.createDiffieHellman(p, 'hex');
assert.strictEqual(d.verifyError, DH_NOT_SUITABLE_GENERATOR);
// Test RSA key signing/verification
-var rsaSign = crypto.createSign('RSA-SHA1');
-var rsaVerify = crypto.createVerify('RSA-SHA1');
+const rsaSign = crypto.createSign('RSA-SHA1');
+const rsaVerify = crypto.createVerify('RSA-SHA1');
assert.ok(rsaSign instanceof crypto.Sign);
assert.ok(rsaVerify instanceof crypto.Verify);
rsaSign.update(rsaPubPem);
-var rsaSignature = rsaSign.sign(rsaKeyPem, 'hex');
+const rsaSignature = rsaSign.sign(rsaKeyPem, 'hex');
assert.strictEqual(
rsaSignature,
'5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7c' +
diff --git a/test/parallel/test-crypto-certificate.js b/test/parallel/test-crypto-certificate.js
index 8dba530fc54a45..c051716556410d 100644
--- a/test/parallel/test-crypto-certificate.js
+++ b/test/parallel/test-crypto-certificate.js
@@ -1,23 +1,23 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
crypto.DEFAULT_ENCODING = 'buffer';
-var fs = require('fs');
+const fs = require('fs');
// Test Certificates
-var spkacValid = fs.readFileSync(common.fixturesDir + '/spkac.valid');
-var spkacFail = fs.readFileSync(common.fixturesDir + '/spkac.fail');
-var spkacPem = fs.readFileSync(common.fixturesDir + '/spkac.pem');
+const spkacValid = fs.readFileSync(common.fixturesDir + '/spkac.valid');
+const spkacFail = fs.readFileSync(common.fixturesDir + '/spkac.fail');
+const spkacPem = fs.readFileSync(common.fixturesDir + '/spkac.pem');
-var certificate = new crypto.Certificate();
+const certificate = new crypto.Certificate();
assert.strictEqual(certificate.verifySpkac(spkacValid), true);
assert.strictEqual(certificate.verifySpkac(spkacFail), false);
diff --git a/test/parallel/test-crypto-dh-odd-key.js b/test/parallel/test-crypto-dh-odd-key.js
index cb8757efff0bde..f6bfcf72c0fd7e 100644
--- a/test/parallel/test-crypto-dh-odd-key.js
+++ b/test/parallel/test-crypto-dh-odd-key.js
@@ -1,17 +1,17 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
function test() {
- var odd = Buffer.alloc(39, 'A');
+ const odd = Buffer.alloc(39, 'A');
- var c = crypto.createDiffieHellman(32);
+ const c = crypto.createDiffieHellman(32);
c.setPrivateKey(odd);
c.generateKeys();
}
diff --git a/test/parallel/test-crypto-dh.js b/test/parallel/test-crypto-dh.js
index 884b482fc53450..b26ac78f3146a0 100644
--- a/test/parallel/test-crypto-dh.js
+++ b/test/parallel/test-crypto-dh.js
@@ -11,13 +11,13 @@ const DH_NOT_SUITABLE_GENERATOR = crypto.constants.DH_NOT_SUITABLE_GENERATOR;
// Test Diffie-Hellman with two parties sharing a secret,
// using various encodings as we go along
-var dh1 = crypto.createDiffieHellman(common.hasFipsCrypto ? 1024 : 256);
-var p1 = dh1.getPrime('buffer');
-var dh2 = crypto.createDiffieHellman(p1, 'buffer');
-var key1 = dh1.generateKeys();
-var key2 = dh2.generateKeys('hex');
-var secret1 = dh1.computeSecret(key2, 'hex', 'base64');
-var secret2 = dh2.computeSecret(key1, 'latin1', 'buffer');
+const dh1 = crypto.createDiffieHellman(common.hasFipsCrypto ? 1024 : 256);
+const p1 = dh1.getPrime('buffer');
+const dh2 = crypto.createDiffieHellman(p1, 'buffer');
+let key1 = dh1.generateKeys();
+let key2 = dh2.generateKeys('hex');
+let secret1 = dh1.computeSecret(key2, 'hex', 'base64');
+let secret2 = dh2.computeSecret(key1, 'latin1', 'buffer');
assert.equal(secret1, secret2.toString('base64'));
assert.equal(dh1.verifyError, 0);
@@ -41,8 +41,8 @@ assert.throws(function() {
// Create "another dh1" using generated keys from dh1,
// and compute secret again
-var dh3 = crypto.createDiffieHellman(p1, 'buffer');
-var privkey1 = dh1.getPrivateKey();
+const dh3 = crypto.createDiffieHellman(p1, 'buffer');
+const privkey1 = dh1.getPrivateKey();
dh3.setPublicKey(key1);
dh3.setPrivateKey(privkey1);
@@ -52,7 +52,7 @@ assert.deepStrictEqual(dh1.getPublicKey(), dh3.getPublicKey());
assert.deepStrictEqual(dh1.getPrivateKey(), dh3.getPrivateKey());
assert.equal(dh3.verifyError, 0);
-var secret3 = dh3.computeSecret(key2, 'hex', 'base64');
+const secret3 = dh3.computeSecret(key2, 'hex', 'base64');
assert.equal(secret1, secret3);
@@ -72,12 +72,12 @@ assert.throws(function() {
}
// Create a shared using a DH group.
-var alice = crypto.createDiffieHellmanGroup('modp5');
-var bob = crypto.createDiffieHellmanGroup('modp5');
+const alice = crypto.createDiffieHellmanGroup('modp5');
+const bob = crypto.createDiffieHellmanGroup('modp5');
alice.generateKeys();
bob.generateKeys();
-var aSecret = alice.computeSecret(bob.getPublicKey()).toString('hex');
-var bSecret = bob.computeSecret(alice.getPublicKey()).toString('hex');
+const aSecret = alice.computeSecret(bob.getPublicKey()).toString('hex');
+const bSecret = bob.computeSecret(alice.getPublicKey()).toString('hex');
assert.equal(aSecret, bSecret);
assert.equal(alice.verifyError, DH_NOT_SUITABLE_GENERATOR);
assert.equal(bob.verifyError, DH_NOT_SUITABLE_GENERATOR);
@@ -85,8 +85,8 @@ assert.equal(bob.verifyError, DH_NOT_SUITABLE_GENERATOR);
/* Ensure specific generator (buffer) works as expected.
* The values below (modp2/modp2buf) are for a 1024 bits long prime from
* RFC 2412 E.2, see https://tools.ietf.org/html/rfc2412. */
-var modp2 = crypto.createDiffieHellmanGroup('modp2');
-var modp2buf = Buffer.from([
+const modp2 = crypto.createDiffieHellmanGroup('modp2');
+const modp2buf = Buffer.from([
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc9, 0x0f,
0xda, 0xa2, 0x21, 0x68, 0xc2, 0x34, 0xc4, 0xc6, 0x62, 0x8b,
0x80, 0xdc, 0x1c, 0xd1, 0x29, 0x02, 0x4e, 0x08, 0x8a, 0x67,
@@ -101,51 +101,52 @@ var modp2buf = Buffer.from([
0x1f, 0xe6, 0x49, 0x28, 0x66, 0x51, 0xec, 0xe6, 0x53, 0x81,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
]);
-var exmodp2 = crypto.createDiffieHellman(modp2buf, Buffer.from([2]));
+const exmodp2 = crypto.createDiffieHellman(modp2buf, Buffer.from([2]));
modp2.generateKeys();
exmodp2.generateKeys();
-var modp2Secret = modp2.computeSecret(exmodp2.getPublicKey()).toString('hex');
-var exmodp2Secret = exmodp2.computeSecret(modp2.getPublicKey()).toString('hex');
+let modp2Secret = modp2.computeSecret(exmodp2.getPublicKey()).toString('hex');
+const exmodp2Secret = exmodp2.computeSecret(modp2.getPublicKey())
+ .toString('hex');
assert.equal(modp2Secret, exmodp2Secret);
assert.equal(modp2.verifyError, DH_NOT_SUITABLE_GENERATOR);
assert.equal(exmodp2.verifyError, DH_NOT_SUITABLE_GENERATOR);
// Ensure specific generator (string with encoding) works as expected.
-var exmodp2_2 = crypto.createDiffieHellman(modp2buf, '02', 'hex');
+const exmodp2_2 = crypto.createDiffieHellman(modp2buf, '02', 'hex');
exmodp2_2.generateKeys();
modp2Secret = modp2.computeSecret(exmodp2_2.getPublicKey()).toString('hex');
-var exmodp2_2Secret = exmodp2_2.computeSecret(modp2.getPublicKey())
+const exmodp2_2Secret = exmodp2_2.computeSecret(modp2.getPublicKey())
.toString('hex');
assert.equal(modp2Secret, exmodp2_2Secret);
assert.equal(exmodp2_2.verifyError, DH_NOT_SUITABLE_GENERATOR);
// Ensure specific generator (string without encoding) works as expected.
-var exmodp2_3 = crypto.createDiffieHellman(modp2buf, '\x02');
+const exmodp2_3 = crypto.createDiffieHellman(modp2buf, '\x02');
exmodp2_3.generateKeys();
modp2Secret = modp2.computeSecret(exmodp2_3.getPublicKey()).toString('hex');
-var exmodp2_3Secret = exmodp2_3.computeSecret(modp2.getPublicKey())
+const exmodp2_3Secret = exmodp2_3.computeSecret(modp2.getPublicKey())
.toString('hex');
assert.equal(modp2Secret, exmodp2_3Secret);
assert.equal(exmodp2_3.verifyError, DH_NOT_SUITABLE_GENERATOR);
// Ensure specific generator (numeric) works as expected.
-var exmodp2_4 = crypto.createDiffieHellman(modp2buf, 2);
+const exmodp2_4 = crypto.createDiffieHellman(modp2buf, 2);
exmodp2_4.generateKeys();
modp2Secret = modp2.computeSecret(exmodp2_4.getPublicKey()).toString('hex');
-var exmodp2_4Secret = exmodp2_4.computeSecret(modp2.getPublicKey())
+const exmodp2_4Secret = exmodp2_4.computeSecret(modp2.getPublicKey())
.toString('hex');
assert.equal(modp2Secret, exmodp2_4Secret);
assert.equal(exmodp2_4.verifyError, DH_NOT_SUITABLE_GENERATOR);
-var p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
- '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' +
- '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' +
- 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF';
-var bad_dh = crypto.createDiffieHellman(p, 'hex');
+const p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
+ '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' +
+ '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' +
+ 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF';
+const bad_dh = crypto.createDiffieHellman(p, 'hex');
assert.equal(bad_dh.verifyError, DH_NOT_SUITABLE_GENERATOR);
diff --git a/test/parallel/test-crypto-domain.js b/test/parallel/test-crypto-domain.js
index ec9985719933d3..6586f7d48a94ce 100644
--- a/test/parallel/test-crypto-domain.js
+++ b/test/parallel/test-crypto-domain.js
@@ -1,21 +1,21 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var domain = require('domain');
+const common = require('../common');
+const assert = require('assert');
+const domain = require('domain');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
function test(fn) {
- var ex = new Error('BAM');
- var d = domain.create();
+ const ex = new Error('BAM');
+ const d = domain.create();
d.on('error', common.mustCall(function(err) {
assert.strictEqual(err, ex);
}));
- var cb = common.mustCall(function() {
+ const cb = common.mustCall(function() {
throw ex;
});
d.run(cb);
diff --git a/test/parallel/test-crypto-domains.js b/test/parallel/test-crypto-domains.js
index 5d8caf37ee2f41..2749382fa5c780 100644
--- a/test/parallel/test-crypto-domains.js
+++ b/test/parallel/test-crypto-domains.js
@@ -1,15 +1,15 @@
'use strict';
-var common = require('../common');
-var domain = require('domain');
-var assert = require('assert');
-var d = domain.create();
-var expect = ['pbkdf2', 'randomBytes', 'pseudoRandomBytes'];
+const common = require('../common');
+const domain = require('domain');
+const assert = require('assert');
+const d = domain.create();
+const expect = ['pbkdf2', 'randomBytes', 'pseudoRandomBytes'];
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
d.on('error', common.mustCall(function(e) {
assert.equal(e.message, expect.shift());
diff --git a/test/parallel/test-crypto-fips.js b/test/parallel/test-crypto-fips.js
index 24b1af70b70329..60263cb01b6809 100644
--- a/test/parallel/test-crypto-fips.js
+++ b/test/parallel/test-crypto-fips.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var spawnSync = require('child_process').spawnSync;
-var path = require('path');
+const common = require('../common');
+const assert = require('assert');
+const spawnSync = require('child_process').spawnSync;
+const path = require('path');
if (!common.hasCrypto) {
common.skip('missing crypto');
@@ -15,14 +15,14 @@ const FIPS_ERROR_STRING = 'Error: Cannot set FIPS mode';
const OPTION_ERROR_STRING = 'bad option';
const CNF_FIPS_ON = path.join(common.fixturesDir, 'openssl_fips_enabled.cnf');
const CNF_FIPS_OFF = path.join(common.fixturesDir, 'openssl_fips_disabled.cnf');
-var num_children_ok = 0;
+let num_children_ok = 0;
function compiledWithFips() {
return process.config.variables.openssl_fips ? true : false;
}
function addToEnv(newVar, value) {
- var envCopy = {};
+ const envCopy = {};
for (const e in process.env) {
envCopy[e] = process.env[e];
}
diff --git a/test/parallel/test-crypto-from-binary.js b/test/parallel/test-crypto-from-binary.js
index 0889541ef6e144..485735e83ce5cc 100644
--- a/test/parallel/test-crypto-from-binary.js
+++ b/test/parallel/test-crypto-from-binary.js
@@ -3,19 +3,19 @@
// to use buffers by default.
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
-var EXTERN_APEX = 0xFBEE9;
+const EXTERN_APEX = 0xFBEE9;
// manually controlled string for checking binary output
-var ucs2_control = 'a\u0000';
+let ucs2_control = 'a\u0000';
// grow the strings to proper length
while (ucs2_control.length <= EXTERN_APEX) {
@@ -24,7 +24,7 @@ while (ucs2_control.length <= EXTERN_APEX) {
// check resultant buffer and output string
-var b = Buffer.from(ucs2_control + ucs2_control, 'ucs2');
+const b = Buffer.from(ucs2_control + ucs2_control, 'ucs2');
//
// Test updating from birant data
diff --git a/test/parallel/test-crypto-hash.js b/test/parallel/test-crypto-hash.js
index 79353ede3b49dc..9008b8f9b1614c 100644
--- a/test/parallel/test-crypto-hash.js
+++ b/test/parallel/test-crypto-hash.js
@@ -1,44 +1,44 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
-var path = require('path');
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
+const path = require('path');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
// Test hashing
-var a1 = crypto.createHash('sha1').update('Test123').digest('hex');
-var a2 = crypto.createHash('sha256').update('Test123').digest('base64');
-var a3 = crypto.createHash('sha512').update('Test123').digest(); // buffer
-var a4 = crypto.createHash('sha1').update('Test123').digest('buffer');
+const a1 = crypto.createHash('sha1').update('Test123').digest('hex');
+const a2 = crypto.createHash('sha256').update('Test123').digest('base64');
+const a3 = crypto.createHash('sha512').update('Test123').digest(); // buffer
+const a4 = crypto.createHash('sha1').update('Test123').digest('buffer');
// stream interface
-var a5 = crypto.createHash('sha512');
+let a5 = crypto.createHash('sha512');
a5.end('Test123');
a5 = a5.read();
-var a6 = crypto.createHash('sha512');
+let a6 = crypto.createHash('sha512');
a6.write('Te');
a6.write('st');
a6.write('123');
a6.end();
a6 = a6.read();
-var a7 = crypto.createHash('sha512');
+let a7 = crypto.createHash('sha512');
a7.end();
a7 = a7.read();
-var a8 = crypto.createHash('sha512');
+let a8 = crypto.createHash('sha512');
a8.write('');
a8.end();
a8 = a8.read();
if (!common.hasFipsCrypto) {
- var a0 = crypto.createHash('md5').update('Test123').digest('latin1');
+ const a0 = crypto.createHash('md5').update('Test123').digest('latin1');
assert.strictEqual(
a0,
'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c',
@@ -71,14 +71,14 @@ assert.notEqual(a7, undefined, 'no data should return data');
assert.notEqual(a8, undefined, 'empty string should generate data');
// Test multiple updates to same hash
-var h1 = crypto.createHash('sha1').update('Test123').digest('hex');
-var h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex');
+const h1 = crypto.createHash('sha1').update('Test123').digest('hex');
+const h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex');
assert.strictEqual(h1, h2, 'multipled updates');
// Test hashing for binary files
-var fn = path.join(common.fixturesDir, 'sample.png');
-var sha1Hash = crypto.createHash('sha1');
-var fileStream = fs.createReadStream(fn);
+const fn = path.join(common.fixturesDir, 'sample.png');
+const sha1Hash = crypto.createHash('sha1');
+const fileStream = fs.createReadStream(fn);
fileStream.on('data', function(data) {
sha1Hash.update(data);
});
@@ -94,7 +94,7 @@ assert.throws(function() {
}, /Digest method not supported/);
// Default UTF-8 encoding
-var hutf8 = crypto.createHash('sha512').update('УТФ-8 text').digest('hex');
+const hutf8 = crypto.createHash('sha512').update('УТФ-8 text').digest('hex');
assert.strictEqual(
hutf8,
'4b21bbd1a68e690a730ddcb5a8bc94ead9879ffe82580767ad7ec6fa8ba2dea6' +
@@ -104,7 +104,7 @@ assert.notEqual(
hutf8,
crypto.createHash('sha512').update('УТФ-8 text', 'latin1').digest('hex'));
-var h3 = crypto.createHash('sha256');
+const h3 = crypto.createHash('sha256');
h3.digest();
assert.throws(function() {
h3.digest();
diff --git a/test/parallel/test-crypto-hmac.js b/test/parallel/test-crypto-hmac.js
index eeb8cd152567f8..a3372bcb7242b9 100644
--- a/test/parallel/test-crypto-hmac.js
+++ b/test/parallel/test-crypto-hmac.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
// Test for binding layer robustness
{
@@ -17,14 +17,14 @@ var crypto = require('crypto');
}
// Test HMAC
-var h1 = crypto.createHmac('sha1', 'Node')
+const h1 = crypto.createHmac('sha1', 'Node')
.update('some data')
.update('to hmac')
.digest('hex');
assert.strictEqual(h1, '19fd6e1ba73d9ed2224dd5094a71babe85d9a892', 'test HMAC');
// Test HMAC (Wikipedia Test Cases)
-var wikipedia = [
+const wikipedia = [
{
key: 'key', data: 'The quick brown fox jumps over the lazy dog',
hmac: { // HMACs lifted from Wikipedia.
@@ -83,7 +83,7 @@ for (let i = 0, l = wikipedia.length; i < l; i++) {
// Test HMAC-SHA-* (rfc 4231 Test Cases)
-var rfc4231 = [
+const rfc4231 = [
{
key: Buffer.from('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
data: Buffer.from('4869205468657265', 'hex'), // 'Hi There'
@@ -249,7 +249,7 @@ for (let i = 0, l = rfc4231.length; i < l; i++) {
}
// Test HMAC-MD5/SHA1 (rfc 2202 Test Cases)
-var rfc2202_md5 = [
+const rfc2202_md5 = [
{
key: Buffer.from('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
data: 'Hi There',
@@ -302,7 +302,7 @@ var rfc2202_md5 = [
hmac: '6f630fad67cda0ee1fb1f562db3aa53e'
}
];
-var rfc2202_sha1 = [
+const rfc2202_sha1 = [
{
key: Buffer.from('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
data: 'Hi There',
diff --git a/test/parallel/test-crypto-padding-aes256.js b/test/parallel/test-crypto-padding-aes256.js
index 7fd2e98de617cf..40bbfed0f2824f 100644
--- a/test/parallel/test-crypto-padding-aes256.js
+++ b/test/parallel/test-crypto-padding-aes256.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
crypto.DEFAULT_ENCODING = 'buffer';
diff --git a/test/parallel/test-crypto-rsa-dsa.js b/test/parallel/test-crypto-rsa-dsa.js
index bbc043fbc3aee2..eadb948491f19c 100644
--- a/test/parallel/test-crypto-rsa-dsa.js
+++ b/test/parallel/test-crypto-rsa-dsa.js
@@ -1,29 +1,29 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
-var constants = require('crypto').constants;
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
+const constants = require('crypto').constants;
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
// Test certificates
-var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
-var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
-var rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem',
- 'ascii');
-var rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem',
- 'ascii');
-var rsaKeyPemEncrypted = fs.readFileSync(
+const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
+const keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
+const rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem',
+ 'ascii');
+const rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem',
+ 'ascii');
+const rsaKeyPemEncrypted = fs.readFileSync(
common.fixturesDir + '/test_rsa_privkey_encrypted.pem', 'ascii');
-var dsaPubPem = fs.readFileSync(common.fixturesDir + '/test_dsa_pubkey.pem',
- 'ascii');
-var dsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_dsa_privkey.pem',
- 'ascii');
-var dsaKeyPemEncrypted = fs.readFileSync(
+const dsaPubPem = fs.readFileSync(common.fixturesDir + '/test_dsa_pubkey.pem',
+ 'ascii');
+const dsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_dsa_privkey.pem',
+ 'ascii');
+const dsaKeyPemEncrypted = fs.readFileSync(
common.fixturesDir + '/test_dsa_privkey_encrypted.pem', 'ascii');
// Test RSA encryption/decryption
@@ -107,19 +107,20 @@ var dsaKeyPemEncrypted = fs.readFileSync(
}
function test_rsa(padding) {
- var input = Buffer.allocUnsafe(padding === 'RSA_NO_PADDING' ? 1024 / 8 : 32);
- for (var i = 0; i < input.length; i++)
+ const input = Buffer
+ .allocUnsafe(padding === 'RSA_NO_PADDING' ? 1024 / 8 : 32);
+ for (let i = 0; i < input.length; i++)
input[i] = (i * 7 + 11) & 0xff;
- var bufferToEncrypt = Buffer.from(input);
+ const bufferToEncrypt = Buffer.from(input);
padding = constants[padding];
- var encryptedBuffer = crypto.publicEncrypt({
+ const encryptedBuffer = crypto.publicEncrypt({
key: rsaPubPem,
padding: padding
}, bufferToEncrypt);
- var decryptedBuffer = crypto.privateDecrypt({
+ const decryptedBuffer = crypto.privateDecrypt({
key: rsaKeyPem,
padding: padding
}, encryptedBuffer);
@@ -131,13 +132,13 @@ test_rsa('RSA_PKCS1_PADDING');
test_rsa('RSA_PKCS1_OAEP_PADDING');
// Test RSA key signing/verification
-var rsaSign = crypto.createSign('RSA-SHA1');
-var rsaVerify = crypto.createVerify('RSA-SHA1');
+let rsaSign = crypto.createSign('RSA-SHA1');
+let rsaVerify = crypto.createVerify('RSA-SHA1');
assert.ok(rsaSign);
assert.ok(rsaVerify);
rsaSign.update(rsaPubPem);
-var rsaSignature = rsaSign.sign(rsaKeyPem, 'hex');
+let rsaSignature = rsaSign.sign(rsaKeyPem, 'hex');
assert.equal(rsaSignature,
'5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7c' +
'8f020d7e2688b122bfb54c724ac9ee169f83f66d2fe90abeb95e8' +
@@ -152,7 +153,7 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
rsaSign = crypto.createSign('RSA-SHA1');
rsaSign.update(rsaPubPem);
assert.doesNotThrow(function() {
- var signOptions = { key: rsaKeyPemEncrypted, passphrase: 'password' };
+ const signOptions = { key: rsaKeyPemEncrypted, passphrase: 'password' };
rsaSignature = rsaSign.sign(signOptions, 'hex');
});
assert.equal(rsaSignature,
@@ -169,7 +170,7 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
rsaSign = crypto.createSign('RSA-SHA1');
rsaSign.update(rsaPubPem);
assert.throws(function() {
- var signOptions = { key: rsaKeyPemEncrypted, passphrase: 'wrong' };
+ const signOptions = { key: rsaKeyPemEncrypted, passphrase: 'wrong' };
rsaSign.sign(signOptions, 'hex');
});
diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js
index b4ef8296282b7f..81b2c109b69b20 100644
--- a/test/parallel/test-crypto-sign-verify.js
+++ b/test/parallel/test-crypto-sign-verify.js
@@ -1,17 +1,17 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
// Test certificates
-var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
-var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
+const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
+const keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
// Test signing and verifying
{
diff --git a/test/parallel/test-crypto-stream.js b/test/parallel/test-crypto-stream.js
index 1720cc7c4e0aea..f558851b7940a0 100644
--- a/test/parallel/test-crypto-stream.js
+++ b/test/parallel/test-crypto-stream.js
@@ -1,14 +1,14 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var stream = require('stream');
-var util = require('util');
+const common = require('../common');
+const assert = require('assert');
+const stream = require('stream');
+const util = require('util');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
// Small stream to buffer converter
function Stream2buffer(callback) {
@@ -28,7 +28,7 @@ Stream2buffer.prototype._write = function(data, encodeing, done) {
if (!common.hasFipsCrypto) {
// Create an md5 hash of "Hallo world"
- var hasher1 = crypto.createHash('md5');
+ const hasher1 = crypto.createHash('md5');
hasher1.pipe(new Stream2buffer(common.mustCall(function end(err, hash) {
assert.strictEqual(err, null);
assert.strictEqual(
diff --git a/test/parallel/test-crypto-verify-failure.js b/test/parallel/test-crypto-verify-failure.js
index 415e13ff64e640..fdf0d6f6456dac 100644
--- a/test/parallel/test-crypto-verify-failure.js
+++ b/test/parallel/test-crypto-verify-failure.js
@@ -1,20 +1,20 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
-var tls = require('tls');
+const crypto = require('crypto');
+const tls = require('tls');
crypto.DEFAULT_ENCODING = 'buffer';
-var fs = require('fs');
+const fs = require('fs');
-var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
+const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
diff --git a/test/parallel/test-cwd-enoent-repl.js b/test/parallel/test-cwd-enoent-repl.js
index 1d03bd3e9112c1..942fc07b64a90b 100644
--- a/test/parallel/test-cwd-enoent-repl.js
+++ b/test/parallel/test-cwd-enoent-repl.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
-var spawn = require('child_process').spawn;
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
+const spawn = require('child_process').spawn;
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
if (common.isSunOS || common.isWindows || common.isAix) {
@@ -10,13 +10,13 @@ if (common.isSunOS || common.isWindows || common.isAix) {
return;
}
-var dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid;
+const dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid;
common.refreshTmpDir();
fs.mkdirSync(dirname);
process.chdir(dirname);
fs.rmdirSync(dirname);
-var proc = spawn(process.execPath, ['--interactive']);
+const proc = spawn(process.execPath, ['--interactive']);
proc.stdout.pipe(process.stdout);
proc.stderr.pipe(process.stderr);
proc.stdin.write('require("path");\n');
diff --git a/test/parallel/test-cwd-enoent.js b/test/parallel/test-cwd-enoent.js
index c671ef2be4619e..736121a7c89d6e 100644
--- a/test/parallel/test-cwd-enoent.js
+++ b/test/parallel/test-cwd-enoent.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
-var spawn = require('child_process').spawn;
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
+const spawn = require('child_process').spawn;
// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
if (common.isSunOS || common.isWindows || common.isAix) {
@@ -10,13 +10,13 @@ if (common.isSunOS || common.isWindows || common.isAix) {
return;
}
-var dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid;
+const dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid;
common.refreshTmpDir();
fs.mkdirSync(dirname);
process.chdir(dirname);
fs.rmdirSync(dirname);
-var proc = spawn(process.execPath, ['-e', '0']);
+const proc = spawn(process.execPath, ['-e', '0']);
proc.stdout.pipe(process.stdout);
proc.stderr.pipe(process.stderr);
diff --git a/test/parallel/test-debug-brk.js b/test/parallel/test-debug-brk.js
index 89d9c892145676..769e3a6c5b504e 100644
--- a/test/parallel/test-debug-brk.js
+++ b/test/parallel/test-debug-brk.js
@@ -7,13 +7,13 @@ let run = () => {};
function test(extraArgs, stdoutPattern) {
const next = run;
run = () => {
- var procStdout = '';
- var procStderr = '';
- var agentStdout = '';
- var debuggerListening = false;
- var outputMatched = false;
- var needToSpawnAgent = true;
- var needToExit = true;
+ let procStdout = '';
+ let procStderr = '';
+ let agentStdout = '';
+ let debuggerListening = false;
+ let outputMatched = false;
+ let needToSpawnAgent = true;
+ let needToExit = true;
const procArgs = [`--debug-brk=${common.PORT}`].concat(extraArgs);
const proc = spawn(process.execPath, procArgs);
diff --git a/test/parallel/test-debug-port-from-cmdline.js b/test/parallel/test-debug-port-from-cmdline.js
index cd92764df29c8e..f81f683c880b08 100644
--- a/test/parallel/test-debug-port-from-cmdline.js
+++ b/test/parallel/test-debug-port-from-cmdline.js
@@ -1,17 +1,17 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
+const common = require('../common');
+const assert = require('assert');
+const spawn = require('child_process').spawn;
-var debugPort = common.PORT;
-var args = ['--interactive', '--debug-port=' + debugPort];
-var childOptions = { stdio: ['pipe', 'pipe', 'pipe', 'ipc'] };
-var child = spawn(process.execPath, args, childOptions);
+const debugPort = common.PORT;
+const args = ['--interactive', '--debug-port=' + debugPort];
+const childOptions = { stdio: ['pipe', 'pipe', 'pipe', 'ipc'] };
+const child = spawn(process.execPath, args, childOptions);
child.stdin.write("process.send({ msg: 'childready' });\n");
child.stderr.on('data', function(data) {
- var lines = data.toString().replace(/\r/g, '').trim().split('\n');
+ const lines = data.toString().replace(/\r/g, '').trim().split('\n');
lines.forEach(processStderrLine);
});
@@ -26,7 +26,7 @@ process.on('exit', function() {
assertOutputLines();
});
-var outputLines = [];
+const outputLines = [];
function processStderrLine(line) {
console.log('> ' + line);
outputLines.push(line);
@@ -37,12 +37,12 @@ function processStderrLine(line) {
}
function assertOutputLines() {
- var expectedLines = [
+ const expectedLines = [
'Starting debugger agent.',
'Debugger listening on (\\[::\\]|0\\.0\\.0\\.0):' + debugPort,
];
assert.strictEqual(outputLines.length, expectedLines.length);
- for (var i = 0; i < expectedLines.length; i++)
+ for (let i = 0; i < expectedLines.length; i++)
assert(RegExp(expectedLines[i]).test(outputLines[i]));
}
diff --git a/test/parallel/test-debug-signal-cluster.js b/test/parallel/test-debug-signal-cluster.js
index d5319a616939d1..22bfdfb09dbdc5 100644
--- a/test/parallel/test-debug-signal-cluster.js
+++ b/test/parallel/test-debug-signal-cluster.js
@@ -12,9 +12,9 @@ const options = { stdio: ['inherit', 'inherit', 'pipe', 'ipc'] };
const child = spawn(process.execPath, args, options);
const outputLines = [];
-var waitingForDebuggers = false;
+let waitingForDebuggers = false;
-var pids;
+let pids;
child.stderr.on('data', function(data) {
const lines = data.toString().replace(/\r/g, '').trim().split('\n');
@@ -76,6 +76,6 @@ function assertOutputLines() {
expectedLines.sort();
assert.equal(outputLines.length, expectedLines.length);
- for (var i = 0; i < expectedLines.length; i++)
+ for (let i = 0; i < expectedLines.length; i++)
assert(RegExp(expectedLines[i]).test(outputLines[i]));
}
diff --git a/test/parallel/test-debug-uncaught-exception-async.js b/test/parallel/test-debug-uncaught-exception-async.js
index 29947cfd92fbb9..8d0d7957c22e12 100644
--- a/test/parallel/test-debug-uncaught-exception-async.js
+++ b/test/parallel/test-debug-uncaught-exception-async.js
@@ -7,7 +7,7 @@ const spawn = require('child_process').spawn;
const emitUncaught = path.join(common.fixturesDir, 'debug-uncaught-async.js');
const result = spawn(process.execPath, [emitUncaught], {encoding: 'utf8'});
-var stderr = '';
+let stderr = '';
result.stderr.on('data', (data) => {
stderr += data;
});
diff --git a/test/parallel/test-debug-usage.js b/test/parallel/test-debug-usage.js
index 5406a82cc8d229..67ee08ce729431 100644
--- a/test/parallel/test-debug-usage.js
+++ b/test/parallel/test-debug-usage.js
@@ -10,7 +10,7 @@ const expectedUsageMessage = `Usage: node debug script.js
node debug :
node debug -p
`;
-var actualUsageMessage = '';
+let actualUsageMessage = '';
child.stderr.on('data', function(data) {
actualUsageMessage += data.toString();
});
diff --git a/test/parallel/test-debugger-pid.js b/test/parallel/test-debugger-pid.js
index 7d03b0fc5c2308..7617e84bb409d8 100644
--- a/test/parallel/test-debugger-pid.js
+++ b/test/parallel/test-debugger-pid.js
@@ -3,15 +3,15 @@ const common = require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;
-var buffer = '';
+let buffer = '';
// connect to debug agent
-var interfacer = spawn(process.execPath, ['debug', '-p', '655555']);
+const interfacer = spawn(process.execPath, ['debug', '-p', '655555']);
console.error(process.execPath, 'debug', '-p', '655555');
interfacer.stdout.setEncoding('utf-8');
interfacer.stderr.setEncoding('utf-8');
-var onData = function(data) {
+const onData = function(data) {
data = (buffer + data).split('\n');
buffer = data.pop();
data.forEach(function(line) {
@@ -21,9 +21,9 @@ var onData = function(data) {
interfacer.stdout.on('data', onData);
interfacer.stderr.on('data', onData);
-var lineCount = 0;
+let lineCount = 0;
interfacer.on('line', function(line) {
- var expected;
+ let expected;
const pid = interfacer.pid;
if (common.isWindows) {
switch (++lineCount) {
diff --git a/test/parallel/test-debugger-repeat-last.js b/test/parallel/test-debugger-repeat-last.js
index 7a43bbb6c767ae..cacedbbd7c6e99 100644
--- a/test/parallel/test-debugger-repeat-last.js
+++ b/test/parallel/test-debugger-repeat-last.js
@@ -17,11 +17,11 @@ const args = [
const proc = spawn(process.execPath, args, { stdio: 'pipe' });
proc.stdout.setEncoding('utf8');
-var stdout = '';
+let stdout = '';
-var sentCommand = false;
-var sentEmpty = false;
-var sentExit = false;
+let sentCommand = false;
+let sentEmpty = false;
+let sentExit = false;
proc.stdout.on('data', (data) => {
stdout += data;
diff --git a/test/parallel/test-delayed-require.js b/test/parallel/test-delayed-require.js
index bc110388fc0380..8e07367eb47366 100644
--- a/test/parallel/test-delayed-require.js
+++ b/test/parallel/test-delayed-require.js
@@ -1,7 +1,7 @@
'use strict';
-var common = require('../common');
-var path = require('path');
-var assert = require('assert');
+const common = require('../common');
+const path = require('path');
+const assert = require('assert');
setTimeout(common.mustCall(function() {
const a = require(path.join(common.fixturesDir, 'a'));
diff --git a/test/parallel/test-dgram-address.js b/test/parallel/test-dgram-address.js
index 38729de67098da..09c5ba31f6c5b5 100644
--- a/test/parallel/test-dgram-address.js
+++ b/test/parallel/test-dgram-address.js
@@ -1,14 +1,14 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var dgram = require('dgram');
+const common = require('../common');
+const assert = require('assert');
+const dgram = require('dgram');
// IPv4 Test
-var socket_ipv4 = dgram.createSocket('udp4');
-var family_ipv4 = 'IPv4';
+const socket_ipv4 = dgram.createSocket('udp4');
+const family_ipv4 = 'IPv4';
socket_ipv4.on('listening', function() {
- var address_ipv4 = socket_ipv4.address();
+ const address_ipv4 = socket_ipv4.address();
assert.strictEqual(address_ipv4.address, common.localhostIPv4);
assert.strictEqual(typeof address_ipv4.port, 'number');
assert.ok(isFinite(address_ipv4.port));
@@ -25,12 +25,12 @@ socket_ipv4.on('error', function(e) {
socket_ipv4.bind(0, common.localhostIPv4);
// IPv6 Test
-var localhost_ipv6 = '::1';
-var socket_ipv6 = dgram.createSocket('udp6');
-var family_ipv6 = 'IPv6';
+const localhost_ipv6 = '::1';
+const socket_ipv6 = dgram.createSocket('udp6');
+const family_ipv6 = 'IPv6';
socket_ipv6.on('listening', function() {
- var address_ipv6 = socket_ipv6.address();
+ const address_ipv6 = socket_ipv6.address();
assert.strictEqual(address_ipv6.address, localhost_ipv6);
assert.strictEqual(typeof address_ipv6.port, 'number');
assert.ok(isFinite(address_ipv6.port));
diff --git a/test/parallel/test-dgram-bind.js b/test/parallel/test-dgram-bind.js
index 2d11fba6443ad8..f4624358a4fab4 100644
--- a/test/parallel/test-dgram-bind.js
+++ b/test/parallel/test-dgram-bind.js
@@ -3,7 +3,7 @@ const common = require('../common');
const assert = require('assert');
const dgram = require('dgram');
-var socket = dgram.createSocket('udp4');
+const socket = dgram.createSocket('udp4');
socket.on('listening', common.mustCall(() => {
assert.throws(() => {
@@ -13,6 +13,6 @@ socket.on('listening', common.mustCall(() => {
socket.close();
}));
-var result = socket.bind(); // should not throw
+const result = socket.bind(); // should not throw
assert.strictEqual(result, socket); // should have returned itself
diff --git a/test/parallel/test-dgram-bytes-length.js b/test/parallel/test-dgram-bytes-length.js
index 8e2233e9c4daad..07a8bb0e43452b 100644
--- a/test/parallel/test-dgram-bytes-length.js
+++ b/test/parallel/test-dgram-bytes-length.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
-var dgram = require('dgram');
+const assert = require('assert');
+const dgram = require('dgram');
-var message = Buffer.from('Some bytes');
-var client = dgram.createSocket('udp4');
+const message = Buffer.from('Some bytes');
+const client = dgram.createSocket('udp4');
client.send(
message,
0,
diff --git a/test/parallel/test-dgram-close-is-not-callback.js b/test/parallel/test-dgram-close-is-not-callback.js
index 61e08200360452..d0f23d5808c7b7 100644
--- a/test/parallel/test-dgram-close-is-not-callback.js
+++ b/test/parallel/test-dgram-close-is-not-callback.js
@@ -1,10 +1,10 @@
'use strict';
-var common = require('../common');
-var dgram = require('dgram');
+const common = require('../common');
+const dgram = require('dgram');
-var buf = Buffer.alloc(1024, 42);
+const buf = Buffer.alloc(1024, 42);
-var socket = dgram.createSocket('udp4');
+const socket = dgram.createSocket('udp4');
socket.send(buf, 0, buf.length, common.PORT, 'localhost');
diff --git a/test/parallel/test-dgram-close.js b/test/parallel/test-dgram-close.js
index 41d28553ca8cb7..43047db697a2eb 100644
--- a/test/parallel/test-dgram-close.js
+++ b/test/parallel/test-dgram-close.js
@@ -6,10 +6,10 @@ const common = require('../common');
const assert = require('assert');
const dgram = require('dgram');
-var buf = Buffer.alloc(1024, 42);
+const buf = Buffer.alloc(1024, 42);
-var socket = dgram.createSocket('udp4');
-var handle = socket._handle;
+let socket = dgram.createSocket('udp4');
+const handle = socket._handle;
socket.send(buf, 0, buf.length, common.PORT, 'localhost');
assert.strictEqual(socket.close(common.mustCall(function() {})), socket);
diff --git a/test/parallel/test-dgram-exclusive-implicit-bind.js b/test/parallel/test-dgram-exclusive-implicit-bind.js
index 97fd6bed5d6e33..d6ec7097e40827 100644
--- a/test/parallel/test-dgram-exclusive-implicit-bind.js
+++ b/test/parallel/test-dgram-exclusive-implicit-bind.js
@@ -40,11 +40,11 @@ const dgram = require('dgram');
// with ENOTSUP.
if (cluster.isMaster) {
- var messages = 0;
+ let messages = 0;
const ports = {};
const pids = [];
- var target = dgram.createSocket('udp4');
+ const target = dgram.createSocket('udp4');
const done = common.mustCall(function() {
cluster.disconnect();
@@ -84,7 +84,7 @@ if (cluster.isMaster) {
}
const source = dgram.createSocket('udp4');
-var interval;
+let interval;
source.on('close', function() {
clearInterval(interval);
diff --git a/test/parallel/test-dgram-implicit-bind.js b/test/parallel/test-dgram-implicit-bind.js
index 8cbb3f771e2d47..bfc86803b463f1 100644
--- a/test/parallel/test-dgram-implicit-bind.js
+++ b/test/parallel/test-dgram-implicit-bind.js
@@ -1,10 +1,10 @@
'use strict';
const common = require('../common');
-var dgram = require('dgram');
+const dgram = require('dgram');
-var source = dgram.createSocket('udp4');
-var target = dgram.createSocket('udp4');
-var messages = 0;
+const source = dgram.createSocket('udp4');
+const target = dgram.createSocket('udp4');
+let messages = 0;
target.on('message', common.mustCall(function(buf) {
if (buf.toString() === 'abc') ++messages;
diff --git a/test/parallel/test-dgram-listen-after-bind.js b/test/parallel/test-dgram-listen-after-bind.js
index 498a17a0e5b053..e60687649cda30 100644
--- a/test/parallel/test-dgram-listen-after-bind.js
+++ b/test/parallel/test-dgram-listen-after-bind.js
@@ -1,14 +1,14 @@
'use strict';
require('../common');
-var assert = require('assert');
-var dgram = require('dgram');
+const assert = require('assert');
+const dgram = require('dgram');
-var socket = dgram.createSocket('udp4');
+const socket = dgram.createSocket('udp4');
socket.bind();
-var fired = false;
-var timer = setTimeout(function() {
+let fired = false;
+const timer = setTimeout(function() {
socket.close();
}, 100);
diff --git a/test/parallel/test-dgram-oob-buffer.js b/test/parallel/test-dgram-oob-buffer.js
index ec5c0f943cb7df..5d869114b3a4e4 100644
--- a/test/parallel/test-dgram-oob-buffer.js
+++ b/test/parallel/test-dgram-oob-buffer.js
@@ -3,11 +3,11 @@
// unreachable host. This error can be reported by sendto() and even by
// recvfrom(). Node should not propagate this error to the user.
-var common = require('../common');
-var dgram = require('dgram');
+const common = require('../common');
+const dgram = require('dgram');
-var socket = dgram.createSocket('udp4');
-var buf = Buffer.from([1, 2, 3, 4]);
+const socket = dgram.createSocket('udp4');
+const buf = Buffer.from([1, 2, 3, 4]);
function ok() {}
socket.send(buf, 0, 0, common.PORT, '127.0.0.1', ok); // useful? no
diff --git a/test/parallel/test-dgram-regress-4496.js b/test/parallel/test-dgram-regress-4496.js
index 4bdd0d6520d7dc..b4ec8195d7e7f0 100644
--- a/test/parallel/test-dgram-regress-4496.js
+++ b/test/parallel/test-dgram-regress-4496.js
@@ -2,11 +2,11 @@
// Remove this test once we support sending strings.
require('../common');
-var assert = require('assert');
-var dgram = require('dgram');
+const assert = require('assert');
+const dgram = require('dgram');
// Should throw but not crash.
-var socket = dgram.createSocket('udp4');
+const socket = dgram.createSocket('udp4');
assert.throws(function() { socket.send(true, 0, 1, 1, 'host'); }, TypeError);
assert.throws(function() { socket.sendto(5, 0, 1, 1, 'host'); }, TypeError);
socket.close();
diff --git a/test/parallel/test-dgram-send-bad-arguments.js b/test/parallel/test-dgram-send-bad-arguments.js
index a3918697addc4e..c7ec6b51eecfa8 100644
--- a/test/parallel/test-dgram-send-bad-arguments.js
+++ b/test/parallel/test-dgram-send-bad-arguments.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
-var dgram = require('dgram');
+const assert = require('assert');
+const dgram = require('dgram');
-var buf = Buffer.from('test');
-var host = '127.0.0.1';
-var sock = dgram.createSocket('udp4');
+const buf = Buffer.from('test');
+const host = '127.0.0.1';
+const sock = dgram.createSocket('udp4');
assert.throws(function() {
sock.send();
diff --git a/test/parallel/test-dgram-send-empty-array.js b/test/parallel/test-dgram-send-empty-array.js
index 442803e6db8632..1bfcacd9a40497 100644
--- a/test/parallel/test-dgram-send-empty-array.js
+++ b/test/parallel/test-dgram-send-empty-array.js
@@ -12,7 +12,7 @@ const dgram = require('dgram');
const client = dgram.createSocket('udp4');
-var interval;
+let interval;
client.on('message', common.mustCall(function onMessage(buf, info) {
const expected = Buffer.alloc(0);
diff --git a/test/parallel/test-dgram-send-empty-buffer.js b/test/parallel/test-dgram-send-empty-buffer.js
index 70e7e46e0a327e..56a0383eb14c9e 100644
--- a/test/parallel/test-dgram-send-empty-buffer.js
+++ b/test/parallel/test-dgram-send-empty-buffer.js
@@ -21,7 +21,7 @@ client.bind(0, common.mustCall(function() {
}));
const buf = Buffer.alloc(0);
- var interval = setInterval(function() {
+ let interval = setInterval(function() {
client.send(buf, 0, 0, port, '127.0.0.1', common.mustCall(function() {}));
}, 10);
}));
diff --git a/test/parallel/test-dgram-unref.js b/test/parallel/test-dgram-unref.js
index 1b92428a38e18b..da148d3216582d 100644
--- a/test/parallel/test-dgram-unref.js
+++ b/test/parallel/test-dgram-unref.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common');
-var dgram = require('dgram');
+const dgram = require('dgram');
{
// Test the case of unref()'ing a socket with a handle.
diff --git a/test/parallel/test-dh-padding.js b/test/parallel/test-dh-padding.js
index a9cd95225abedb..72d54798d79da0 100644
--- a/test/parallel/test-dh-padding.js
+++ b/test/parallel/test-dh-padding.js
@@ -1,9 +1,10 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
+let crypto;
try {
- var crypto = require('crypto');
+ crypto = require('crypto');
} catch (e) {
common.skip('node compiled without OpenSSL.');
return;
@@ -25,13 +26,13 @@ try {
* crypto = require('crypto');
*
* for (;;) {
- * var a = crypto.getDiffieHellman('modp14'),
- * var b = crypto.getDiffieHellman('modp14');
+ * let a = crypto.getDiffieHellman('modp14'),
+ * let b = crypto.getDiffieHellman('modp14');
*
* a.generateKeys();
* b.generateKeys();
*
- * var aSecret = a.computeSecret(b.getPublicKey()).toString('hex');
+ * let aSecret = a.computeSecret(b.getPublicKey()).toString('hex');
* console.log("A public: " + a.getPublicKey().toString('hex'));
* console.log("A private: " + a.getPrivateKey().toString('hex'));
* console.log("B public: " + b.getPublicKey().toString('hex'));
@@ -45,7 +46,7 @@ try {
* }
*/
-var apub =
+const apub =
'5484455905d3eff34c70980e871f27f05448e66f5a6efbb97cbcba4e927196c2bd9ea272cded91\
10a4977afa8d9b16c9139a444ed2d954a794650e5d7cb525204f385e1af81530518563822ecd0f9\
524a958d02b3c269e79d6d69850f0968ad567a4404fbb0b19efc8bc73e267b6136b88cafb33299f\
@@ -53,7 +54,7 @@ f7c7cace3ffab1a88c2c9ee841f88b4c3679b4efc465f5c93cca11d487be57373e4c5926f634c4e\
efee6721d01db91cd66321615b2522f96368dbc818875d422140d0edf30bdb97d9721feddcb9ff6\
453741a4f687ee46fc54bf1198801f1210ac789879a5ee123f79e2d2ce1209df2445d32166bc9e4\
8f89e944ec9c3b2e16c8066cd8eebd4e33eb941';
-var bpub =
+const bpub =
'3fca64510e36bc7da8a3a901c7b74c2eabfa25deaf7cbe1d0c50235866136ad677317279e1fb0\
06e9c0a07f63e14a3363c8e016fbbde2b2c7e79fed1cc3e08e95f7459f547a8cd0523ee9dc744d\
e5a956d92b937db4448917e1f6829437f05e408ee7aea70c0362b37370c7c75d14449d8b2d2133\
@@ -61,7 +62,7 @@ e5a956d92b937db4448917e1f6829437f05e408ee7aea70c0362b37370c7c75d14449d8b2d2133\
788a1fdc6cdf17f5fffaf024ce8711a2ebde0b52e9f1cb56224483826d6e5ac6ecfaae07b75d20\
6e8ac97f5be1a5b68f20382f2a7dac189cf169325c4cf845b26a0cd616c31fec905c5d9035e5f7\
8e9880c812374ac0f3ca3d365f06e4be526b5affd4b79';
-var apriv =
+const apriv =
'62411e34704637d99c6c958a7db32ac22fcafafbe1c33d2cfdb76e12ded41f38fc16b792b9041\
2e4c82755a3815ba52f780f0ee296ad46e348fc4d1dcd6b64f4eea1b231b2b7d95c5b1c2e26d34\
83520558b9860a6eb668f01422a54e6604aa7702b4e67511397ef3ecb912bff1a83899c5a5bfb2\
@@ -69,7 +70,7 @@ var apriv =
08c3b3e6fc60668f7be81cce6784482af228dd7f489005253a165e292802cfd0399924f6c56827\
7012f68255207722355634290acc7fddeefbba75650a85ece95b6a12de67eac016ba78960108dd\
5dbadfaa43cc9fed515a1f307b7d90ae0623bc7b8cefb';
-var secret =
+const secret =
'00c37b1e06a436d6717816a40e6d72907a6f255638b93032267dcb9a5f0b4a9aa0236f3dce63b\
1c418c60978a00acd1617dfeecf1661d8a3fafb4d0d8824386750f4853313400e7e4afd22847e4\
fa56bc9713872021265111906673b38db83d10cbfa1dea3b6b4c97c8655f4ae82125281af7f234\
@@ -79,7 +80,7 @@ dc8fe984ddaf532fc1531ce43155fa0ab32532bf1ece5356b8a3447b5267798a904f16f3f4e635\
8612314311231f905f91c63a1aea52e0b60cead8b57df';
/* FIPS-friendly 2048 bit prime */
-var p = crypto.createDiffieHellman(
+const p = crypto.createDiffieHellman(
crypto.getDiffieHellman('modp14').getPrime());
p.setPublicKey(apub, 'hex');
diff --git a/test/parallel/test-domain-abort-on-uncaught.js b/test/parallel/test-domain-abort-on-uncaught.js
index d61debc06067f6..f754541f37462b 100644
--- a/test/parallel/test-domain-abort-on-uncaught.js
+++ b/test/parallel/test-domain-abort-on-uncaught.js
@@ -9,7 +9,7 @@ const assert = require('assert');
const domain = require('domain');
const child_process = require('child_process');
-var errorHandlerCalled = false;
+let errorHandlerCalled = false;
const tests = [
function nextTick() {
@@ -90,7 +90,7 @@ const tests = [
});
d.run(function() {
- var fs = require('fs');
+ const fs = require('fs');
fs.exists('/non/existing/file', function onExists(exists) {
throw new Error('boom!');
});
@@ -212,7 +212,7 @@ const tests = [
d.run(function() {
d2.run(function() {
- var fs = require('fs');
+ const fs = require('fs');
fs.exists('/non/existing/file', function onExists(exists) {
throw new Error('boom!');
});
@@ -232,7 +232,7 @@ if (process.argv[2] === 'child') {
} else {
tests.forEach(function(test, testIndex) {
- var testCmd = '';
+ let testCmd = '';
if (!common.isWindows) {
// Do not create core files, as it can take a lot of disk space on
// continuous testing and developers' machines
@@ -245,7 +245,7 @@ if (process.argv[2] === 'child') {
testCmd += ' ' + 'child';
testCmd += ' ' + testIndex;
- var child = child_process.exec(testCmd);
+ const child = child_process.exec(testCmd);
child.on('exit', function onExit(code, signal) {
assert.strictEqual(code, 0, 'Test at index ' + testIndex +
diff --git a/test/parallel/test-domain-crypto.js b/test/parallel/test-domain-crypto.js
index 1109591fee9631..dfa2636816aff4 100644
--- a/test/parallel/test-domain-crypto.js
+++ b/test/parallel/test-domain-crypto.js
@@ -2,8 +2,9 @@
const common = require('../common');
+let crypto;
try {
- var crypto = require('crypto');
+ crypto = require('crypto');
} catch (e) {
common.skip('node compiled without OpenSSL.');
return;
diff --git a/test/parallel/test-domain-enter-exit.js b/test/parallel/test-domain-enter-exit.js
index 2973e833f3a1b9..4a11c3a206a5fe 100644
--- a/test/parallel/test-domain-enter-exit.js
+++ b/test/parallel/test-domain-enter-exit.js
@@ -2,8 +2,8 @@
// Make sure the domain stack is a stack
require('../common');
-var assert = require('assert');
-var domain = require('domain');
+const assert = require('assert');
+const domain = require('domain');
function names(array) {
return array.map(function(d) {
@@ -11,11 +11,11 @@ function names(array) {
}).join(', ');
}
-var a = domain.create();
+const a = domain.create();
a.name = 'a';
-var b = domain.create();
+const b = domain.create();
b.name = 'b';
-var c = domain.create();
+const c = domain.create();
c.name = 'c';
a.enter(); // push
diff --git a/test/parallel/test-domain-exit-dispose-again.js b/test/parallel/test-domain-exit-dispose-again.js
index b1911bb40e0c93..542950f8af428e 100644
--- a/test/parallel/test-domain-exit-dispose-again.js
+++ b/test/parallel/test-domain-exit-dispose-again.js
@@ -6,22 +6,22 @@
// the same invocation of listOnTimeout, _are_ called.
require('../common');
-var assert = require('assert');
-var domain = require('domain');
-var disposalFailed = false;
+const assert = require('assert');
+const domain = require('domain');
+let disposalFailed = false;
// Repeatedly schedule a timer with a delay different than the timers attached
// to a domain that will eventually be disposed to make sure that they are
// called, regardless of what happens with those timers attached to domains
// that will eventually be disposed.
-var a = 0;
+let a = 0;
log();
function log() {
console.log(a++, process.domain);
if (a < 10) setTimeout(log, 20);
}
-var secondTimerRan = false;
+let secondTimerRan = false;
// Use the same timeout duration for both "firstTimer" and "secondTimer"
// callbacks so that they are called during the same invocation of the
diff --git a/test/parallel/test-domain-exit-dispose.js b/test/parallel/test-domain-exit-dispose.js
index 508cec18dccb7d..e1797cb660a0c0 100644
--- a/test/parallel/test-domain-exit-dispose.js
+++ b/test/parallel/test-domain-exit-dispose.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var common = require('../common');
-var assert = require('assert');
-var domain = require('domain');
+const common = require('../common');
+const assert = require('assert');
+const domain = require('domain');
// no matter what happens, we should increment a 10 times.
-var a = 0;
+let a = 0;
log();
function log() {
console.log(a++, process.domain);
@@ -15,7 +15,7 @@ function log() {
// in 50ms we'll throw an error.
setTimeout(err, 50);
function err() {
- var d = domain.create();
+ const d = domain.create();
d.on('error', handle);
d.run(err2);
diff --git a/test/parallel/test-domain-http-server.js b/test/parallel/test-domain-http-server.js
index 26264e8ec987d8..94bafe7f0e3d5e 100644
--- a/test/parallel/test-domain-http-server.js
+++ b/test/parallel/test-domain-http-server.js
@@ -1,17 +1,17 @@
'use strict';
require('../common');
-var domain = require('domain');
-var http = require('http');
-var assert = require('assert');
+const domain = require('domain');
+const http = require('http');
+const assert = require('assert');
-var objects = { foo: 'bar', baz: {}, num: 42, arr: [1, 2, 3] };
+const objects = { foo: 'bar', baz: {}, num: 42, arr: [1, 2, 3] };
objects.baz.asdf = objects;
-var serverCaught = 0;
-var clientCaught = 0;
+let serverCaught = 0;
+let clientCaught = 0;
-var server = http.createServer(function(req, res) {
- var dom = domain.create();
+const server = http.createServer(function(req, res) {
+ const dom = domain.create();
req.resume();
dom.add(req);
dom.add(res);
@@ -27,7 +27,7 @@ var server = http.createServer(function(req, res) {
dom.run(function() {
// Now, an action that has the potential to fail!
// if you request 'baz', then it'll throw a JSON circular ref error.
- var data = JSON.stringify(objects[req.url.replace(/[^a-z]/g, '')]);
+ const data = JSON.stringify(objects[req.url.replace(/[^a-z]/g, '')]);
// this line will throw if you pick an unknown key
assert.notStrictEqual(data, undefined, 'Data should not be undefined');
@@ -43,8 +43,8 @@ function next() {
const port = this.address().port;
console.log('listening on localhost:%d', port);
- var requests = 0;
- var responses = 0;
+ let requests = 0;
+ let responses = 0;
makeReq('/');
makeReq('/foo');
@@ -55,14 +55,14 @@ function next() {
function makeReq(p) {
requests++;
- var dom = domain.create();
+ const dom = domain.create();
dom.on('error', function(er) {
clientCaught++;
console.log('client error', er);
req.socket.destroy();
});
- var req = http.get({ host: 'localhost', port: port, path: p });
+ let req = http.get({ host: 'localhost', port: port, path: p });
dom.add(req);
req.on('response', function(res) {
responses++;
@@ -74,7 +74,7 @@ function next() {
}
dom.add(res);
- var d = '';
+ let d = '';
res.on('data', function(c) {
d += c;
});
diff --git a/test/parallel/test-domain-implicit-fs.js b/test/parallel/test-domain-implicit-fs.js
index a92653aff1de1c..8039e788312ec9 100644
--- a/test/parallel/test-domain-implicit-fs.js
+++ b/test/parallel/test-domain-implicit-fs.js
@@ -2,10 +2,10 @@
// Simple tests of most basic domain functionality.
const common = require('../common');
-var assert = require('assert');
-var domain = require('domain');
+const assert = require('assert');
+const domain = require('domain');
-var d = new domain.Domain();
+const d = new domain.Domain();
d.on('error', common.mustCall(function(er) {
console.error('caught', er);
@@ -28,7 +28,7 @@ d.on('error', common.mustCall(function(er) {
// handles are created.
d.run(function() {
setTimeout(function() {
- var fs = require('fs');
+ const fs = require('fs');
fs.readdir(__dirname, function() {
fs.open('this file does not exist', 'r', function(er) {
if (er) throw er;
diff --git a/test/parallel/test-domain-multi.js b/test/parallel/test-domain-multi.js
index e8c5d4924cb553..a38b6a2bc42bdf 100644
--- a/test/parallel/test-domain-multi.js
+++ b/test/parallel/test-domain-multi.js
@@ -5,14 +5,14 @@ const common = require('../common');
const domain = require('domain');
const http = require('http');
-var a = domain.create();
+const a = domain.create();
a.enter(); // this will be our "root" domain
a.on('error', common.fail);
const server = http.createServer((req, res) => {
// child domain of a.
- var b = domain.create();
+ const b = domain.create();
a.add(b);
// treat these EE objects as if they are a part of the b domain
diff --git a/test/parallel/test-domain-nested-throw.js b/test/parallel/test-domain-nested-throw.js
index 69a80b7ab104d0..39507446a3acfc 100644
--- a/test/parallel/test-domain-nested-throw.js
+++ b/test/parallel/test-domain-nested-throw.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var domain = require('domain');
+const domain = require('domain');
-var dispose;
+let dispose;
switch (process.argv[2]) {
case 'true':
dispose = true;
@@ -18,10 +18,10 @@ switch (process.argv[2]) {
}
function parent() {
- var node = process.execPath;
- var spawn = require('child_process').spawn;
- var opt = { stdio: 'inherit' };
- var child = spawn(node, [__filename, 'true'], opt);
+ const node = process.execPath;
+ const spawn = require('child_process').spawn;
+ const opt = { stdio: 'inherit' };
+ let child = spawn(node, [__filename, 'true'], opt);
child.on('exit', function(c) {
assert(!c);
child = spawn(node, [__filename, 'false'], opt);
@@ -32,11 +32,11 @@ function parent() {
});
}
-var gotDomain1Error = false;
-var gotDomain2Error = false;
+let gotDomain1Error = false;
+let gotDomain2Error = false;
-var threw1 = false;
-var threw2 = false;
+let threw1 = false;
+let threw2 = false;
function throw1() {
threw1 = true;
@@ -49,7 +49,7 @@ function throw2() {
}
function inner(throw1, throw2) {
- var domain1 = domain.createDomain();
+ const domain1 = domain.createDomain();
domain1.on('error', function(err) {
if (gotDomain1Error) {
@@ -67,7 +67,7 @@ function inner(throw1, throw2) {
}
function outer() {
- var domain2 = domain.createDomain();
+ const domain2 = domain.createDomain();
domain2.on('error', function(err) {
if (gotDomain2Error) {
diff --git a/test/parallel/test-domain-nested.js b/test/parallel/test-domain-nested.js
index 68c56d0c3c8b2c..d0618b5bad724b 100644
--- a/test/parallel/test-domain-nested.js
+++ b/test/parallel/test-domain-nested.js
@@ -2,8 +2,8 @@
// Make sure that the nested domains don't cause the domain stack to grow
require('../common');
-var assert = require('assert');
-var domain = require('domain');
+const assert = require('assert');
+const domain = require('domain');
process.on('exit', function(c) {
assert.equal(domain._stack.length, 0);
diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-5.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-5.js
index 78ef3662a20229..ade72147e148e7 100644
--- a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-5.js
+++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-5.js
@@ -7,7 +7,7 @@ function test() {
const d = domain.create();
d.run(function() {
- var fs = require('fs');
+ const fs = require('fs');
fs.exists('/non/existing/file', function onExists() {
throw new Error('boom!');
});
diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-9.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-9.js
index a4eebd50e96388..2e86a2125e86ee 100644
--- a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-9.js
+++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-9.js
@@ -12,7 +12,7 @@ function test() {
d.run(function() {
d2.run(function() {
- var fs = require('fs');
+ const fs = require('fs');
fs.exists('/non/existing/file', function onExists() {
throw new Error('boom!');
});
diff --git a/test/parallel/test-domain-safe-exit.js b/test/parallel/test-domain-safe-exit.js
index 399ae37bcd94c5..bbc3b2fe22cae8 100644
--- a/test/parallel/test-domain-safe-exit.js
+++ b/test/parallel/test-domain-safe-exit.js
@@ -2,11 +2,11 @@
// Make sure the domain stack doesn't get clobbered by un-matched .exit()
require('../common');
-var assert = require('assert');
-var domain = require('domain');
+const assert = require('assert');
+const domain = require('domain');
-var a = domain.create();
-var b = domain.create();
+const a = domain.create();
+const b = domain.create();
a.enter(); // push
b.enter(); // push
diff --git a/test/parallel/test-domain-stack.js b/test/parallel/test-domain-stack.js
index e30d3b21f3af57..43152a4a3bb1c9 100644
--- a/test/parallel/test-domain-stack.js
+++ b/test/parallel/test-domain-stack.js
@@ -2,9 +2,9 @@
// Make sure that the domain stack doesn't get out of hand.
require('../common');
-var domain = require('domain');
+const domain = require('domain');
-var a = domain.create();
+const a = domain.create();
a.name = 'a';
a.on('error', function() {
@@ -14,11 +14,11 @@ a.on('error', function() {
}
});
-var foo = a.bind(function() {
+const foo = a.bind(function() {
throw new Error('error from foo');
});
-for (var i = 0; i < 1000; i++) {
+for (let i = 0; i < 1000; i++) {
process.nextTick(foo);
}
diff --git a/test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js b/test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js
index 48c77bd2d490cc..135877ebae44ff 100644
--- a/test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js
+++ b/test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js
@@ -82,7 +82,7 @@ function runTestWithAbortOnUncaughtException() {
}
function createTestCmdLine(options) {
- var testCmd = '';
+ let testCmd = '';
if (!common.isWindows) {
// Do not create core files, as it can take a lot of disk space on
diff --git a/test/parallel/test-domain-timers.js b/test/parallel/test-domain-timers.js
index d42afa7471791a..7d51b61fd04be6 100644
--- a/test/parallel/test-domain-timers.js
+++ b/test/parallel/test-domain-timers.js
@@ -1,11 +1,11 @@
'use strict';
const common = require('../common');
-var domain = require('domain');
-var assert = require('assert');
+const domain = require('domain');
+const assert = require('assert');
-var timeout;
+let timeout;
-var timeoutd = domain.create();
+const timeoutd = domain.create();
timeoutd.on('error', common.mustCall(function(e) {
assert.strictEqual(e.message, 'Timeout UNREFd',
@@ -19,7 +19,7 @@ timeoutd.run(function() {
}, 0).unref();
});
-var immediated = domain.create();
+const immediated = domain.create();
immediated.on('error', common.mustCall(function(e) {
assert.strictEqual(e.message, 'Immediate Error',
diff --git a/test/parallel/test-domain-top-level-error-handler-throw.js b/test/parallel/test-domain-top-level-error-handler-throw.js
index b65b94012393c6..53a73eac426232 100644
--- a/test/parallel/test-domain-top-level-error-handler-throw.js
+++ b/test/parallel/test-domain-top-level-error-handler-throw.js
@@ -13,8 +13,8 @@ const domainErrHandlerExMessage = 'exception from domain error handler';
const internalExMessage = 'You should NOT see me';
if (process.argv[2] === 'child') {
- var domain = require('domain');
- var d = domain.create();
+ const domain = require('domain');
+ const d = domain.create();
d.on('error', function() {
throw new Error(domainErrHandlerExMessage);
@@ -26,11 +26,11 @@ if (process.argv[2] === 'child') {
});
});
} else {
- var fork = require('child_process').fork;
- var assert = require('assert');
+ const fork = require('child_process').fork;
+ const assert = require('assert');
- var child = fork(process.argv[1], ['child'], {silent: true});
- var stderrOutput = '';
+ const child = fork(process.argv[1], ['child'], {silent: true});
+ let stderrOutput = '';
if (child) {
child.stderr.on('data', function onStderrData(data) {
stderrOutput += data.toString();
@@ -45,8 +45,8 @@ if (process.argv[2] === 'child') {
});
child.on('exit', function onChildExited(exitCode, signal) {
- var expectedExitCode = 7;
- var expectedSignal = null;
+ const expectedExitCode = 7;
+ const expectedSignal = null;
assert.strictEqual(exitCode, expectedExitCode);
assert.strictEqual(signal, expectedSignal);
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 6fb3912e5b8d9c..0da8f1368f7c98 100644
--- a/test/parallel/test-domain-with-abort-on-uncaught-exception.js
+++ b/test/parallel/test-domain-with-abort-on-uncaught-exception.js
@@ -29,8 +29,8 @@ const fs = require('fs');
const domainErrHandlerExMessage = 'exception from domain error handler';
if (process.argv[2] === 'child') {
- var domain = require('domain');
- var d = domain.create();
+ const domain = require('domain');
+ const d = domain.create();
process.on('uncaughtException', function onUncaughtException() {
// The process' uncaughtException event must not be emitted when
@@ -80,7 +80,7 @@ if (process.argv[2] === 'child') {
throw new Error('Error from domain.run callback');
});
} else {
- var exec = require('child_process').exec;
+ const exec = require('child_process').exec;
function testDomainExceptionHandling(cmdLineOption, options) {
if (typeof cmdLineOption === 'object') {
@@ -88,18 +88,18 @@ if (process.argv[2] === 'child') {
cmdLineOption = undefined;
}
- var throwInDomainErrHandlerOpt;
+ let throwInDomainErrHandlerOpt;
if (options.throwInDomainErrHandler)
throwInDomainErrHandlerOpt = 'throwInDomainErrHandler';
- var cmdToExec = '';
+ let cmdToExec = '';
if (!common.isWindows) {
// Do not create core files, as it can take a lot of disk space on
// continuous testing and developers' machines
cmdToExec += 'ulimit -c 0 && ';
}
- var useTryCatchOpt;
+ let useTryCatchOpt;
if (options.useTryCatch)
useTryCatchOpt = 'useTryCatch';
@@ -112,7 +112,7 @@ if (process.argv[2] === 'child') {
useTryCatchOpt
].join(' ');
- var child = exec(cmdToExec);
+ const child = exec(cmdToExec);
if (child) {
child.on('exit', function onChildExited(exitCode, signal) {
diff --git a/test/parallel/test-domain.js b/test/parallel/test-domain.js
index 73ab3b96168930..fe51cc46820770 100644
--- a/test/parallel/test-domain.js
+++ b/test/parallel/test-domain.js
@@ -6,24 +6,24 @@ const assert = require('assert');
const domain = require('domain');
const events = require('events');
const fs = require('fs');
-var caught = 0;
-var expectCaught = 0;
+let caught = 0;
+let expectCaught = 0;
-var d = new domain.Domain();
-var e = new events.EventEmitter();
+const d = new domain.Domain();
+const e = new events.EventEmitter();
d.on('error', function(er) {
console.error('caught', er && (er.message || er));
- var er_message = er.message;
- var er_path = er.path;
+ let er_message = er.message;
+ let er_path = er.path;
// On windows, error messages can contain full path names. If this is the
// case, remove the directory part.
if (typeof er_path === 'string') {
- var slash = er_path.lastIndexOf('\\');
+ const slash = er_path.lastIndexOf('\\');
if (slash !== -1) {
- var dir = er_path.slice(0, slash + 1);
+ const dir = er_path.slice(0, slash + 1);
er_path = er_path.replace(dir, '');
er_message = er_message.replace(dir, '');
}
@@ -129,7 +129,7 @@ expectCaught++;
// set up while in the scope of the d domain.
d.run(function() {
process.nextTick(function() {
- var i = setInterval(function() {
+ const i = setInterval(function() {
clearInterval(i);
setTimeout(function() {
fs.stat('this file does not exist', function(er, stat) {
@@ -166,7 +166,7 @@ function fn() {
throw new Error('This function should never be called!');
}
-var bound = d.intercept(fn);
+let bound = d.intercept(fn);
bound(new Error('bound'));
expectCaught++;
@@ -210,7 +210,7 @@ expectCaught++;
// implicit addition by being created within a domain-bound context.
-var implicit;
+let implicit;
d.run(function() {
implicit = new events.EventEmitter();
@@ -223,7 +223,7 @@ setTimeout(function() {
expectCaught++;
-var result = d.run(function() {
+let result = d.run(function() {
return 'return value';
});
assert.strictEqual(result, 'return value');
@@ -236,12 +236,12 @@ result = d.run(function(a, b) {
assert.strictEqual(result, 'return value');
-var fst = fs.createReadStream('stream for nonexistent file');
+let fst = fs.createReadStream('stream for nonexistent file');
d.add(fst);
expectCaught++;
[42, null, , false, function() {}, 'string'].forEach(function(something) {
- var d = new domain.Domain();
+ const d = new domain.Domain();
d.run(function() {
process.nextTick(function() {
throw something;
diff --git a/test/parallel/test-dsa-fips-invalid-key.js b/test/parallel/test-dsa-fips-invalid-key.js
index ede3adab66c527..6055a9b4c47862 100644
--- a/test/parallel/test-dsa-fips-invalid-key.js
+++ b/test/parallel/test-dsa-fips-invalid-key.js
@@ -1,20 +1,20 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasFipsCrypto) {
common.skip('node compiled without FIPS OpenSSL.');
return;
}
-var crypto = require('crypto');
-var fs = require('fs');
+const crypto = require('crypto');
+const fs = require('fs');
-var input = 'hello';
+const input = 'hello';
-var dsapri = fs.readFileSync(common.fixturesDir +
+const dsapri = fs.readFileSync(common.fixturesDir +
'/keys/dsa_private_1025.pem');
-var sign = crypto.createSign('DSS1');
+const sign = crypto.createSign('DSS1');
sign.update(input);
assert.throws(function() {
diff --git a/test/parallel/test-error-reporting.js b/test/parallel/test-error-reporting.js
index 62525a5494d5a0..fa7332a67a482b 100644
--- a/test/parallel/test-error-reporting.js
+++ b/test/parallel/test-error-reporting.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var exec = require('child_process').exec;
-var path = require('path');
+const common = require('../common');
+const assert = require('assert');
+const exec = require('child_process').exec;
+const path = require('path');
function errExec(script, callback) {
- var cmd = '"' + process.argv[0] + '" "' +
- path.join(common.fixturesDir, script) + '"';
+ const cmd = '"' + process.argv[0] + '" "' +
+ path.join(common.fixturesDir, script) + '"';
return exec(cmd, function(err, stdout, stderr) {
// There was some error
assert.ok(err);
diff --git a/test/parallel/test-event-emitter-check-listener-leaks.js b/test/parallel/test-event-emitter-check-listener-leaks.js
index 1e357cd027d0f5..244bfa97bfa86a 100644
--- a/test/parallel/test-event-emitter-check-listener-leaks.js
+++ b/test/parallel/test-event-emitter-check-listener-leaks.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
-var events = require('events');
+const assert = require('assert');
+const events = require('events');
-var e = new events.EventEmitter();
+let e = new events.EventEmitter();
// default
for (let i = 0; i < 10; i++) {
diff --git a/test/parallel/test-event-emitter-errors.js b/test/parallel/test-event-emitter-errors.js
index 3effb999b37e8c..2b4a93ae9808df 100644
--- a/test/parallel/test-event-emitter-errors.js
+++ b/test/parallel/test-event-emitter-errors.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var EventEmitter = require('events');
-var assert = require('assert');
+const EventEmitter = require('events');
+const assert = require('assert');
-var EE = new EventEmitter();
+const EE = new EventEmitter();
assert.throws(function() {
EE.emit('error', 'Accepts a string');
diff --git a/test/parallel/test-event-emitter-get-max-listeners.js b/test/parallel/test-event-emitter-get-max-listeners.js
index 34ffee3600e5e9..9acc71fd7920e3 100644
--- a/test/parallel/test-event-emitter-get-max-listeners.js
+++ b/test/parallel/test-event-emitter-get-max-listeners.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
-var EventEmitter = require('events');
+const assert = require('assert');
+const EventEmitter = require('events');
-var emitter = new EventEmitter();
+const emitter = new EventEmitter();
assert.strictEqual(emitter.getMaxListeners(), EventEmitter.defaultMaxListeners);
@@ -14,6 +14,6 @@ emitter.setMaxListeners(3);
assert.strictEqual(emitter.getMaxListeners(), 3);
// https://github.com/nodejs/node/issues/523 - second call should not throw.
-var recv = {};
+const recv = {};
EventEmitter.prototype.on.call(recv, 'event', function() {});
EventEmitter.prototype.on.call(recv, 'event', function() {});
diff --git a/test/parallel/test-event-emitter-listeners-side-effects.js b/test/parallel/test-event-emitter-listeners-side-effects.js
index 906138af2367c3..022750da406500 100644
--- a/test/parallel/test-event-emitter-listeners-side-effects.js
+++ b/test/parallel/test-event-emitter-listeners-side-effects.js
@@ -1,12 +1,12 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var EventEmitter = require('events').EventEmitter;
+const EventEmitter = require('events').EventEmitter;
-var e = new EventEmitter();
-var fl; // foo listeners
+const e = new EventEmitter();
+let fl; // foo listeners
fl = e.listeners('foo');
assert(Array.isArray(fl));
diff --git a/test/parallel/test-event-emitter-method-names.js b/test/parallel/test-event-emitter-method-names.js
index e268e229b06b5b..d0464b80a44fe1 100644
--- a/test/parallel/test-event-emitter-method-names.js
+++ b/test/parallel/test-event-emitter-method-names.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
-var events = require('events');
+const assert = require('assert');
+const events = require('events');
-var E = events.EventEmitter.prototype;
+const E = events.EventEmitter.prototype;
assert.strictEqual(E.constructor.name, 'EventEmitter');
assert.strictEqual(E.on, E.addListener); // Same method.
Object.getOwnPropertyNames(E).forEach(function(name) {
diff --git a/test/parallel/test-event-emitter-no-error-provided-to-error-event.js b/test/parallel/test-event-emitter-no-error-provided-to-error-event.js
index 0a3ecb33d6e697..3e7242915e1854 100644
--- a/test/parallel/test-event-emitter-no-error-provided-to-error-event.js
+++ b/test/parallel/test-event-emitter-no-error-provided-to-error-event.js
@@ -1,11 +1,11 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var events = require('events');
-var domain = require('domain');
-var e = new events.EventEmitter();
+const assert = require('assert');
+const events = require('events');
+const domain = require('domain');
+const e = new events.EventEmitter();
-var d = domain.create();
+const d = domain.create();
d.add(e);
d.on('error', common.mustCall(function(er) {
assert(er instanceof Error, 'error created');
diff --git a/test/parallel/test-event-emitter-num-args.js b/test/parallel/test-event-emitter-num-args.js
index 31e57c89c8f23d..53ac0f79c20333 100644
--- a/test/parallel/test-event-emitter-num-args.js
+++ b/test/parallel/test-event-emitter-num-args.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var events = require('events');
+const assert = require('assert');
+const events = require('events');
const e = new events.EventEmitter();
const num_args_emitted = [];
diff --git a/test/parallel/test-event-emitter-once.js b/test/parallel/test-event-emitter-once.js
index cca21a454b43bc..724b2ffd16aad1 100644
--- a/test/parallel/test-event-emitter-once.js
+++ b/test/parallel/test-event-emitter-once.js
@@ -12,7 +12,7 @@ e.emit('hello', 'a', 'b');
e.emit('hello', 'a', 'b');
e.emit('hello', 'a', 'b');
-var remove = function() {
+const remove = function() {
common.fail('once->foo should not be emitted');
};
diff --git a/test/parallel/test-event-emitter-prepend.js b/test/parallel/test-event-emitter-prepend.js
index aa755a723c583e..5a3b66b0cb3250 100644
--- a/test/parallel/test-event-emitter-prepend.js
+++ b/test/parallel/test-event-emitter-prepend.js
@@ -5,7 +5,7 @@ const EventEmitter = require('events');
const assert = require('assert');
const myEE = new EventEmitter();
-var m = 0;
+let m = 0;
// This one comes last.
myEE.on('foo', common.mustCall(() => assert.equal(m, 2)));
diff --git a/test/parallel/test-event-emitter-remove-all-listeners.js b/test/parallel/test-event-emitter-remove-all-listeners.js
index 1970904df25a75..9cf08369f82986 100644
--- a/test/parallel/test-event-emitter-remove-all-listeners.js
+++ b/test/parallel/test-event-emitter-remove-all-listeners.js
@@ -66,7 +66,7 @@ function listener() {}
{
const ee = new events.EventEmitter();
- var expectLength = 2;
+ let expectLength = 2;
ee.on('removeListener', function(name, listener) {
assert.strictEqual(expectLength--, this.listeners('baz').length);
});
diff --git a/test/parallel/test-event-emitter-set-max-listeners-side-effects.js b/test/parallel/test-event-emitter-set-max-listeners-side-effects.js
index cadaf3adc36014..5235d05638441b 100644
--- a/test/parallel/test-event-emitter-set-max-listeners-side-effects.js
+++ b/test/parallel/test-event-emitter-set-max-listeners-side-effects.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
-var events = require('events');
+const assert = require('assert');
+const events = require('events');
-var e = new events.EventEmitter();
+const e = new events.EventEmitter();
assert(!(e._events instanceof Object));
assert.deepStrictEqual(Object.keys(e._events), []);
diff --git a/test/parallel/test-event-emitter-subclass.js b/test/parallel/test-event-emitter-subclass.js
index d2651defeeaa23..d35802b413136b 100644
--- a/test/parallel/test-event-emitter-subclass.js
+++ b/test/parallel/test-event-emitter-subclass.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var EventEmitter = require('events').EventEmitter;
-var util = require('util');
+const assert = require('assert');
+const EventEmitter = require('events').EventEmitter;
+const util = require('util');
util.inherits(MyEE, EventEmitter);
@@ -13,7 +13,7 @@ function MyEE(cb) {
EventEmitter.call(this);
}
-var myee = new MyEE(common.mustCall(function() {}));
+const myee = new MyEE(common.mustCall(function() {}));
util.inherits(ErrorEE, EventEmitter);
@@ -38,8 +38,8 @@ function MyEE2() {
MyEE2.prototype = new EventEmitter();
-var ee1 = new MyEE2();
-var ee2 = new MyEE2();
+const ee1 = new MyEE2();
+const ee2 = new MyEE2();
ee1.on('x', function() {});
diff --git a/test/parallel/test-exception-handler.js b/test/parallel/test-exception-handler.js
index e0e1b0086d9a7f..506fbaed0ebf63 100644
--- a/test/parallel/test-exception-handler.js
+++ b/test/parallel/test-exception-handler.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var MESSAGE = 'catch me if you can';
+const MESSAGE = 'catch me if you can';
process.on('uncaughtException', common.mustCall(function(e) {
console.log('uncaught exception! 1');
diff --git a/test/parallel/test-file-write-stream2.js b/test/parallel/test-file-write-stream2.js
index 77e8119d25b8a7..504a572dde67d7 100644
--- a/test/parallel/test-file-write-stream2.js
+++ b/test/parallel/test-file-write-stream2.js
@@ -7,14 +7,13 @@ const fs = require('fs');
const filepath = path.join(common.tmpDir, 'write.txt');
-var file;
const EXPECTED = '012345678910';
const cb_expected = 'write open drain write drain close error ';
-var cb_occurred = '';
+let cb_occurred = '';
-var countDrains = 0;
+let countDrains = 0;
process.on('exit', function() {
@@ -41,7 +40,7 @@ function removeTestFile() {
common.refreshTmpDir();
// drain at 0, return false at 10.
-file = fs.createWriteStream(filepath, {
+const file = fs.createWriteStream(filepath, {
highWaterMark: 11
});
@@ -80,7 +79,7 @@ file.on('error', function(err) {
});
-for (var i = 0; i < 11; i++) {
+for (let i = 0; i < 11; i++) {
const ret = file.write(i + '');
console.error('%d %j', i, ret);
diff --git a/test/parallel/test-force-repl-with-eval.js b/test/parallel/test-force-repl-with-eval.js
index e5044ba59df4d5..8c75818508d17e 100644
--- a/test/parallel/test-force-repl-with-eval.js
+++ b/test/parallel/test-force-repl-with-eval.js
@@ -5,11 +5,11 @@ const spawn = require('child_process').spawn;
// spawn a node child process in "interactive" mode (force the repl) and eval
const cp = spawn(process.execPath, ['-i', '-e', 'console.log("42")']);
-var gotToEnd = false;
+let gotToEnd = false;
cp.stdout.setEncoding('utf8');
-var output = '';
+let output = '';
cp.stdout.on('data', function(b) {
output += b;
if (output === '> 42\n') {
diff --git a/test/parallel/test-force-repl.js b/test/parallel/test-force-repl.js
index 37f2f603342a1c..5507d7401b72d3 100644
--- a/test/parallel/test-force-repl.js
+++ b/test/parallel/test-force-repl.js
@@ -5,7 +5,7 @@ const spawn = require('child_process').spawn;
// spawn a node child process in "interactive" mode (force the repl)
const cp = spawn(process.execPath, ['-i']);
-var timeoutId = setTimeout(function() {
+const timeoutId = setTimeout(function() {
common.fail('timeout!');
}, common.platformTimeout(5000)); // give node + the repl 5 seconds to start
diff --git a/test/parallel/test-freelist.js b/test/parallel/test-freelist.js
index 65758bd7114de8..8ec7134dad0eb5 100644
--- a/test/parallel/test-freelist.js
+++ b/test/parallel/test-freelist.js
@@ -12,7 +12,7 @@ assert.strictEqual(typeof freelist.FreeList, 'function');
const flist1 = new freelist.FreeList('flist1', 3, String);
// Allocating when empty, should not change the list size
-var result = flist1.alloc('test');
+const result = flist1.alloc('test');
assert.strictEqual(typeof result, 'string');
assert.strictEqual(result, 'test');
assert.strictEqual(flist1.list.length, 0);
diff --git a/test/parallel/test-fs-access.js b/test/parallel/test-fs-access.js
index 6da26fe47beb92..ad4023ea74ac83 100644
--- a/test/parallel/test-fs-access.js
+++ b/test/parallel/test-fs-access.js
@@ -1,13 +1,13 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
-var path = require('path');
-var doesNotExist = path.join(common.tmpDir, '__this_should_not_exist');
-var readOnlyFile = path.join(common.tmpDir, 'read_only_file');
-var readWriteFile = path.join(common.tmpDir, 'read_write_file');
-
-var removeFile = function(file) {
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
+const path = require('path');
+const doesNotExist = path.join(common.tmpDir, '__this_should_not_exist');
+const readOnlyFile = path.join(common.tmpDir, 'read_only_file');
+const readWriteFile = path.join(common.tmpDir, 'read_write_file');
+
+const removeFile = function(file) {
try {
fs.unlinkSync(file);
} catch (err) {
@@ -15,7 +15,7 @@ var removeFile = function(file) {
}
};
-var createFileWithPerms = function(file, mode) {
+const createFileWithPerms = function(file, mode) {
removeFile(file);
fs.writeFileSync(file, '');
fs.chmodSync(file, mode);
@@ -48,7 +48,7 @@ createFileWithPerms(readWriteFile, 0o666);
* id, but that's fine. In this case, it is the responsability of the
* continuous integration platform to take care of that.
*/
-var hasWriteAccessForReadonlyFile = false;
+let hasWriteAccessForReadonlyFile = false;
if (!common.isWindows && process.getuid() === 0) {
hasWriteAccessForReadonlyFile = true;
try {
@@ -107,7 +107,7 @@ assert.doesNotThrow(function() {
});
assert.doesNotThrow(function() {
- var mode = fs.F_OK | fs.R_OK | fs.W_OK;
+ const mode = fs.F_OK | fs.R_OK | fs.W_OK;
fs.accessSync(readWriteFile, mode);
});
diff --git a/test/parallel/test-fs-chmod.js b/test/parallel/test-fs-chmod.js
index 2e5d839ae97720..5121fd89f99466 100644
--- a/test/parallel/test-fs-chmod.js
+++ b/test/parallel/test-fs-chmod.js
@@ -99,7 +99,7 @@ fs.open(file2, 'a', common.mustCall((err, fd) => {
// lchmod
if (fs.lchmod) {
- var link = path.join(common.tmpDir, 'symbolic-link');
+ const link = path.join(common.tmpDir, 'symbolic-link');
common.refreshTmpDir();
fs.symlinkSync(file2, link);
diff --git a/test/parallel/test-fs-exists.js b/test/parallel/test-fs-exists.js
index 83e6adaf1100f7..14e1446f5a6d3d 100644
--- a/test/parallel/test-fs-exists.js
+++ b/test/parallel/test-fs-exists.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
-var f = __filename;
+const assert = require('assert');
+const fs = require('fs');
+const f = __filename;
fs.exists(f, common.mustCall(function(y) {
assert.strictEqual(y, true);
diff --git a/test/parallel/test-fs-long-path.js b/test/parallel/test-fs-long-path.js
index 64585467ed6a77..7082e740ed47c9 100644
--- a/test/parallel/test-fs-long-path.js
+++ b/test/parallel/test-fs-long-path.js
@@ -1,7 +1,7 @@
'use strict';
-var common = require('../common');
-var fs = require('fs');
-var path = require('path');
+const common = require('../common');
+const fs = require('fs');
+const path = require('path');
if (!common.isWindows) {
common.skip('this test is Windows-specific.');
@@ -9,9 +9,9 @@ if (!common.isWindows) {
}
// make a path that will be at least 260 chars long.
-var fileNameLen = Math.max(260 - common.tmpDir.length - 1, 1);
-var fileName = path.join(common.tmpDir, new Array(fileNameLen + 1).join('x'));
-var fullPath = path.resolve(fileName);
+const fileNameLen = Math.max(260 - common.tmpDir.length - 1, 1);
+const fileName = path.join(common.tmpDir, new Array(fileNameLen + 1).join('x'));
+const fullPath = path.resolve(fileName);
common.refreshTmpDir();
diff --git a/test/parallel/test-fs-make-callback.js b/test/parallel/test-fs-make-callback.js
index 4fbe64437eaff0..2dc9874a546574 100644
--- a/test/parallel/test-fs-make-callback.js
+++ b/test/parallel/test-fs-make-callback.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var fs = require('fs');
+const assert = require('assert');
+const fs = require('fs');
function test(cb) {
return function() {
diff --git a/test/parallel/test-fs-mkdir.js b/test/parallel/test-fs-mkdir.js
index 2b8e8b8f026637..620231102273e3 100644
--- a/test/parallel/test-fs-mkdir.js
+++ b/test/parallel/test-fs-mkdir.js
@@ -1,7 +1,7 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
function unlink(pathname) {
try {
diff --git a/test/parallel/test-fs-null-bytes.js b/test/parallel/test-fs-null-bytes.js
index e04aa1cb76cb6f..fa29e64c9b2382 100644
--- a/test/parallel/test-fs-null-bytes.js
+++ b/test/parallel/test-fs-null-bytes.js
@@ -1,7 +1,7 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
function check(async, sync) {
const expected = /Path must be a string without null bytes/;
diff --git a/test/parallel/test-fs-open-flags.js b/test/parallel/test-fs-open-flags.js
index d212130bc903d1..f07da13569b56a 100644
--- a/test/parallel/test-fs-open-flags.js
+++ b/test/parallel/test-fs-open-flags.js
@@ -1,16 +1,16 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var fs = require('fs');
+const fs = require('fs');
-var O_APPEND = fs.constants.O_APPEND || 0;
-var O_CREAT = fs.constants.O_CREAT || 0;
-var O_EXCL = fs.constants.O_EXCL || 0;
-var O_RDONLY = fs.constants.O_RDONLY || 0;
-var O_RDWR = fs.constants.O_RDWR || 0;
-var O_TRUNC = fs.constants.O_TRUNC || 0;
-var O_WRONLY = fs.constants.O_WRONLY || 0;
+const O_APPEND = fs.constants.O_APPEND || 0;
+const O_CREAT = fs.constants.O_CREAT || 0;
+const O_EXCL = fs.constants.O_EXCL || 0;
+const O_RDONLY = fs.constants.O_RDONLY || 0;
+const O_RDWR = fs.constants.O_RDWR || 0;
+const O_TRUNC = fs.constants.O_TRUNC || 0;
+const O_WRONLY = fs.constants.O_WRONLY || 0;
assert.equal(fs._stringToFlags('r'), O_RDONLY);
assert.equal(fs._stringToFlags('r+'), O_RDWR);
diff --git a/test/parallel/test-fs-read-buffer-tostring-fail.js b/test/parallel/test-fs-read-buffer-tostring-fail.js
index cce33edf4e6947..3ef058e4aa031e 100644
--- a/test/parallel/test-fs-read-buffer-tostring-fail.js
+++ b/test/parallel/test-fs-read-buffer-tostring-fail.js
@@ -14,7 +14,7 @@ const path = require('path');
const Buffer = require('buffer').Buffer;
const kStringMaxLength = process.binding('buffer').kStringMaxLength;
-var fd;
+let fd;
common.refreshTmpDir();
@@ -26,7 +26,7 @@ const stream = fs.createWriteStream(file, {
const size = kStringMaxLength / 200;
const a = Buffer.alloc(size, 'a');
-for (var i = 0; i < 201; i++) {
+for (let i = 0; i < 201; i++) {
stream.write(a);
}
diff --git a/test/parallel/test-fs-read-buffer.js b/test/parallel/test-fs-read-buffer.js
index 32f52b13cc7594..cc1d1052351849 100644
--- a/test/parallel/test-fs-read-buffer.js
+++ b/test/parallel/test-fs-read-buffer.js
@@ -20,6 +20,6 @@ fs.read(fd,
assert.deepStrictEqual(bufferAsync, Buffer.from(expected));
}));
-var r = fs.readSync(fd, bufferSync, 0, expected.length, 0);
+const r = fs.readSync(fd, bufferSync, 0, expected.length, 0);
assert.deepStrictEqual(bufferSync, Buffer.from(expected));
assert.equal(r, expected.length);
diff --git a/test/parallel/test-fs-read-stream-fd-leak.js b/test/parallel/test-fs-read-stream-fd-leak.js
index 45847270097348..0a7a42a3bab3c1 100644
--- a/test/parallel/test-fs-read-stream-fd-leak.js
+++ b/test/parallel/test-fs-read-stream-fd-leak.js
@@ -5,7 +5,7 @@ const assert = require('assert');
const fs = require('fs');
const path = require('path');
-var openCount = 0;
+let openCount = 0;
const _fsopen = fs.open;
const _fsclose = fs.close;
@@ -26,8 +26,8 @@ fs.close = function() {
function testLeak(endFn, callback) {
console.log('testing for leaks from fs.createReadStream().%s()...', endFn);
- var i = 0;
- var check = 0;
+ let i = 0;
+ let check = 0;
const checkFunction = function() {
if (openCount !== 0 && check < totalCheck) {
diff --git a/test/parallel/test-fs-read-stream-fd.js b/test/parallel/test-fs-read-stream-fd.js
index 5af5200e30eb68..93b93085159ac6 100644
--- a/test/parallel/test-fs-read-stream-fd.js
+++ b/test/parallel/test-fs-read-stream-fd.js
@@ -1,18 +1,17 @@
'use strict';
const common = require('../common');
-var fs = require('fs');
-var assert = require('assert');
-var path = require('path');
-var file = path.join(common.tmpDir, '/read_stream_fd_test.txt');
-var input = 'hello world';
-var output = '';
-var fd, stream;
+const fs = require('fs');
+const assert = require('assert');
+const path = require('path');
+const file = path.join(common.tmpDir, '/read_stream_fd_test.txt');
+const input = 'hello world';
+let output = '';
common.refreshTmpDir();
fs.writeFileSync(file, input);
-fd = fs.openSync(file, 'r');
+const fd = fs.openSync(file, 'r');
-stream = fs.createReadStream(null, { fd: fd, encoding: 'utf8' });
+const stream = fs.createReadStream(null, { fd: fd, encoding: 'utf8' });
stream.on('data', function(data) {
output += data;
});
diff --git a/test/parallel/test-fs-read-stream-resume.js b/test/parallel/test-fs-read-stream-resume.js
index 3ff89644e5c018..6c8b2c2421c8e3 100644
--- a/test/parallel/test-fs-read-stream-resume.js
+++ b/test/parallel/test-fs-read-stream-resume.js
@@ -9,7 +9,7 @@ const file = path.join(common.fixturesDir, 'x.txt');
let data = '';
let first = true;
-var stream = fs.createReadStream(file);
+const stream = fs.createReadStream(file);
stream.setEncoding('utf8');
stream.on('data', function(chunk) {
data += chunk;
diff --git a/test/parallel/test-fs-read-stream.js b/test/parallel/test-fs-read-stream.js
index c8da0275c53c9b..d4fad6e6f79c07 100644
--- a/test/parallel/test-fs-read-stream.js
+++ b/test/parallel/test-fs-read-stream.js
@@ -7,13 +7,13 @@ const fs = require('fs');
const fn = path.join(common.fixturesDir, 'elipses.txt');
const rangeFile = path.join(common.fixturesDir, 'x.txt');
-var callbacks = { open: 0, end: 0, close: 0 };
+const callbacks = { open: 0, end: 0, close: 0 };
-var paused = false;
-var bytesRead = 0;
+let paused = false;
+let bytesRead = 0;
-var file = fs.ReadStream(fn);
-var fileSize = fs.statSync(fn).size;
+const file = fs.ReadStream(fn);
+const fileSize = fs.statSync(fn).size;
assert.strictEqual(file.bytesRead, 0);
@@ -64,13 +64,13 @@ file.on('close', function() {
//assert.equal(fs.readFileSync(fn), fileContent);
});
-var file3 = fs.createReadStream(fn, {encoding: 'utf8'});
+const file3 = fs.createReadStream(fn, {encoding: 'utf8'});
file3.length = 0;
file3.on('data', function(data) {
assert.strictEqual('string', typeof data);
file3.length += data.length;
- for (var i = 0; i < data.length; i++) {
+ for (let i = 0; i < data.length; i++) {
// http://www.fileformat.info/info/unicode/char/2026/index.htm
assert.strictEqual('\u2026', data[i]);
}
@@ -89,8 +89,8 @@ process.on('exit', function() {
console.error('ok');
});
-var file4 = fs.createReadStream(rangeFile, {bufferSize: 1, start: 1, end: 2});
-var contentRead = '';
+const file4 = fs.createReadStream(rangeFile, {bufferSize: 1, start: 1, end: 2});
+let contentRead = '';
file4.on('data', function(data) {
contentRead += data.toString('utf-8');
});
@@ -98,7 +98,7 @@ file4.on('end', function(data) {
assert.strictEqual(contentRead, 'yz');
});
-var file5 = fs.createReadStream(rangeFile, {bufferSize: 1, start: 1});
+const file5 = fs.createReadStream(rangeFile, {bufferSize: 1, start: 1});
file5.data = '';
file5.on('data', function(data) {
file5.data += data.toString('utf-8');
@@ -108,7 +108,7 @@ file5.on('end', function() {
});
// https://github.com/joyent/node/issues/2320
-var file6 = fs.createReadStream(rangeFile, {bufferSize: 1.23, start: 1});
+const file6 = fs.createReadStream(rangeFile, {bufferSize: 1.23, start: 1});
file6.data = '';
file6.on('data', function(data) {
file6.data += data.toString('utf-8');
@@ -121,7 +121,7 @@ assert.throws(function() {
fs.createReadStream(rangeFile, {start: 10, end: 2});
}, /"start" option must be <= "end" option/);
-var stream = fs.createReadStream(rangeFile, { start: 0, end: 0 });
+const stream = fs.createReadStream(rangeFile, { start: 0, end: 0 });
stream.data = '';
stream.on('data', function(chunk) {
@@ -133,11 +133,11 @@ stream.on('end', function() {
});
// pause and then resume immediately.
-var pauseRes = fs.createReadStream(rangeFile);
+const pauseRes = fs.createReadStream(rangeFile);
pauseRes.pause();
pauseRes.resume();
-var file7 = fs.createReadStream(rangeFile, {autoClose: false });
+let file7 = fs.createReadStream(rangeFile, {autoClose: false });
file7.on('data', function() {});
file7.on('end', function() {
process.nextTick(function() {
@@ -160,12 +160,12 @@ function file7Next() {
}
// Just to make sure autoClose won't close the stream because of error.
-var file8 = fs.createReadStream(null, {fd: 13337, autoClose: false });
+const file8 = fs.createReadStream(null, {fd: 13337, autoClose: false });
file8.on('data', function() {});
file8.on('error', common.mustCall(function() {}));
// Make sure stream is destroyed when file does not exist.
-var file9 = fs.createReadStream('/path/to/file/that/does/not/exist');
+const file9 = fs.createReadStream('/path/to/file/that/does/not/exist');
file9.on('data', function() {});
file9.on('error', common.mustCall(function() {}));
diff --git a/test/parallel/test-fs-read.js b/test/parallel/test-fs-read.js
index 41957c228ea944..06755c0d6e050f 100644
--- a/test/parallel/test-fs-read.js
+++ b/test/parallel/test-fs-read.js
@@ -17,6 +17,6 @@ fs.read(fd,
assert.strictEqual(bytesRead, expected.length);
}));
-var r = fs.readSync(fd, expected.length, 0, 'utf-8');
+const r = fs.readSync(fd, expected.length, 0, 'utf-8');
assert.strictEqual(r[0], expected);
assert.strictEqual(r[1], expected.length);
diff --git a/test/parallel/test-fs-readfile-fd.js b/test/parallel/test-fs-readfile-fd.js
index 6420dbfdd004e5..47eeccf0a31b87 100644
--- a/test/parallel/test-fs-readfile-fd.js
+++ b/test/parallel/test-fs-readfile-fd.js
@@ -40,7 +40,7 @@ function tempFd(callback) {
}
function tempFdSync(callback) {
- var fd = fs.openSync(fn, 'r');
+ const fd = fs.openSync(fn, 'r');
callback(fd);
fs.closeSync(fd);
}
diff --git a/test/parallel/test-fs-readfile-zero-byte-liar.js b/test/parallel/test-fs-readfile-zero-byte-liar.js
index c3887979bb0b4a..82037a77e62122 100644
--- a/test/parallel/test-fs-readfile-zero-byte-liar.js
+++ b/test/parallel/test-fs-readfile-zero-byte-liar.js
@@ -1,7 +1,7 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
+const assert = require('assert');
+const fs = require('fs');
const dataExpected = fs.readFileSync(__filename, 'utf8');
diff --git a/test/parallel/test-fs-realpath-buffer-encoding.js b/test/parallel/test-fs-realpath-buffer-encoding.js
index 78ec02549bbd27..54054bb479f8d4 100644
--- a/test/parallel/test-fs-realpath-buffer-encoding.js
+++ b/test/parallel/test-fs-realpath-buffer-encoding.js
@@ -8,14 +8,15 @@ const buffer_dir = Buffer.from(string_dir);
const encodings = ['ascii', 'utf8', 'utf16le', 'ucs2',
'base64', 'binary', 'hex'];
-var expected = {};
+const expected = {};
encodings.forEach((encoding) => {
expected[encoding] = buffer_dir.toString(encoding);
});
// test sync version
-for (var encoding in expected) {
+let encoding;
+for (encoding in expected) {
const expected_value = expected[encoding];
let result;
diff --git a/test/parallel/test-fs-realpath-on-substed-drive.js b/test/parallel/test-fs-realpath-on-substed-drive.js
index c9109362691845..a5c542162c3b65 100644
--- a/test/parallel/test-fs-realpath-on-substed-drive.js
+++ b/test/parallel/test-fs-realpath-on-substed-drive.js
@@ -14,7 +14,8 @@ let result;
// create a subst drive
const driveLetters = 'ABCDEFGHIJKLMNOPQRSTUWXYZ';
let drive;
-for (var i = 0; i < driveLetters.length; ++i) {
+let i;
+for (i = 0; i < driveLetters.length; ++i) {
drive = `${driveLetters[i]}:`;
result = spawnSync('subst', [drive, common.fixturesDir]);
if (result.status === 0)
diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js
index adc8459a3eca46..54c509d55e1fed 100644
--- a/test/parallel/test-fs-realpath.js
+++ b/test/parallel/test-fs-realpath.js
@@ -4,13 +4,14 @@ const assert = require('assert');
const fs = require('fs');
const path = require('path');
const exec = require('child_process').exec;
-var async_completed = 0, async_expected = 0, unlink = [];
-var skipSymlinks = false;
+let async_completed = 0, async_expected = 0;
+const unlink = [];
+let skipSymlinks = false;
common.refreshTmpDir();
-var root = '/';
-var assertEqualPath = assert.strictEqual;
+let root = '/';
+let assertEqualPath = assert.strictEqual;
if (common.isWindows) {
// something like "C:\\"
root = process.cwd().substr(0, 3);
@@ -54,7 +55,7 @@ fs.mkdirSync(path.join(targetsAbsDir, 'nested-index', 'two'));
function asynctest(testBlock, args, callback, assertBlock) {
async_expected++;
testBlock.apply(testBlock, args.concat(function(err) {
- var ignoreError = false;
+ let ignoreError = false;
if (assertBlock) {
try {
ignoreError = assertBlock.apply(assertBlock, arguments);
@@ -216,7 +217,7 @@ function test_cyclic_link_overprotection(callback) {
const expected = fs.realpathSync(cycles);
const folder = cycles + '/folder';
const link = folder + '/cycles';
- var testPath = cycles;
+ let testPath = cycles;
testPath += '/folder/cycles'.repeat(10);
try { fs.unlinkSync(link); } catch (ex) {}
fs.symlinkSync(cycles, link, 'dir');
@@ -474,7 +475,7 @@ const tests = [
test_up_multiple
];
const numtests = tests.length;
-var testsRun = 0;
+let testsRun = 0;
function runNextTest(err) {
if (err) throw err;
const test = tests.shift();
diff --git a/test/parallel/test-fs-sir-writes-alot.js b/test/parallel/test-fs-sir-writes-alot.js
index 8e1385ed4da2a0..dab1cb2447c46a 100644
--- a/test/parallel/test-fs-sir-writes-alot.js
+++ b/test/parallel/test-fs-sir-writes-alot.js
@@ -1,36 +1,37 @@
'use strict';
-var common = require('../common');
-var fs = require('fs');
-var assert = require('assert');
-var join = require('path').join;
+const common = require('../common');
+const fs = require('fs');
+const assert = require('assert');
+const join = require('path').join;
-var filename = join(common.tmpDir, 'out.txt');
+const filename = join(common.tmpDir, 'out.txt');
common.refreshTmpDir();
-var fd = fs.openSync(filename, 'w');
+const fd = fs.openSync(filename, 'w');
-var line = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa\n';
+const line = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa\n';
-var N = 10240, complete = 0;
-for (var i = 0; i < N; i++) {
+const N = 10240;
+let complete = 0;
+for (let i = 0; i < N; i++) {
// Create a new buffer for each write. Before the write is actually
// executed by the thread pool, the buffer will be collected.
- var buffer = Buffer.from(line);
+ const buffer = Buffer.from(line);
fs.write(fd, buffer, 0, buffer.length, null, function(er, written) {
complete++;
if (complete === N) {
fs.closeSync(fd);
- var s = fs.createReadStream(filename);
+ const s = fs.createReadStream(filename);
s.on('data', testBuffer);
}
});
}
-var bytesChecked = 0;
+let bytesChecked = 0;
function testBuffer(b) {
- for (var i = 0; i < b.length; i++) {
+ for (let i = 0; i < b.length; i++) {
bytesChecked++;
if (b[i] !== 'a'.charCodeAt(0) && b[i] !== '\n'.charCodeAt(0)) {
throw new Error('invalid char ' + i + ',' + b[i]);
diff --git a/test/parallel/test-fs-stat.js b/test/parallel/test-fs-stat.js
index 2c844452f05540..32ba47c2fe0c1e 100644
--- a/test/parallel/test-fs-stat.js
+++ b/test/parallel/test-fs-stat.js
@@ -1,7 +1,7 @@
/* eslint-disable strict */
const common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
+const assert = require('assert');
+const fs = require('fs');
fs.stat('.', common.mustCall(function(err, stats) {
assert.ifError(err);
@@ -37,7 +37,7 @@ fs.open('.', 'r', undefined, common.mustCall(function(err, fd) {
// fstatSync
fs.open('.', 'r', undefined, common.mustCall(function(err, fd) {
- var stats;
+ let stats;
try {
stats = fs.fstatSync(fd);
} catch (err) {
diff --git a/test/parallel/test-fs-stream-double-close.js b/test/parallel/test-fs-stream-double-close.js
index df5010293729a3..ae6429a62b4f3c 100644
--- a/test/parallel/test-fs-stream-double-close.js
+++ b/test/parallel/test-fs-stream-double-close.js
@@ -1,6 +1,6 @@
'use strict';
-var common = require('../common');
-var fs = require('fs');
+const common = require('../common');
+const fs = require('fs');
common.refreshTmpDir();
diff --git a/test/parallel/test-fs-symlink-dir-junction-relative.js b/test/parallel/test-fs-symlink-dir-junction-relative.js
index d4e32c4b7eeb5a..9244dd20b4349c 100644
--- a/test/parallel/test-fs-symlink-dir-junction-relative.js
+++ b/test/parallel/test-fs-symlink-dir-junction-relative.js
@@ -1,15 +1,15 @@
'use strict';
// Test creating and resolving relative junction or symbolic link
-var common = require('../common');
-var assert = require('assert');
-var path = require('path');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const path = require('path');
+const fs = require('fs');
-var linkPath1 = path.join(common.tmpDir, 'junction1');
-var linkPath2 = path.join(common.tmpDir, 'junction2');
-var linkTarget = path.join(common.fixturesDir);
-var linkData = path.join(common.fixturesDir);
+const linkPath1 = path.join(common.tmpDir, 'junction1');
+const linkPath2 = path.join(common.tmpDir, 'junction2');
+const linkTarget = path.join(common.fixturesDir);
+const linkData = path.join(common.fixturesDir);
common.refreshTmpDir();
@@ -24,11 +24,11 @@ fs.symlinkSync(linkData, linkPath2, 'junction');
verifyLink(linkPath2);
function verifyLink(linkPath) {
- var stats = fs.lstatSync(linkPath);
+ const stats = fs.lstatSync(linkPath);
assert.ok(stats.isSymbolicLink());
- var data1 = fs.readFileSync(linkPath + '/x.txt', 'ascii');
- var data2 = fs.readFileSync(linkTarget + '/x.txt', 'ascii');
+ const data1 = fs.readFileSync(linkPath + '/x.txt', 'ascii');
+ const data2 = fs.readFileSync(linkTarget + '/x.txt', 'ascii');
assert.strictEqual(data1, data2);
// Clean up.
diff --git a/test/parallel/test-fs-symlink.js b/test/parallel/test-fs-symlink.js
index ab52ba22923f3d..9f3f0251e76b58 100644
--- a/test/parallel/test-fs-symlink.js
+++ b/test/parallel/test-fs-symlink.js
@@ -5,8 +5,8 @@ const path = require('path');
const fs = require('fs');
const exec = require('child_process').exec;
-var linkTime;
-var fileTime;
+let linkTime;
+let fileTime;
if (common.isWindows) {
// On Windows, creating symlinks requires admin privileges.
diff --git a/test/parallel/test-fs-sync-fd-leak.js b/test/parallel/test-fs-sync-fd-leak.js
index f7cfd25f4b9b4c..0adf407d25d7a4 100644
--- a/test/parallel/test-fs-sync-fd-leak.js
+++ b/test/parallel/test-fs-sync-fd-leak.js
@@ -1,12 +1,14 @@
'use strict';
require('../common');
-var assert = require('assert');
-var fs = require('fs');
+const assert = require('assert');
+const fs = require('fs');
// ensure that (read|write|append)FileSync() closes the file descriptor
fs.openSync = function() {
return 42;
};
+
+let close_called = 0;
fs.closeSync = function(fd) {
assert.equal(fd, 42);
close_called++;
@@ -32,9 +34,8 @@ ensureThrows(function() {
fs.appendFileSync('dummy', 'xxx');
});
-var close_called = 0;
function ensureThrows(cb) {
- var got_exception = false;
+ let got_exception = false;
close_called = 0;
try {
diff --git a/test/parallel/test-fs-truncate-GH-6233.js b/test/parallel/test-fs-truncate-GH-6233.js
index acfdd1ccae1259..95eaf12cbb77f9 100644
--- a/test/parallel/test-fs-truncate-GH-6233.js
+++ b/test/parallel/test-fs-truncate-GH-6233.js
@@ -1,9 +1,9 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
-var filename = common.tmpDir + '/truncate-file.txt';
+const filename = common.tmpDir + '/truncate-file.txt';
common.refreshTmpDir();
diff --git a/test/parallel/test-fs-utimes.js b/test/parallel/test-fs-utimes.js
index 108ca7c7d71c03..b28a2b96e2075e 100644
--- a/test/parallel/test-fs-utimes.js
+++ b/test/parallel/test-fs-utimes.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var util = require('util');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const util = require('util');
+const fs = require('fs');
let tests_ok = 0;
let tests_run = 0;
diff --git a/test/parallel/test-fs-watch-recursive.js b/test/parallel/test-fs-watch-recursive.js
index 97c65fccf4a1fb..5fb13623dff543 100644
--- a/test/parallel/test-fs-watch-recursive.js
+++ b/test/parallel/test-fs-watch-recursive.js
@@ -22,7 +22,7 @@ const filepathOne = path.join(testsubdir, filenameOne);
const watcher = fs.watch(testDir, {recursive: true});
-var watcherClosed = false;
+let watcherClosed = false;
watcher.on('change', function(event, filename) {
assert.ok('change' === event || 'rename' === event);
@@ -37,8 +37,9 @@ watcher.on('change', function(event, filename) {
watcherClosed = true;
});
+let interval;
if (common.isOSX) {
- var interval = setInterval(function() {
+ interval = setInterval(function() {
fs.writeFileSync(filepathOne, 'world');
}, 10);
} else {
diff --git a/test/parallel/test-fs-watchfile.js b/test/parallel/test-fs-watchfile.js
index d30261859c39b7..fcd28be0c1f126 100644
--- a/test/parallel/test-fs-watchfile.js
+++ b/test/parallel/test-fs-watchfile.js
@@ -40,7 +40,7 @@ common.refreshTmpDir();
// If the file initially didn't exist, and gets created at a later point of
// time, the callback should be invoked again with proper values in stat object
-var fileExists = false;
+let fileExists = false;
fs.watchFile(enoentFile, {interval: 0}, common.mustCall(function(curr, prev) {
if (!fileExists) {
diff --git a/test/parallel/test-fs-write-buffer.js b/test/parallel/test-fs-write-buffer.js
index b6404a036a78c2..7b4081010fd6d7 100644
--- a/test/parallel/test-fs-write-buffer.js
+++ b/test/parallel/test-fs-write-buffer.js
@@ -23,7 +23,7 @@ fs.open(filename, 'w', 0o644, common.mustCall(function(err, fd) {
assert.equal(expected.length, written);
fs.closeSync(fd);
- var found = fs.readFileSync(filename, 'utf8');
+ const found = fs.readFileSync(filename, 'utf8');
assert.deepStrictEqual(expected.toString(), found);
fs.unlinkSync(filename);
}));
diff --git a/test/parallel/test-fs-write-file-buffer.js b/test/parallel/test-fs-write-file-buffer.js
index a23ccc21336976..409ddf1d51f557 100644
--- a/test/parallel/test-fs-write-file-buffer.js
+++ b/test/parallel/test-fs-write-file-buffer.js
@@ -1,10 +1,10 @@
'use strict';
-var common = require('../common');
-var join = require('path').join;
-var util = require('util');
-var fs = require('fs');
+const common = require('../common');
+const join = require('path').join;
+const util = require('util');
+const fs = require('fs');
-var data = [
+let data = [
'/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcH',
'Bw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/',
'2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e',
@@ -27,7 +27,7 @@ data = data.join('\n');
common.refreshTmpDir();
-var buf = Buffer.from(data, 'base64');
+const buf = Buffer.from(data, 'base64');
fs.writeFileSync(join(common.tmpDir, 'test.jpg'), buf);
util.log('Done!');
diff --git a/test/parallel/test-fs-write-stream-change-open.js b/test/parallel/test-fs-write-stream-change-open.js
index a9d31a3074dcd6..f68cc0a6d386e2 100644
--- a/test/parallel/test-fs-write-stream-change-open.js
+++ b/test/parallel/test-fs-write-stream-change-open.js
@@ -4,7 +4,7 @@ const assert = require('assert');
const path = require('path');
const fs = require('fs');
-var file = path.join(common.tmpDir, 'write.txt');
+const file = path.join(common.tmpDir, 'write.txt');
common.refreshTmpDir();
diff --git a/test/parallel/test-fs-write-stream-end.js b/test/parallel/test-fs-write-stream-end.js
index ade6777d5f68ac..6329aee4167d7b 100644
--- a/test/parallel/test-fs-write-stream-end.js
+++ b/test/parallel/test-fs-write-stream-end.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var path = require('path');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const path = require('path');
+const fs = require('fs');
common.refreshTmpDir();
diff --git a/test/parallel/test-fs-write-stream-err.js b/test/parallel/test-fs-write-stream-err.js
index c1151b12531f92..d50fd07103222e 100644
--- a/test/parallel/test-fs-write-stream-err.js
+++ b/test/parallel/test-fs-write-stream-err.js
@@ -1,17 +1,17 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
common.refreshTmpDir();
-var stream = fs.createWriteStream(common.tmpDir + '/out', {
+const stream = fs.createWriteStream(common.tmpDir + '/out', {
highWaterMark: 10
});
-var err = new Error('BAM');
+const err = new Error('BAM');
-var write = fs.write;
-var writeCalls = 0;
+const write = fs.write;
+let writeCalls = 0;
fs.write = function() {
switch (writeCalls++) {
case 0:
@@ -21,7 +21,7 @@ fs.write = function() {
case 1:
// then it breaks
console.error('second write');
- var cb = arguments[arguments.length - 1];
+ const cb = arguments[arguments.length - 1];
return process.nextTick(function() {
cb(err);
});
diff --git a/test/parallel/test-fs-write-stream.js b/test/parallel/test-fs-write-stream.js
index 71aaaa75dd5845..a3ba0377e2e26e 100644
--- a/test/parallel/test-fs-write-stream.js
+++ b/test/parallel/test-fs-write-stream.js
@@ -4,7 +4,7 @@ const assert = require('assert');
const path = require('path');
const fs = require('fs');
-var file = path.join(common.tmpDir, 'write.txt');
+const file = path.join(common.tmpDir, 'write.txt');
common.refreshTmpDir();
diff --git a/test/parallel/test-fs-write-string-coerce.js b/test/parallel/test-fs-write-string-coerce.js
index 5c7999e9b1158c..9daae645822acb 100644
--- a/test/parallel/test-fs-write-string-coerce.js
+++ b/test/parallel/test-fs-write-string-coerce.js
@@ -1,15 +1,15 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var path = require('path');
-var Buffer = require('buffer').Buffer;
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const path = require('path');
+const Buffer = require('buffer').Buffer;
+const fs = require('fs');
common.refreshTmpDir();
-var fn = path.join(common.tmpDir, 'write-string-coerce.txt');
-var data = true;
-var expected = data + '';
+const fn = path.join(common.tmpDir, 'write-string-coerce.txt');
+const data = true;
+const expected = data + '';
fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {
if (err) throw err;
diff --git a/test/parallel/test-fs-write-sync.js b/test/parallel/test-fs-write-sync.js
index 12f34f81d8e06b..8f1a8f75c5dac0 100644
--- a/test/parallel/test-fs-write-sync.js
+++ b/test/parallel/test-fs-write-sync.js
@@ -1,21 +1,21 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var path = require('path');
-var fs = require('fs');
-var fn = path.join(common.tmpDir, 'write.txt');
+const common = require('../common');
+const assert = require('assert');
+const path = require('path');
+const fs = require('fs');
+const fn = path.join(common.tmpDir, 'write.txt');
common.refreshTmpDir();
-var foo = 'foo';
-var fd = fs.openSync(fn, 'w');
+const foo = 'foo';
+const fd = fs.openSync(fn, 'w');
-var written = fs.writeSync(fd, '');
+let written = fs.writeSync(fd, '');
assert.strictEqual(0, written);
fs.writeSync(fd, foo);
-var bar = 'bár';
+const bar = 'bár';
written = fs.writeSync(fd, Buffer.from(bar), 0, Buffer.byteLength(bar));
assert.ok(written > 3);
fs.closeSync(fd);
diff --git a/test/parallel/test-global-console-exists.js b/test/parallel/test-global-console-exists.js
index 32e640cc52f7fc..d4a7c21222b807 100644
--- a/test/parallel/test-global-console-exists.js
+++ b/test/parallel/test-global-console-exists.js
@@ -9,7 +9,7 @@ const assert = require('assert');
const EventEmitter = require('events');
const leak_warning = /EventEmitter memory leak detected\. 2 hello listeners/;
-var write_calls = 0;
+let write_calls = 0;
process.on('warning', (warning) => {
// This will be called after the default internal
diff --git a/test/parallel/test-global.js b/test/parallel/test-global.js
index 1bf1bd7cd69303..9ebbd0f604434d 100644
--- a/test/parallel/test-global.js
+++ b/test/parallel/test-global.js
@@ -15,8 +15,8 @@ assert.strictEqual('bar',
baseBar, // eslint-disable-line no-undef
'global.x -> x in base level not working');
-var module = require(path.join(common.fixturesDir, 'global', 'plain'));
-const fooBar = module.fooBar;
+const mod = require(path.join(common.fixturesDir, 'global', 'plain'));
+const fooBar = mod.fooBar;
assert.strictEqual('foo', fooBar.foo, 'x -> global.x in sub level not working');
diff --git a/test/parallel/test-http-1.0-keep-alive.js b/test/parallel/test-http-1.0-keep-alive.js
index 383f67c90a31b5..dea5f65c54184d 100644
--- a/test/parallel/test-http-1.0-keep-alive.js
+++ b/test/parallel/test-http-1.0-keep-alive.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var http = require('http');
-var net = require('net');
+const http = require('http');
+const net = require('net');
// Check that our HTTP server correctly handles HTTP/1.0 keep-alive requests.
check([{
@@ -83,12 +83,12 @@ check([{
}]);
function check(tests) {
- var test = tests[0];
- var server;
+ const test = tests[0];
+ let server;
if (test) {
server = http.createServer(serverHandler).listen(0, '127.0.0.1', client);
}
- var current = 0;
+ let current = 0;
function next() {
check(tests.slice(1));
@@ -96,7 +96,7 @@ function check(tests) {
function serverHandler(req, res) {
if (current + 1 === test.responses.length) this.close();
- var ctx = test.responses[current];
+ const ctx = test.responses[current];
console.error('< SERVER SENDING RESPONSE', ctx);
res.writeHead(200, ctx.headers);
ctx.chunks.slice(0, -1).forEach(function(chunk) { res.write(chunk); });
@@ -106,10 +106,10 @@ function check(tests) {
function client() {
if (current === test.requests.length) return next();
const port = server.address().port;
- var conn = net.createConnection(port, '127.0.0.1', connected);
+ const conn = net.createConnection(port, '127.0.0.1', connected);
function connected() {
- var ctx = test.requests[current];
+ const ctx = test.requests[current];
console.error(' > CLIENT SENDING REQUEST', ctx);
conn.setEncoding('utf8');
conn.write(ctx.data);
diff --git a/test/parallel/test-http-1.0.js b/test/parallel/test-http-1.0.js
index d01613de45452d..d98da182a9fee5 100644
--- a/test/parallel/test-http-1.0.js
+++ b/test/parallel/test-http-1.0.js
@@ -1,20 +1,20 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
-var http = require('http');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
+const http = require('http');
-var body = 'hello world\n';
+const body = 'hello world\n';
function test(handler, request_generator, response_validator) {
- var server = http.createServer(handler);
+ const server = http.createServer(handler);
- var client_got_eof = false;
- var server_response = '';
+ let client_got_eof = false;
+ let server_response = '';
server.listen(0);
server.on('listening', function() {
- var c = net.createConnection(this.address().port);
+ const c = net.createConnection(this.address().port);
c.setEncoding('utf8');
diff --git a/test/parallel/test-http-abort-before-end.js b/test/parallel/test-http-abort-before-end.js
index ee22dc847b5882..046f439cb33195 100644
--- a/test/parallel/test-http-abort-before-end.js
+++ b/test/parallel/test-http-abort-before-end.js
@@ -1,12 +1,12 @@
'use strict';
const common = require('../common');
-var http = require('http');
-var assert = require('assert');
+const http = require('http');
+const assert = require('assert');
-var server = http.createServer(common.fail);
+const server = http.createServer(common.fail);
server.listen(0, function() {
- var req = http.request({
+ const req = http.request({
method: 'GET',
host: '127.0.0.1',
port: this.address().port
diff --git a/test/parallel/test-http-abort-client.js b/test/parallel/test-http-abort-client.js
index addcec1ef3e9f9..6c00a1e6c64328 100644
--- a/test/parallel/test-http-abort-client.js
+++ b/test/parallel/test-http-abort-client.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var http = require('http');
+const http = require('http');
-var server = http.Server(function(req, res) {
+const server = http.Server(function(req, res) {
console.log('Server accepted request.');
res.writeHead(200);
res.write('Part of my res.');
diff --git a/test/parallel/test-http-abort-queued.js b/test/parallel/test-http-abort-queued.js
index 0a993a2658ca11..8e8339aa82d3dd 100644
--- a/test/parallel/test-http-abort-queued.js
+++ b/test/parallel/test-http-abort-queued.js
@@ -3,9 +3,9 @@ require('../common');
const assert = require('assert');
const http = require('http');
-var complete;
+let complete;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
// We should not see the queued /thatotherone request within the server
// as it should be aborted before it is sent.
assert.equal(req.url, '/');
@@ -22,10 +22,10 @@ var server = http.createServer(function(req, res) {
server.listen(0, function() {
console.log('listen', server.address().port);
- var agent = new http.Agent({maxSockets: 1});
+ const agent = new http.Agent({maxSockets: 1});
assert.equal(Object.keys(agent.sockets).length, 0);
- var options = {
+ const options = {
hostname: 'localhost',
port: server.address().port,
method: 'GET',
@@ -33,12 +33,12 @@ server.listen(0, function() {
agent: agent
};
- var req1 = http.request(options);
+ const req1 = http.request(options);
req1.on('response', function(res1) {
assert.equal(Object.keys(agent.sockets).length, 1);
assert.equal(Object.keys(agent.requests).length, 0);
- var req2 = http.request({
+ const req2 = http.request({
method: 'GET',
host: 'localhost',
port: server.address().port,
diff --git a/test/parallel/test-http-after-connect.js b/test/parallel/test-http-after-connect.js
index 0580f428ed70f5..a93d0b83aa6f4f 100644
--- a/test/parallel/test-http-after-connect.js
+++ b/test/parallel/test-http-after-connect.js
@@ -3,7 +3,7 @@ const common = require('../common');
const assert = require('assert');
const http = require('http');
-var clientResponses = 0;
+let clientResponses = 0;
const server = http.createServer(common.mustCall(function(req, res) {
console.error('Server got GET request');
@@ -46,7 +46,7 @@ function doRequest(i) {
path: '/request' + i
}, common.mustCall(function(res) {
console.error('Client got GET response');
- var data = '';
+ let data = '';
res.setEncoding('utf8');
res.on('data', function(chunk) {
data += chunk;
diff --git a/test/parallel/test-http-agent-destroyed-socket.js b/test/parallel/test-http-agent-destroyed-socket.js
index a2693637728439..4bb14c2d7e01ce 100644
--- a/test/parallel/test-http-agent-destroyed-socket.js
+++ b/test/parallel/test-http-agent-destroyed-socket.js
@@ -1,28 +1,28 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(0, function() {
- var agent = new http.Agent({maxSockets: 1});
+ const agent = new http.Agent({maxSockets: 1});
agent.on('free', function(socket, host, port) {
console.log('freeing socket. destroyed? ', socket.destroyed);
});
- var requestOptions = {
+ const requestOptions = {
agent: agent,
host: 'localhost',
port: this.address().port,
path: '/'
};
- var request1 = http.get(requestOptions, function(response) {
+ const request1 = http.get(requestOptions, function(response) {
// assert request2 is queued in the agent
- var key = agent.getName(requestOptions);
+ const key = agent.getName(requestOptions);
assert.strictEqual(agent.requests[key].length, 1);
console.log('got response1');
request1.socket.on('close', function() {
@@ -58,14 +58,14 @@ var server = http.createServer(function(req, res) {
});
});
- var request2 = http.get(requestOptions, function(response) {
+ let request2 = http.get(requestOptions, function(response) {
assert(!request2.socket.destroyed);
assert(request1.socket.destroyed);
// assert not reusing the same socket, since it was destroyed.
assert.notStrictEqual(request1.socket, request2.socket);
console.log('got response2');
- var gotClose = false;
- var gotResponseEnd = false;
+ let gotClose = false;
+ let gotResponseEnd = false;
request2.socket.on('close', function() {
console.log('request2 socket closed');
gotClose = true;
diff --git a/test/parallel/test-http-agent-error-on-idle.js b/test/parallel/test-http-agent-error-on-idle.js
index 59b0109ef1c398..b2bf6334dcbc1b 100644
--- a/test/parallel/test-http-agent-error-on-idle.js
+++ b/test/parallel/test-http-agent-error-on-idle.js
@@ -1,38 +1,38 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var Agent = http.Agent;
+const assert = require('assert');
+const http = require('http');
+const Agent = http.Agent;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.end('hello world');
});
server.listen(0, function() {
- var agent = new Agent({
+ const agent = new Agent({
keepAlive: true,
});
- var requestParams = {
+ const requestParams = {
host: 'localhost',
port: this.address().port,
agent: agent,
path: '/'
};
- var socketKey = agent.getName(requestParams);
+ const socketKey = agent.getName(requestParams);
get(function(res) {
assert.equal(res.statusCode, 200);
res.resume();
res.on('end', function() {
process.nextTick(function() {
- var freeSockets = agent.freeSockets[socketKey];
+ const freeSockets = agent.freeSockets[socketKey];
assert.equal(freeSockets.length, 1,
'expect a free socket on ' + socketKey);
//generate a random error on the free socket
- var freeSocket = freeSockets[0];
+ const freeSocket = freeSockets[0];
freeSocket.emit('error', new Error('ECONNRESET: test'));
get(done);
diff --git a/test/parallel/test-http-agent-false.js b/test/parallel/test-http-agent-false.js
index 96606028bf7a45..5c9907bb706d32 100644
--- a/test/parallel/test-http-agent-false.js
+++ b/test/parallel/test-http-agent-false.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
// sending `agent: false` when `port: null` is also passed in (i.e. the result
// of a `url.parse()` call with the default port used, 80 or 443), should not
// result in an assertion error...
-var opts = {
+const opts = {
host: '127.0.0.1',
port: null,
path: '/',
@@ -14,7 +14,7 @@ var opts = {
agent: false
};
-var good = false;
+let good = false;
process.on('exit', function() {
assert(good, 'expected either an "error" or "response" event');
});
@@ -22,7 +22,7 @@ process.on('exit', function() {
// we just want an "error" (no local HTTP server on port 80) or "response"
// to happen (user happens ot have HTTP server running on port 80).
// As long as the process doesn't crash from a C++ assertion then we're good.
-var req = http.request(opts);
+const req = http.request(opts);
req.on('response', function(res) {
good = true;
});
diff --git a/test/parallel/test-http-agent-maxsockets-regress-4050.js b/test/parallel/test-http-agent-maxsockets-regress-4050.js
index 0ba3d1304f0d68..fd3a8c33f3e39a 100644
--- a/test/parallel/test-http-agent-maxsockets-regress-4050.js
+++ b/test/parallel/test-http-agent-maxsockets-regress-4050.js
@@ -26,9 +26,9 @@ function get(path, callback) {
}
server.listen(0, function() {
- var finished = 0;
+ let finished = 0;
const num_requests = 6;
- for (var i = 0; i < num_requests; i++) {
+ for (let i = 0; i < num_requests; i++) {
const request = get('/1', function() {
});
request.on('response', function() {
diff --git a/test/parallel/test-http-agent-maxsockets.js b/test/parallel/test-http-agent-maxsockets.js
index ea443ff9bd1107..6814aca3e76fbc 100644
--- a/test/parallel/test-http-agent-maxsockets.js
+++ b/test/parallel/test-http-agent-maxsockets.js
@@ -1,16 +1,16 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var agent = new http.Agent({
+const agent = new http.Agent({
keepAlive: true,
keepAliveMsecs: 1000,
maxSockets: 2,
maxFreeSockets: 2
});
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.end('hello world');
});
@@ -23,12 +23,12 @@ function get(path, callback) {
}, callback);
}
-var count = 0;
+let count = 0;
function done() {
if (++count !== 2) {
return;
}
- var freepool = agent.freeSockets[Object.keys(agent.freeSockets)[0]];
+ const freepool = agent.freeSockets[Object.keys(agent.freeSockets)[0]];
assert.equal(freepool.length, 2,
'expect keep 2 free sockets, but got ' + freepool.length);
agent.destroy();
diff --git a/test/parallel/test-http-agent-no-protocol.js b/test/parallel/test-http-agent-no-protocol.js
index 94fd525b908c30..a11489b6c5bc2b 100644
--- a/test/parallel/test-http-agent-no-protocol.js
+++ b/test/parallel/test-http-agent-no-protocol.js
@@ -1,12 +1,12 @@
'use strict';
const common = require('../common');
-var http = require('http');
-var url = require('url');
+const http = require('http');
+const url = require('url');
-var server = http.createServer(common.mustCall(function(req, res) {
+const server = http.createServer(common.mustCall(function(req, res) {
res.end();
})).listen(0, '127.0.0.1', common.mustCall(function() {
- var opts = url.parse(`http://127.0.0.1:${this.address().port}/`);
+ const opts = url.parse(`http://127.0.0.1:${this.address().port}/`);
// remove the `protocol` field… the `http` module should fall back
// to "http:", as defined by the global, default `http.Agent` instance.
diff --git a/test/parallel/test-http-agent-null.js b/test/parallel/test-http-agent-null.js
index f1dfeddea8b0e3..9071b88b98997a 100644
--- a/test/parallel/test-http-agent-null.js
+++ b/test/parallel/test-http-agent-null.js
@@ -1,11 +1,11 @@
'use strict';
const common = require('../common');
-var http = require('http');
+const http = require('http');
-var server = http.createServer(common.mustCall(function(req, res) {
+const server = http.createServer(common.mustCall(function(req, res) {
res.end();
})).listen(0, common.mustCall(function() {
- var options = {
+ const options = {
agent: null,
port: this.address().port
};
diff --git a/test/parallel/test-http-agent.js b/test/parallel/test-http-agent.js
index dae982ed51a302..85975979cb3265 100644
--- a/test/parallel/test-http-agent.js
+++ b/test/parallel/test-http-agent.js
@@ -1,22 +1,22 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var server = http.Server(function(req, res) {
+const server = http.Server(function(req, res) {
res.writeHead(200);
res.end('hello world\n');
});
-var responses = 0;
-var N = 4;
-var M = 4;
+let responses = 0;
+const N = 4;
+const M = 4;
server.listen(0, function() {
const port = this.address().port;
- for (var i = 0; i < N; i++) {
+ for (let i = 0; i < N; i++) {
setTimeout(function() {
- for (var j = 0; j < M; j++) {
+ for (let j = 0; j < M; j++) {
http.get({ port: port, path: '/' }, function(res) {
console.log('%d %d', responses, res.statusCode);
if (++responses === N * M) {
diff --git a/test/parallel/test-http-automatic-headers.js b/test/parallel/test-http-automatic-headers.js
index 600be8e43ee23c..5fc8d780af9396 100644
--- a/test/parallel/test-http-automatic-headers.js
+++ b/test/parallel/test-http-automatic-headers.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.setHeader('X-Date', 'foo');
res.setHeader('X-Connection', 'bar');
res.setHeader('X-Content-Length', 'baz');
@@ -12,7 +12,7 @@ var server = http.createServer(function(req, res) {
server.listen(0);
server.on('listening', function() {
- var agent = new http.Agent({ port: this.address().port, maxSockets: 1 });
+ const agent = new http.Agent({ port: this.address().port, maxSockets: 1 });
http.get({
port: this.address().port,
path: '/hello',
diff --git a/test/parallel/test-http-blank-header.js b/test/parallel/test-http-blank-header.js
index 13b1a2f3b0d449..2a6bf482077166 100644
--- a/test/parallel/test-http-blank-header.js
+++ b/test/parallel/test-http-blank-header.js
@@ -1,10 +1,10 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
-var server = http.createServer(common.mustCall(function(req, res) {
+const server = http.createServer(common.mustCall(function(req, res) {
assert.equal('GET', req.method);
assert.equal('/blah', req.url);
assert.deepStrictEqual({
@@ -16,7 +16,7 @@ var server = http.createServer(common.mustCall(function(req, res) {
server.listen(0, function() {
- var c = net.createConnection(this.address().port);
+ const c = net.createConnection(this.address().port);
c.on('connect', function() {
c.write('GET /blah HTTP/1.1\r\n' +
diff --git a/test/parallel/test-http-buffer-sanity.js b/test/parallel/test-http-buffer-sanity.js
index 542d4ad5af2cbc..c240cd13b1825c 100644
--- a/test/parallel/test-http-buffer-sanity.js
+++ b/test/parallel/test-http-buffer-sanity.js
@@ -1,28 +1,28 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var bufferSize = 5 * 1024 * 1024;
-var measuredSize = 0;
+const bufferSize = 5 * 1024 * 1024;
+let measuredSize = 0;
-var buffer = Buffer.allocUnsafe(bufferSize);
-for (var i = 0; i < buffer.length; i++) {
+const buffer = Buffer.allocUnsafe(bufferSize);
+for (let i = 0; i < buffer.length; i++) {
buffer[i] = i % 256;
}
-var web = http.Server(function(req, res) {
+const web = http.Server(function(req, res) {
web.close();
console.log(req.headers);
- var i = 0;
+ let i = 0;
req.on('data', function(d) {
process.stdout.write(',');
measuredSize += d.length;
- for (var j = 0; j < d.length; j++) {
+ for (let j = 0; j < d.length; j++) {
assert.equal(buffer[i], d[j]);
i++;
}
@@ -45,7 +45,7 @@ var web = http.Server(function(req, res) {
web.listen(0, common.mustCall(function() {
console.log('Making request');
- var req = http.request({
+ const req = http.request({
port: this.address().port,
method: 'GET',
path: '/',
diff --git a/test/parallel/test-http-byteswritten.js b/test/parallel/test-http-byteswritten.js
index bb914439a76b78..3b295ebdcc1c49 100644
--- a/test/parallel/test-http-byteswritten.js
+++ b/test/parallel/test-http-byteswritten.js
@@ -1,11 +1,11 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var body = 'hello world\n';
+const body = 'hello world\n';
-var httpServer = http.createServer(common.mustCall(function(req, res) {
+const httpServer = http.createServer(common.mustCall(function(req, res) {
httpServer.close();
res.on('finish', common.mustCall(function() {
@@ -16,9 +16,9 @@ var httpServer = http.createServer(common.mustCall(function(req, res) {
// Write 1.5mb to cause some requests to buffer
// Also, mix up the encodings a bit.
- var chunk = new Array(1024 + 1).join('7');
- var bchunk = Buffer.from(chunk);
- for (var i = 0; i < 1024; i++) {
+ const chunk = new Array(1024 + 1).join('7');
+ const bchunk = Buffer.from(chunk);
+ for (let i = 0; i < 1024; i++) {
res.write(chunk);
res.write(bchunk);
res.write(chunk, 'hex');
diff --git a/test/parallel/test-http-chunked-304.js b/test/parallel/test-http-chunked-304.js
index 82fe138fd926da..b130004d1a83e7 100644
--- a/test/parallel/test-http-chunked-304.js
+++ b/test/parallel/test-http-chunked-304.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
// RFC 2616, section 10.2.5:
//
diff --git a/test/parallel/test-http-chunked.js b/test/parallel/test-http-chunked.js
index bb91dadd159de5..516523221133ec 100644
--- a/test/parallel/test-http-chunked.js
+++ b/test/parallel/test-http-chunked.js
@@ -1,25 +1,25 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var UTF8_STRING = '南越国是前203年至前111年存在于岭南地区的一个国家,' +
- '国都位于番禺,疆域包括今天中国的广东、广西两省区的大部份地区,福建省、湖南、' +
- '贵州、云南的一小部份地区和越南的北部。南越国是秦朝灭亡后,' +
- '由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。前196年和前179年,' +
- '南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' +
- '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。' +
- '南越国共存在93年,历经五代君主。南越国是岭南地区的第一个有记载的政权国家,' +
- '采用封建制和郡县制并存的制度,它的建立保证了秦末乱世岭南地区社会秩序的稳定,' +
- '有效的改善了岭南地区落后的政治、经济现状。';
+const UTF8_STRING = '南越国是前203年至前111年存在于岭南地区的一个国家,' +
+ '国都位于番禺,疆域包括今天中国的广东、广西两省区的大部份地区,福建省、湖南、' +
+ '贵州、云南的一小部份地区和越南的北部。南越国是秦朝灭亡后,' +
+ '由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。前196年和前179年,' +
+ '南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' +
+ '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。' +
+ '南越国共存在93年,历经五代君主。南越国是岭南地区的第一个有记载的政权国家,' +
+ '采用封建制和郡县制并存的制度,它的建立保证了秦末乱世岭南地区社会秩序的稳定,' +
+ '有效的改善了岭南地区落后的政治、经济现状。';
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain; charset=utf8'});
res.end(UTF8_STRING, 'utf8');
});
server.listen(0, function() {
- var data = '';
- var get = http.get({
+ let data = '';
+ const get = http.get({
path: '/',
host: 'localhost',
port: this.address().port
diff --git a/test/parallel/test-http-client-abort-event.js b/test/parallel/test-http-client-abort-event.js
index c0c1f9e4c73c92..b62186e724d919 100644
--- a/test/parallel/test-http-client-abort-event.js
+++ b/test/parallel/test-http-client-abort-event.js
@@ -1,12 +1,12 @@
'use strict';
const common = require('../common');
-var http = require('http');
-var server = http.createServer(function(req, res) {
+const http = require('http');
+const server = http.createServer(function(req, res) {
res.end();
});
server.listen(0, common.mustCall(function() {
- var req = http.request({
+ const req = http.request({
port: this.address().port
}, common.fail);
diff --git a/test/parallel/test-http-client-abort.js b/test/parallel/test-http-client-abort.js
index 4f46128f0e804a..738c620815a21a 100644
--- a/test/parallel/test-http-client-abort.js
+++ b/test/parallel/test-http-client-abort.js
@@ -3,7 +3,7 @@ require('../common');
const assert = require('assert');
const http = require('http');
-var clientAborts = 0;
+let clientAborts = 0;
const server = http.Server(function(req, res) {
console.log('Got connection');
@@ -23,17 +23,17 @@ const server = http.Server(function(req, res) {
});
});
-var responses = 0;
+let responses = 0;
const N = 8;
const requests = [];
server.listen(0, function() {
console.log('Server listening.');
- for (var i = 0; i < N; i++) {
+ for (let i = 0; i < N; i++) {
console.log('Making client ' + i);
- var options = { port: this.address().port, path: '/?id=' + i };
- var req = http.get(options, function(res) {
+ const options = { port: this.address().port, path: '/?id=' + i };
+ const req = http.get(options, function(res) {
console.log('Client response code ' + res.statusCode);
res.resume();
diff --git a/test/parallel/test-http-client-abort2.js b/test/parallel/test-http-client-abort2.js
index 30269a193f0eab..7c7be9b530e2d2 100644
--- a/test/parallel/test-http-client-abort2.js
+++ b/test/parallel/test-http-client-abort2.js
@@ -1,13 +1,13 @@
'use strict';
require('../common');
-var http = require('http');
+const http = require('http');
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.end('Hello');
});
server.listen(0, function() {
- var req = http.get({port: this.address().port}, function(res) {
+ const req = http.get({port: this.address().port}, function(res) {
res.on('data', function(data) {
req.abort();
server.close();
diff --git a/test/parallel/test-http-client-agent.js b/test/parallel/test-http-client-agent.js
index 36ed24ec526255..3c2b9c89727467 100644
--- a/test/parallel/test-http-client-agent.js
+++ b/test/parallel/test-http-client-agent.js
@@ -1,13 +1,13 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var name;
-var max = 3;
-var count = 0;
+let name;
+const max = 3;
+let count = 0;
-var server = http.Server(function(req, res) {
+const server = http.Server(function(req, res) {
if (req.url === '/0') {
setTimeout(function() {
res.writeHead(200);
@@ -20,17 +20,17 @@ var server = http.Server(function(req, res) {
});
server.listen(0, function() {
name = http.globalAgent.getName({ port: this.address().port });
- for (var i = 0; i < max; ++i) {
+ for (let i = 0; i < max; ++i) {
request(i);
}
});
function request(i) {
- var req = http.get({
+ const req = http.get({
port: server.address().port,
path: '/' + i
}, function(res) {
- var socket = req.socket;
+ const socket = req.socket;
socket.on('close', function() {
++count;
if (count < max) {
diff --git a/test/parallel/test-http-client-default-headers-exist.js b/test/parallel/test-http-client-default-headers-exist.js
index 9b73f2db32aad6..2271944773d9db 100644
--- a/test/parallel/test-http-client-default-headers-exist.js
+++ b/test/parallel/test-http-client-default-headers-exist.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var expectedHeaders = {
+const expectedHeaders = {
'DELETE': ['host', 'connection'],
'GET': ['host', 'connection'],
'HEAD': ['host', 'connection'],
@@ -12,18 +12,18 @@ var expectedHeaders = {
'PUT': ['host', 'connection', 'content-length']
};
-var expectedMethods = Object.keys(expectedHeaders);
+const expectedMethods = Object.keys(expectedHeaders);
-var requestCount = 0;
+let requestCount = 0;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
requestCount++;
res.end();
assert(expectedHeaders.hasOwnProperty(req.method),
req.method + ' was an unexpected method');
- var requestHeaders = Object.keys(req.headers);
+ const requestHeaders = Object.keys(req.headers);
requestHeaders.forEach(function(header) {
assert.notStrictEqual(
expectedHeaders[req.method].indexOf(header.toLowerCase()),
diff --git a/test/parallel/test-http-client-encoding.js b/test/parallel/test-http-client-encoding.js
index b02463aa5188d5..d2aa8fdcbbac46 100644
--- a/test/parallel/test-http-client-encoding.js
+++ b/test/parallel/test-http-client-encoding.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var http = require('http');
+const http = require('http');
http.createServer(function(req, res) {
res.end('ok\n');
diff --git a/test/parallel/test-http-client-get-url.js b/test/parallel/test-http-client-get-url.js
index 51f8413b675244..d666fdd8354e71 100644
--- a/test/parallel/test-http-client-get-url.js
+++ b/test/parallel/test-http-client-get-url.js
@@ -1,9 +1,9 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var server = http.createServer(common.mustCall(function(req, res) {
+const server = http.createServer(common.mustCall(function(req, res) {
assert.equal('GET', req.method);
assert.equal('/foo?bar', req.url);
res.writeHead(200, {'Content-Type': 'text/plain'});
diff --git a/test/parallel/test-http-client-parse-error.js b/test/parallel/test-http-client-parse-error.js
index cd6f135d889534..0d8f577a78566c 100644
--- a/test/parallel/test-http-client-parse-error.js
+++ b/test/parallel/test-http-client-parse-error.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var http = require('http');
-var net = require('net');
+const http = require('http');
+const net = require('net');
-var connects = 0;
-var parseErrors = 0;
+let connects = 0;
+let parseErrors = 0;
// Create a TCP server
net.createServer(function(c) {
@@ -18,7 +18,7 @@ net.createServer(function(c) {
this.close();
}
}).listen(0, '127.0.0.1', function() {
- for (var i = 0; i < 2; i++) {
+ for (let i = 0; i < 2; i++) {
http.request({
host: '127.0.0.1',
port: this.address().port,
diff --git a/test/parallel/test-http-client-pipe-end.js b/test/parallel/test-http-client-pipe-end.js
index 5b2db49435a1b6..d4ccba8d55b036 100644
--- a/test/parallel/test-http-client-pipe-end.js
+++ b/test/parallel/test-http-client-pipe-end.js
@@ -1,10 +1,10 @@
'use strict';
// see https://github.com/joyent/node/issues/3257
-var common = require('../common');
-var http = require('http');
+const common = require('../common');
+const http = require('http');
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
req.resume();
req.once('end', function() {
res.writeHead(200);
@@ -16,7 +16,7 @@ var server = http.createServer(function(req, res) {
common.refreshTmpDir();
server.listen(common.PIPE, function() {
- var req = http.request({
+ const req = http.request({
socketPath: common.PIPE,
headers: {'Content-Length': '1'},
method: 'POST',
diff --git a/test/parallel/test-http-client-race-2.js b/test/parallel/test-http-client-race-2.js
index 477c6c25c4e396..a6ccc7297967a5 100644
--- a/test/parallel/test-http-client-race-2.js
+++ b/test/parallel/test-http-client-race-2.js
@@ -1,22 +1,22 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var url = require('url');
+const assert = require('assert');
+const http = require('http');
+const url = require('url');
//
// Slight variation on test-http-client-race to test for another race
// condition involving the parsers FreeList used internally by http.Client.
//
-var body1_s = '1111111111111111';
-var body2_s = '22222';
-var body3_s = '3333333333333333333';
+const body1_s = '1111111111111111';
+const body2_s = '22222';
+const body3_s = '3333333333333333333';
-var server = http.createServer(function(req, res) {
- var pathname = url.parse(req.url).pathname;
+const server = http.createServer(function(req, res) {
+ const pathname = url.parse(req.url).pathname;
- var body;
+ let body;
switch (pathname) {
case '/1': body = body1_s; break;
case '/2': body = body2_s; break;
@@ -29,17 +29,17 @@ var server = http.createServer(function(req, res) {
});
server.listen(0);
-var body1 = '';
-var body2 = '';
-var body3 = '';
+let body1 = '';
+let body2 = '';
+let body3 = '';
server.on('listening', function() {
- var client = http.createClient(this.address().port);
+ const client = http.createClient(this.address().port);
//
// Client #1 is assigned Parser #1
//
- var req1 = client.request('/1');
+ const req1 = client.request('/1');
req1.end();
req1.on('response', function(res1) {
res1.setEncoding('utf8');
@@ -59,13 +59,13 @@ server.on('listening', function() {
// parser that previously belonged to Client #1. But we're not finished
// with Client #1 yet!
//
- var client2 = http.createClient(server.address().port);
+ const client2 = http.createClient(server.address().port);
//
// At this point, the bug would manifest itself and crash because the
// internal state of the parser was no longer valid for use by Client #1
//
- var req2 = client.request('/2');
+ const req2 = client.request('/2');
req2.end();
req2.on('response', function(res2) {
res2.setEncoding('utf8');
@@ -76,7 +76,7 @@ server.on('listening', function() {
// Just to be really sure we've covered all our bases, execute a
// request using client2.
//
- var req3 = client2.request('/3');
+ const req3 = client2.request('/3');
req3.end();
req3.on('response', function(res3) {
res3.setEncoding('utf8');
diff --git a/test/parallel/test-http-client-race.js b/test/parallel/test-http-client-race.js
index 30ebb34fc7fcff..14e3300f20a436 100644
--- a/test/parallel/test-http-client-race.js
+++ b/test/parallel/test-http-client-race.js
@@ -1,25 +1,25 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var url = require('url');
+const assert = require('assert');
+const http = require('http');
+const url = require('url');
-var body1_s = '1111111111111111';
-var body2_s = '22222';
+const body1_s = '1111111111111111';
+const body2_s = '22222';
-var server = http.createServer(function(req, res) {
- var body = url.parse(req.url).pathname === '/1' ? body1_s : body2_s;
+const server = http.createServer(function(req, res) {
+ const body = url.parse(req.url).pathname === '/1' ? body1_s : body2_s;
res.writeHead(200,
{'Content-Type': 'text/plain', 'Content-Length': body.length});
res.end(body);
});
server.listen(0);
-var body1 = '';
-var body2 = '';
+let body1 = '';
+let body2 = '';
server.on('listening', function() {
- var req1 = http.request({ port: this.address().port, path: '/1' });
+ const req1 = http.request({ port: this.address().port, path: '/1' });
req1.end();
req1.on('response', function(res1) {
res1.setEncoding('utf8');
@@ -29,7 +29,7 @@ server.on('listening', function() {
});
res1.on('end', function() {
- var req2 = http.request({ port: server.address().port, path: '/2' });
+ const req2 = http.request({ port: server.address().port, path: '/2' });
req2.end();
req2.on('response', function(res2) {
res2.setEncoding('utf8');
diff --git a/test/parallel/test-http-client-read-in-error.js b/test/parallel/test-http-client-read-in-error.js
index 142c0ee3715aed..69b24f73771d41 100644
--- a/test/parallel/test-http-client-read-in-error.js
+++ b/test/parallel/test-http-client-read-in-error.js
@@ -1,8 +1,8 @@
'use strict';
require('../common');
-var net = require('net');
-var http = require('http');
-var util = require('util');
+const net = require('net');
+const http = require('http');
+const util = require('util');
function Agent() {
http.Agent.call(this);
@@ -10,8 +10,8 @@ function Agent() {
util.inherits(Agent, http.Agent);
Agent.prototype.createConnection = function() {
- var self = this;
- var socket = new net.Socket();
+ const self = this;
+ const socket = new net.Socket();
socket.on('error', function() {
socket.push('HTTP/1.1 200\r\n\r\n');
@@ -35,7 +35,7 @@ Agent.prototype.breakSocket = function breakSocket(socket) {
socket.emit('error', new Error('Intentional error'));
};
-var agent = new Agent();
+const agent = new Agent();
http.request({
agent: agent
diff --git a/test/parallel/test-http-client-readable.js b/test/parallel/test-http-client-readable.js
index e49181cedf63d6..bc6421692b305b 100644
--- a/test/parallel/test-http-client-readable.js
+++ b/test/parallel/test-http-client-readable.js
@@ -13,7 +13,7 @@ util.inherits(FakeAgent, http.Agent);
FakeAgent.prototype.createConnection = function() {
const s = new Duplex();
- var once = false;
+ let once = false;
s._read = function() {
if (once)
@@ -38,7 +38,7 @@ FakeAgent.prototype.createConnection = function() {
return s;
};
-var received = '';
+let received = '';
const req = http.request({
agent: new FakeAgent()
diff --git a/test/parallel/test-http-client-response-domain.js b/test/parallel/test-http-client-response-domain.js
index 5355a301e8031d..eb8b226acef169 100644
--- a/test/parallel/test-http-client-response-domain.js
+++ b/test/parallel/test-http-client-response-domain.js
@@ -4,12 +4,12 @@ const assert = require('assert');
const http = require('http');
const domain = require('domain');
-var d;
+let d;
common.refreshTmpDir();
// first fire up a simple HTTP server
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.writeHead(200);
res.end();
server.close();
@@ -26,7 +26,7 @@ function test() {
assert.equal('should be caught by domain', err.message);
}));
- var req = http.get({
+ const req = http.get({
socketPath: common.PIPE,
headers: {'Content-Length': '1'},
method: 'POST',
diff --git a/test/parallel/test-http-client-timeout-agent.js b/test/parallel/test-http-client-timeout-agent.js
index 4ed217c171f28a..16a18342468f94 100644
--- a/test/parallel/test-http-client-timeout-agent.js
+++ b/test/parallel/test-http-client-timeout-agent.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var requests_sent = 0;
-var requests_done = 0;
-var options = {
+let requests_sent = 0;
+let requests_done = 0;
+const options = {
method: 'GET',
port: undefined,
host: '127.0.0.1',
@@ -13,7 +13,7 @@ var options = {
//http.globalAgent.maxSockets = 15;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
const m = /\/(.*)/.exec(req.url);
const reqid = parseInt(m[1], 10);
if (reqid % 2) {
@@ -27,7 +27,7 @@ var server = http.createServer(function(req, res) {
server.listen(0, options.host, function() {
options.port = this.address().port;
- var req;
+ let req;
for (requests_sent = 0; requests_sent < 30; requests_sent += 1) {
options.path = '/' + requests_sent;
diff --git a/test/parallel/test-http-client-timeout-option.js b/test/parallel/test-http-client-timeout-option.js
index 79aa6ba46b6579..6741fbe0bd1e35 100644
--- a/test/parallel/test-http-client-timeout-option.js
+++ b/test/parallel/test-http-client-timeout-option.js
@@ -3,7 +3,7 @@ const common = require('../common');
const assert = require('assert');
const http = require('http');
-var options = {
+const options = {
method: 'GET',
port: undefined,
host: '127.0.0.1',
@@ -11,17 +11,17 @@ var options = {
timeout: 1
};
-var server = http.createServer();
+const server = http.createServer();
server.listen(0, options.host, function() {
options.port = this.address().port;
- var req = http.request(options);
+ const req = http.request(options);
req.on('error', function() {
// this space is intentionally left blank
});
req.on('close', common.mustCall(() => server.close()));
- var timeout_events = 0;
+ let timeout_events = 0;
req.on('timeout', common.mustCall(() => timeout_events += 1));
setTimeout(function() {
req.destroy();
diff --git a/test/parallel/test-http-client-timeout-with-data.js b/test/parallel/test-http-client-timeout-with-data.js
index c82327beb295da..a21a2181752701 100644
--- a/test/parallel/test-http-client-timeout-with-data.js
+++ b/test/parallel/test-http-client-timeout-with-data.js
@@ -3,7 +3,7 @@ const common = require('../common');
const assert = require('assert');
const http = require('http');
-var nchunks = 0;
+let nchunks = 0;
const options = {
method: 'GET',
diff --git a/test/parallel/test-http-client-timeout.js b/test/parallel/test-http-client-timeout.js
index 402736e9b7d47c..0caae0d04c333c 100644
--- a/test/parallel/test-http-client-timeout.js
+++ b/test/parallel/test-http-client-timeout.js
@@ -1,22 +1,22 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var options = {
+const options = {
method: 'GET',
port: undefined,
host: '127.0.0.1',
path: '/'
};
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
// this space intentionally left blank
});
server.listen(0, options.host, function() {
options.port = this.address().port;
- var req = http.request(options, function(res) {
+ const req = http.request(options, function(res) {
// this space intentionally left blank
});
req.on('close', function() {
@@ -25,7 +25,7 @@ server.listen(0, options.host, function() {
function destroy() {
req.destroy();
}
- var s = req.setTimeout(1, destroy);
+ const s = req.setTimeout(1, destroy);
assert.ok(s instanceof http.ClientRequest);
req.on('error', destroy);
req.end();
diff --git a/test/parallel/test-http-client-upload-buf.js b/test/parallel/test-http-client-upload-buf.js
index 512a438ef82115..338aab9cc59ba0 100644
--- a/test/parallel/test-http-client-upload-buf.js
+++ b/test/parallel/test-http-client-upload-buf.js
@@ -1,14 +1,14 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var N = 1024;
+const N = 1024;
-var server = http.createServer(common.mustCall(function(req, res) {
+const server = http.createServer(common.mustCall(function(req, res) {
assert.equal('POST', req.method);
- var bytesReceived = 0;
+ let bytesReceived = 0;
req.on('data', function(chunk) {
bytesReceived += chunk.length;
@@ -25,7 +25,7 @@ var server = http.createServer(common.mustCall(function(req, res) {
server.listen(0);
server.on('listening', common.mustCall(function() {
- var req = http.request({
+ const req = http.request({
port: this.address().port,
method: 'POST',
path: '/'
diff --git a/test/parallel/test-http-client-upload.js b/test/parallel/test-http-client-upload.js
index a5c8f5b92bc761..ba60681776ba49 100644
--- a/test/parallel/test-http-client-upload.js
+++ b/test/parallel/test-http-client-upload.js
@@ -1,13 +1,13 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var server = http.createServer(common.mustCall(function(req, res) {
+const server = http.createServer(common.mustCall(function(req, res) {
assert.equal('POST', req.method);
req.setEncoding('utf8');
- var sent_body = '';
+ let sent_body = '';
req.on('data', function(chunk) {
console.log('server got: ' + JSON.stringify(chunk));
@@ -25,7 +25,7 @@ var server = http.createServer(common.mustCall(function(req, res) {
server.listen(0);
server.on('listening', common.mustCall(function() {
- var req = http.request({
+ const req = http.request({
port: this.address().port,
method: 'POST',
path: '/'
diff --git a/test/parallel/test-http-conn-reset.js b/test/parallel/test-http-conn-reset.js
index d7852bf32c9ec3..f7f08a6bf42c81 100644
--- a/test/parallel/test-http-conn-reset.js
+++ b/test/parallel/test-http-conn-reset.js
@@ -1,16 +1,16 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
-var options = {
+const options = {
host: '127.0.0.1',
port: undefined
};
// start a tcp server that closes incoming connections immediately
-var server = net.createServer(function(client) {
+const server = net.createServer(function(client) {
client.destroy();
server.close();
});
@@ -19,7 +19,7 @@ server.listen(0, options.host, common.mustCall(onListen));
// do a GET request, expect it to fail
function onListen() {
options.port = this.address().port;
- var req = http.request(options, function(res) {
+ const req = http.request(options, function(res) {
assert.ok(false, 'this should never run');
});
req.on('error', common.mustCall(function(err) {
diff --git a/test/parallel/test-http-connect-req-res.js b/test/parallel/test-http-connect-req-res.js
index 1cee61e4c2fb37..0b1ca4630a562e 100644
--- a/test/parallel/test-http-connect-req-res.js
+++ b/test/parallel/test-http-connect-req-res.js
@@ -18,7 +18,7 @@ server.on('connect', common.mustCall(function(req, socket, firstBodyChunk) {
'Head'
);
- var data = firstBodyChunk.toString();
+ let data = firstBodyChunk.toString();
socket.on('data', function(buf) {
data += buf.toString();
});
@@ -49,7 +49,7 @@ server.listen(0, common.mustCall(function() {
assert.equal(socket.listeners('connect').length, 0);
assert.equal(socket.listeners('data').length, 0);
- var data = firstBodyChunk.toString();
+ let data = firstBodyChunk.toString();
// test that the firstBodyChunk was not parsed as HTTP
assert.equal(data, 'Head');
diff --git a/test/parallel/test-http-content-length.js b/test/parallel/test-http-content-length.js
index 9104e5ba0d74cb..3d6882d92f04b3 100644
--- a/test/parallel/test-http-content-length.js
+++ b/test/parallel/test-http-content-length.js
@@ -1,27 +1,27 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var expectedHeadersMultipleWrites = {
+const expectedHeadersMultipleWrites = {
'connection': 'close',
'transfer-encoding': 'chunked',
};
-var expectedHeadersEndWithData = {
+const expectedHeadersEndWithData = {
'connection': 'close',
'content-length': String('hello world'.length)
};
-var expectedHeadersEndNoData = {
+const expectedHeadersEndNoData = {
'connection': 'close',
'content-length': '0',
};
-var receivedRequests = 0;
-var totalRequests = 3;
+let receivedRequests = 0;
+const totalRequests = 3;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.removeHeader('Date');
switch (req.url.substr(1)) {
@@ -47,7 +47,7 @@ var server = http.createServer(function(req, res) {
});
server.listen(0, function() {
- var req;
+ let req;
req = http.request({
port: this.address().port,
diff --git a/test/parallel/test-http-contentLength0.js b/test/parallel/test-http-contentLength0.js
index 19e90e151382be..537c7c0691af16 100644
--- a/test/parallel/test-http-contentLength0.js
+++ b/test/parallel/test-http-contentLength0.js
@@ -1,23 +1,24 @@
'use strict';
require('../common');
-var http = require('http');
+const http = require('http');
// Simple test of Node's HTTP Client choking on a response
// with a 'Content-Length: 0 ' response header.
// I.E. a space character after the 'Content-Length' throws an `error` event.
-var s = http.createServer(function(req, res) {
+const s = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Length': '0 '});
res.end();
});
s.listen(0, function() {
- var request = http.request({ port: this.address().port }, function(response) {
- console.log('STATUS: ' + response.statusCode);
- s.close();
- response.resume();
- });
+ const request =
+ http.request({ port: this.address().port }, function(response) {
+ console.log('STATUS: ' + response.statusCode);
+ s.close();
+ response.resume();
+ });
request.end();
});
diff --git a/test/parallel/test-http-date-header.js b/test/parallel/test-http-date-header.js
index e0b93c1f8718f5..e14a92b310f2d1 100644
--- a/test/parallel/test-http-date-header.js
+++ b/test/parallel/test-http-date-header.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var testResBody = 'other stuff!\n';
+const testResBody = 'other stuff!\n';
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
assert.ok(!('date' in req.headers),
'Request headers contained a Date.');
res.writeHead(200, {
@@ -17,12 +17,12 @@ server.listen(0);
server.addListener('listening', function() {
- var options = {
+ const options = {
port: this.address().port,
path: '/',
method: 'GET'
};
- var req = http.request(options, function(res) {
+ const req = http.request(options, function(res) {
assert.ok('date' in res.headers,
'Response headers didn\'t contain a Date.');
res.addListener('end', function() {
diff --git a/test/parallel/test-http-default-encoding.js b/test/parallel/test-http-default-encoding.js
index 4fb386bf4bb0e8..46327085184069 100644
--- a/test/parallel/test-http-default-encoding.js
+++ b/test/parallel/test-http-default-encoding.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var expected = 'This is a unicode text: سلام';
-var result = '';
+const expected = 'This is a unicode text: سلام';
+let result = '';
-var server = http.Server(function(req, res) {
+const server = http.Server(function(req, res) {
req.setEncoding('utf8');
req.on('data', function(chunk) {
result += chunk;
diff --git a/test/parallel/test-http-default-port.js b/test/parallel/test-http-default-port.js
index fcea5aac7b156b..dbe1a44c6a2c1b 100644
--- a/test/parallel/test-http-default-port.js
+++ b/test/parallel/test-http-default-port.js
@@ -13,8 +13,9 @@ const options = {
let gotHttpsResp = false;
let gotHttpResp = false;
+let https;
if (common.hasCrypto) {
- var https = require('https');
+ https = require('https');
} else {
common.skip('missing crypto');
}
diff --git a/test/parallel/test-http-destroyed-socket-write2.js b/test/parallel/test-http-destroyed-socket-write2.js
index 7d2f235a27f7fb..01023a088576ef 100644
--- a/test/parallel/test-http-destroyed-socket-write2.js
+++ b/test/parallel/test-http-destroyed-socket-write2.js
@@ -1,19 +1,19 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
// Verify that ECONNRESET is raised when writing to a http request
// where the server has ended the socket.
-var http = require('http');
-var server = http.createServer(function(req, res) {
+const http = require('http');
+const server = http.createServer(function(req, res) {
setImmediate(function() {
res.destroy();
});
});
server.listen(0, function() {
- var req = http.request({
+ const req = http.request({
port: this.address().port,
path: '/',
method: 'POST'
diff --git a/test/parallel/test-http-dns-error.js b/test/parallel/test-http-dns-error.js
index 5e15ab9a3fa0da..6dad7322ed45a0 100644
--- a/test/parallel/test-http-dns-error.js
+++ b/test/parallel/test-http-dns-error.js
@@ -4,8 +4,9 @@ const assert = require('assert');
const http = require('http');
+let https;
if (common.hasCrypto) {
- var https = require('https');
+ https = require('https');
} else {
common.skip('missing crypto');
}
diff --git a/test/parallel/test-http-eof-on-connect.js b/test/parallel/test-http-eof-on-connect.js
index 6f70dc239172ee..f67e45ed403225 100644
--- a/test/parallel/test-http-eof-on-connect.js
+++ b/test/parallel/test-http-eof-on-connect.js
@@ -1,13 +1,13 @@
'use strict';
require('../common');
-var net = require('net');
-var http = require('http');
+const net = require('net');
+const http = require('http');
// This is a regression test for https://github.com/joyent/node/issues/44
// It is separate from test-http-malformed-request.js because it is only
// reproduceable on the first packet on the first connection to a server.
-var server = http.createServer(function(req, res) {});
+const server = http.createServer(function(req, res) {});
server.listen(0);
server.on('listening', function() {
diff --git a/test/parallel/test-http-exceptions.js b/test/parallel/test-http-exceptions.js
index b9958007609fd0..c003db131065a3 100644
--- a/test/parallel/test-http-exceptions.js
+++ b/test/parallel/test-http-exceptions.js
@@ -1,8 +1,8 @@
'use strict';
require('../common');
-var http = require('http');
+const http = require('http');
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
intentionally_not_defined(); // eslint-disable-line no-undef
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Thank you, come again.');
@@ -10,12 +10,12 @@ var server = http.createServer(function(req, res) {
});
server.listen(0, function() {
- for (var i = 0; i < 4; i += 1) {
+ for (let i = 0; i < 4; i += 1) {
http.get({ port: this.address().port, path: '/busy/' + i });
}
});
-var exception_count = 0;
+let exception_count = 0;
process.on('uncaughtException', function(err) {
console.log('Caught an exception: ' + err);
diff --git a/test/parallel/test-http-expect-continue.js b/test/parallel/test-http-expect-continue.js
index a0ebf83b3301a5..0cf90e3b115e60 100644
--- a/test/parallel/test-http-expect-continue.js
+++ b/test/parallel/test-http-expect-continue.js
@@ -1,13 +1,13 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var outstanding_reqs = 0;
-var test_req_body = 'some stuff...\n';
-var test_res_body = 'other stuff!\n';
-var sent_continue = false;
-var got_continue = false;
+let outstanding_reqs = 0;
+const test_req_body = 'some stuff...\n';
+const test_res_body = 'other stuff!\n';
+let sent_continue = false;
+let got_continue = false;
function handler(req, res) {
assert.equal(sent_continue, true, 'Full response sent before 100 Continue');
@@ -19,7 +19,7 @@ function handler(req, res) {
res.end(test_res_body);
}
-var server = http.createServer(handler);
+const server = http.createServer(handler);
server.on('checkContinue', function(req, res) {
console.error('Server got Expect: 100-continue...');
res.writeContinue();
@@ -32,7 +32,7 @@ server.listen(0);
server.on('listening', function() {
- var req = http.request({
+ const req = http.request({
port: this.address().port,
method: 'POST',
path: '/world',
@@ -40,7 +40,7 @@ server.on('listening', function() {
});
console.error('Client sending request...');
outstanding_reqs++;
- var body = '';
+ let body = '';
req.on('continue', function() {
console.error('Client got 100 Continue...');
got_continue = true;
diff --git a/test/parallel/test-http-extra-response.js b/test/parallel/test-http-extra-response.js
index 8364684a1ec23f..6ebecaad1300de 100644
--- a/test/parallel/test-http-extra-response.js
+++ b/test/parallel/test-http-extra-response.js
@@ -1,15 +1,15 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
// If an HTTP server is broken and sends data after the end of the response,
// node should ignore it and drop the connection.
// Demos this bug: https://github.com/joyent/node/issues/680
-var body = 'hello world\r\n';
-var fullResponse =
+const body = 'hello world\r\n';
+const fullResponse =
'HTTP/1.1 500 Internal Server Error\r\n' +
'Content-Length: ' + body.length + '\r\n' +
'Content-Type: text/plain\r\n' +
@@ -20,8 +20,8 @@ var fullResponse =
'\r\n' +
body;
-var server = net.createServer(function(socket) {
- var postBody = '';
+const server = net.createServer(function(socket) {
+ let postBody = '';
socket.setEncoding('utf8');
@@ -43,7 +43,7 @@ var server = net.createServer(function(socket) {
server.listen(0, common.mustCall(function() {
http.get({ port: this.address().port }, common.mustCall(function(res) {
- var buffer = '';
+ let buffer = '';
console.log('Got res code: ' + res.statusCode);
res.setEncoding('utf8');
diff --git a/test/parallel/test-http-flush-response-headers.js b/test/parallel/test-http-flush-response-headers.js
index 1cd8402df361b0..ea7d2d97b4dc7a 100644
--- a/test/parallel/test-http-flush-response-headers.js
+++ b/test/parallel/test-http-flush-response-headers.js
@@ -11,7 +11,7 @@ server.on('request', function(req, res) {
res.flushHeaders(); // Should be idempotent.
});
server.listen(0, common.localhostIPv4, function() {
- var req = http.request({
+ const req = http.request({
method: 'GET',
host: common.localhostIPv4,
port: this.address().port,
diff --git a/test/parallel/test-http-flush.js b/test/parallel/test-http-flush.js
index 8b3dacb803d9bd..e8f5782c2f7857 100644
--- a/test/parallel/test-http-flush.js
+++ b/test/parallel/test-http-flush.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var http = require('http');
+const http = require('http');
http.createServer(function(req, res) {
res.end('ok');
this.close();
}).listen(0, '127.0.0.1', function() {
- var req = http.request({
+ const req = http.request({
method: 'POST',
host: '127.0.0.1',
port: this.address().port,
diff --git a/test/parallel/test-http-full-response.js b/test/parallel/test-http-full-response.js
index e59456a710aac3..c834c6e6545320 100644
--- a/test/parallel/test-http-full-response.js
+++ b/test/parallel/test-http-full-response.js
@@ -1,15 +1,15 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
// This test requires the program 'ab'
-var http = require('http');
-var exec = require('child_process').exec;
+const http = require('http');
+const exec = require('child_process').exec;
-var bodyLength = 12345;
+const bodyLength = 12345;
-var body = 'c'.repeat(bodyLength);
+const body = 'c'.repeat(bodyLength);
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.writeHead(200, {
'Content-Length': bodyLength,
'Content-Type': 'text/plain'
@@ -18,7 +18,7 @@ var server = http.createServer(function(req, res) {
});
function runAb(opts, callback) {
- var command = `ab ${opts} http://127.0.0.1:${server.address().port}/`;
+ const command = `ab ${opts} http://127.0.0.1:${server.address().port}/`;
exec(command, function(err, stdout, stderr) {
if (err) {
if (/ab|apr/mi.test(stderr)) {
@@ -29,14 +29,14 @@ function runAb(opts, callback) {
return;
}
- var m = /Document Length:\s*(\d+) bytes/mi.exec(stdout);
- var documentLength = parseInt(m[1]);
+ let m = /Document Length:\s*(\d+) bytes/mi.exec(stdout);
+ const documentLength = parseInt(m[1]);
m = /Complete requests:\s*(\d+)/mi.exec(stdout);
- var completeRequests = parseInt(m[1]);
+ const completeRequests = parseInt(m[1]);
m = /HTML transferred:\s*(\d+) bytes/mi.exec(stdout);
- var htmlTransfered = parseInt(m[1]);
+ const htmlTransfered = parseInt(m[1]);
assert.equal(bodyLength, documentLength);
assert.equal(completeRequests * documentLength, htmlTransfered);
diff --git a/test/parallel/test-http-get-pipeline-problem.js b/test/parallel/test-http-get-pipeline-problem.js
index cc681f675a791e..15c96a9a4e12ea 100644
--- a/test/parallel/test-http-get-pipeline-problem.js
+++ b/test/parallel/test-http-get-pipeline-problem.js
@@ -2,23 +2,23 @@
// In previous versions of Node.js (e.g., 0.6.0), this sort of thing would halt
// after http.globalAgent.maxSockets number of files.
// See https://groups.google.com/forum/#!topic/nodejs-dev/V5fB69hFa9o
-var common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const http = require('http');
+const fs = require('fs');
http.globalAgent.maxSockets = 1;
common.refreshTmpDir();
-var image = fs.readFileSync(common.fixturesDir + '/person.jpg');
+const image = fs.readFileSync(common.fixturesDir + '/person.jpg');
console.log('image.length = ' + image.length);
-var total = 10;
-var requests = 0, responses = 0;
+const total = 10;
+let requests = 0, responses = 0;
-var server = http.Server(function(req, res) {
+const server = http.Server(function(req, res) {
if (++requests === total) {
server.close();
}
@@ -35,18 +35,18 @@ var server = http.Server(function(req, res) {
server.listen(0, function() {
- for (var i = 0; i < total; i++) {
+ for (let i = 0; i < total; i++) {
(function() {
- var x = i;
+ const x = i;
- var opts = {
+ const opts = {
port: server.address().port,
headers: { connection: 'close' }
};
http.get(opts, function(res) {
console.error('recv ' + x);
- var s = fs.createWriteStream(common.tmpDir + '/' + x + '.jpg');
+ const s = fs.createWriteStream(common.tmpDir + '/' + x + '.jpg');
res.pipe(s);
s.on('finish', function() {
@@ -64,16 +64,16 @@ server.listen(0, function() {
});
-var checkedFiles = false;
+let checkedFiles = false;
function checkFiles() {
// Should see 1.jpg, 2.jpg, ..., 100.jpg in tmpDir
- var files = fs.readdirSync(common.tmpDir);
+ const files = fs.readdirSync(common.tmpDir);
assert(total <= files.length);
- for (var i = 0; i < total; i++) {
- var fn = i + '.jpg';
+ for (let i = 0; i < total; i++) {
+ const fn = i + '.jpg';
assert.ok(files.indexOf(fn) >= 0, "couldn't find '" + fn + "'");
- var stat = fs.statSync(common.tmpDir + '/' + fn);
+ const stat = fs.statSync(common.tmpDir + '/' + fn);
assert.equal(image.length, stat.size,
"size doesn't match on '" + fn +
"'. Got " + stat.size + ' bytes');
diff --git a/test/parallel/test-http-head-request.js b/test/parallel/test-http-head-request.js
index e8626b18811bda..de94dfb8b7d6e7 100644
--- a/test/parallel/test-http-head-request.js
+++ b/test/parallel/test-http-head-request.js
@@ -1,11 +1,11 @@
'use strict';
const common = require('../common');
-var http = require('http');
+const http = require('http');
-var body = 'hello world\n';
+const body = 'hello world\n';
function test(headers) {
- var server = http.createServer(function(req, res) {
+ const server = http.createServer(function(req, res) {
console.error('req: %s headers: %j', req.method, headers);
res.writeHead(200, headers);
res.end();
@@ -13,7 +13,7 @@ function test(headers) {
});
server.listen(0, common.mustCall(function() {
- var request = http.request({
+ const request = http.request({
port: this.address().port,
method: 'HEAD',
path: '/'
diff --git a/test/parallel/test-http-head-response-has-no-body-end.js b/test/parallel/test-http-head-response-has-no-body-end.js
index 87ce957df3499f..de5ca976fc47b0 100644
--- a/test/parallel/test-http-head-response-has-no-body-end.js
+++ b/test/parallel/test-http-head-response-has-no-body-end.js
@@ -1,19 +1,19 @@
'use strict';
const common = require('../common');
-var http = require('http');
+const http = require('http');
// This test is to make sure that when the HTTP server
// responds to a HEAD request with data to res.end,
// it does not send any body.
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.writeHead(200);
res.end('FAIL'); // broken: sends FAIL from hot path.
});
server.listen(0);
server.on('listening', common.mustCall(function() {
- var req = http.request({
+ const req = http.request({
port: this.address().port,
method: 'HEAD',
path: '/'
diff --git a/test/parallel/test-http-head-response-has-no-body.js b/test/parallel/test-http-head-response-has-no-body.js
index 445b522b8dea51..b2eb98b1eea06c 100644
--- a/test/parallel/test-http-head-response-has-no-body.js
+++ b/test/parallel/test-http-head-response-has-no-body.js
@@ -1,19 +1,19 @@
'use strict';
const common = require('../common');
-var http = require('http');
+const http = require('http');
// This test is to make sure that when the HTTP server
// responds to a HEAD request, it does not send any body.
// In this case it was sending '0\r\n\r\n'
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.writeHead(200); // broken: defaults to TE chunked
res.end();
});
server.listen(0);
server.on('listening', common.mustCall(function() {
- var req = http.request({
+ const req = http.request({
port: this.address().port,
method: 'HEAD',
path: '/'
diff --git a/test/parallel/test-http-header-read.js b/test/parallel/test-http-header-read.js
index b726fe130f0ee4..3d9e756d505238 100644
--- a/test/parallel/test-http-header-read.js
+++ b/test/parallel/test-http-header-read.js
@@ -1,14 +1,14 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
// Verify that ServerResponse.getHeader() works correctly even after
// the response header has been sent. Issue 752 on github.
-var s = http.createServer(function(req, res) {
- var contentType = 'Content-Type';
- var plain = 'text/plain';
+const s = http.createServer(function(req, res) {
+ const contentType = 'Content-Type';
+ const plain = 'text/plain';
res.setHeader(contentType, plain);
assert.ok(!res.headersSent);
res.writeHead(200);
diff --git a/test/parallel/test-http-hex-write.js b/test/parallel/test-http-hex-write.js
index adfe18077a8259..211f818e566699 100644
--- a/test/parallel/test-http-hex-write.js
+++ b/test/parallel/test-http-hex-write.js
@@ -1,10 +1,10 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var http = require('http');
+const http = require('http');
-var expect = 'hex\nutf8\n';
+const expect = 'hex\nutf8\n';
http.createServer(function(q, s) {
s.setHeader('content-length', expect.length);
@@ -15,7 +15,7 @@ http.createServer(function(q, s) {
}).listen(0, common.mustCall(function() {
http.request({ port: this.address().port })
.on('response', common.mustCall(function(res) {
- var data = '';
+ let data = '';
res.setEncoding('ascii');
res.on('data', function(c) {
diff --git a/test/parallel/test-http-host-header-ipv6-fail.js b/test/parallel/test-http-host-header-ipv6-fail.js
index 5f81234edba352..94351bc5c167e4 100644
--- a/test/parallel/test-http-host-header-ipv6-fail.js
+++ b/test/parallel/test-http-host-header-ipv6-fail.js
@@ -16,7 +16,7 @@ const http = require('http');
const hostname = '::1';
function httpreq() {
- var req = http.request({
+ const req = http.request({
host: hostname,
port: server.address().port,
path: '/',
diff --git a/test/parallel/test-http-host-headers.js b/test/parallel/test-http-host-headers.js
index 863dbae365d164..b7a916816ffe1d 100644
--- a/test/parallel/test-http-host-headers.js
+++ b/test/parallel/test-http-host-headers.js
@@ -20,7 +20,7 @@ testHttp();
function testHttp() {
- var counter = 0;
+ let counter = 0;
function cb(res) {
counter--;
diff --git a/test/parallel/test-http-invalidheaderfield.js b/test/parallel/test-http-invalidheaderfield.js
index 9d4a12a952a838..aaed46c69cd592 100644
--- a/test/parallel/test-http-invalidheaderfield.js
+++ b/test/parallel/test-http-invalidheaderfield.js
@@ -5,7 +5,7 @@ const EventEmitter = require('events');
const http = require('http');
const ee = new EventEmitter();
-var count = 3;
+let count = 3;
const server = http.createServer(function(req, res) {
assert.doesNotThrow(function() {
@@ -24,7 +24,7 @@ server.listen(0, function() {
assert.throws(
function() {
- var options = {
+ const options = {
port: server.address().port,
headers: {'testing 123': 123}
};
@@ -38,7 +38,7 @@ server.listen(0, function() {
assert.doesNotThrow(
function() {
- var options = {
+ const options = {
port: server.address().port,
headers: {'testing_123': 123}
};
diff --git a/test/parallel/test-http-keep-alive-close-on-header.js b/test/parallel/test-http-keep-alive-close-on-header.js
index d9396b258e7515..15d5d62d429658 100644
--- a/test/parallel/test-http-keep-alive-close-on-header.js
+++ b/test/parallel/test-http-keep-alive-close-on-header.js
@@ -1,24 +1,24 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var body = 'hello world\n';
-var headers = {'connection': 'keep-alive'};
+const body = 'hello world\n';
+const headers = {'connection': 'keep-alive'};
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Length': body.length, 'Connection': 'close'});
res.write(body);
res.end();
});
-var connectCount = 0;
+let connectCount = 0;
server.listen(0, function() {
- var agent = new http.Agent({ maxSockets: 1 });
- var name = agent.getName({ port: this.address().port });
- var request = http.request({
+ const agent = new http.Agent({ maxSockets: 1 });
+ const name = agent.getName({ port: this.address().port });
+ let request = http.request({
method: 'GET',
path: '/',
headers: headers,
diff --git a/test/parallel/test-http-keepalive-client.js b/test/parallel/test-http-keepalive-client.js
index 955fc006e22d58..1fcf12b0dbcddf 100644
--- a/test/parallel/test-http-keepalive-client.js
+++ b/test/parallel/test-http-keepalive-client.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var http = require('http');
+const http = require('http');
-var serverSocket = null;
-var server = http.createServer(function(req, res) {
+let serverSocket = null;
+const server = http.createServer(function(req, res) {
// They should all come in on the same server socket.
if (serverSocket) {
assert.equal(req.socket, serverSocket);
@@ -20,12 +20,12 @@ server.listen(0, function() {
makeRequest(expectRequests);
});
-var agent = http.Agent({ keepAlive: true });
+const agent = http.Agent({ keepAlive: true });
-var clientSocket = null;
-var expectRequests = 10;
-var actualRequests = 0;
+let clientSocket = null;
+let expectRequests = 10;
+let actualRequests = 0;
function makeRequest(n) {
@@ -35,7 +35,7 @@ function makeRequest(n) {
return;
}
- var req = http.request({
+ const req = http.request({
port: server.address().port,
agent: agent,
path: '/' + n
@@ -52,7 +52,7 @@ function makeRequest(n) {
});
req.on('response', function(res) {
- var data = '';
+ let data = '';
res.setEncoding('utf8');
res.on('data', function(c) {
data += c;
diff --git a/test/parallel/test-http-keepalive-maxsockets.js b/test/parallel/test-http-keepalive-maxsockets.js
index 6f1476d0ce3aed..14e9e88ef7fd09 100644
--- a/test/parallel/test-http-keepalive-maxsockets.js
+++ b/test/parallel/test-http-keepalive-maxsockets.js
@@ -1,25 +1,25 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var http = require('http');
+const http = require('http');
-var serverSockets = [];
-var server = http.createServer(function(req, res) {
+const serverSockets = [];
+const server = http.createServer(function(req, res) {
if (serverSockets.indexOf(req.socket) === -1) {
serverSockets.push(req.socket);
}
res.end(req.url);
});
server.listen(0, function() {
- var agent = http.Agent({
+ const agent = http.Agent({
keepAlive: true,
maxSockets: 5,
maxFreeSockets: 2
});
- var closed = false;
+ let closed = false;
makeReqs(10, function(er) {
assert.ifError(er);
assert.equal(count(agent.freeSockets), 2);
@@ -49,7 +49,7 @@ server.listen(0, function() {
// make 10 requests in parallel,
// then 10 more when they all finish.
function makeReqs(n, cb) {
- for (var i = 0; i < n; i++)
+ for (let i = 0; i < n; i++)
makeReq(i, then);
function then(er) {
@@ -66,7 +66,7 @@ server.listen(0, function() {
path: '/' + i,
agent: agent
}, function(res) {
- var data = '';
+ let data = '';
res.setEncoding('ascii');
res.on('data', function(c) {
data += c;
diff --git a/test/parallel/test-http-keepalive-request.js b/test/parallel/test-http-keepalive-request.js
index daae5aa9944294..b9e9f1e9798cfc 100644
--- a/test/parallel/test-http-keepalive-request.js
+++ b/test/parallel/test-http-keepalive-request.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var http = require('http');
+const http = require('http');
-var serverSocket = null;
-var server = http.createServer(function(req, res) {
+let serverSocket = null;
+const server = http.createServer(function(req, res) {
// They should all come in on the same server socket.
if (serverSocket) {
assert.equal(req.socket, serverSocket);
@@ -20,12 +20,12 @@ server.listen(0, function() {
makeRequest(expectRequests);
});
-var agent = http.Agent({ keepAlive: true });
+const agent = http.Agent({ keepAlive: true });
-var clientSocket = null;
-var expectRequests = 10;
-var actualRequests = 0;
+let clientSocket = null;
+let expectRequests = 10;
+let actualRequests = 0;
function makeRequest(n) {
@@ -35,7 +35,7 @@ function makeRequest(n) {
return;
}
- var req = http.request({
+ const req = http.request({
port: server.address().port,
path: '/' + n,
agent: agent
@@ -52,7 +52,7 @@ function makeRequest(n) {
});
req.on('response', function(res) {
- var data = '';
+ let data = '';
res.setEncoding('utf8');
res.on('data', function(c) {
data += c;
diff --git a/test/parallel/test-http-legacy.js b/test/parallel/test-http-legacy.js
index 165e51ff418ed0..bf2f83d71bbc2a 100644
--- a/test/parallel/test-http-legacy.js
+++ b/test/parallel/test-http-legacy.js
@@ -1,14 +1,14 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var url = require('url');
+const assert = require('assert');
+const http = require('http');
+const url = require('url');
-var responses_sent = 0;
-var body0 = '';
-var body1 = '';
+let responses_sent = 0;
+let body0 = '';
+let body1 = '';
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
if (responses_sent === 0) {
assert.equal('GET', req.method);
assert.equal('/hello', url.parse(req.url).pathname);
@@ -37,8 +37,8 @@ var server = http.createServer(function(req, res) {
});
server.listen(0, common.mustCall(function() {
- var client = http.createClient(this.address().port);
- var req = client.request('/hello', {'Accept': '*/*', 'Foo': 'bar'});
+ const client = http.createClient(this.address().port);
+ const req = client.request('/hello', {'Accept': '*/*', 'Foo': 'bar'});
setTimeout(function() {
req.end();
}, 100);
@@ -50,7 +50,7 @@ server.listen(0, common.mustCall(function() {
}));
setTimeout(common.mustCall(function() {
- var req = client.request('POST', '/world');
+ const req = client.request('POST', '/world');
req.end();
req.on('response', common.mustCall(function(res) {
assert.equal(200, res.statusCode);
diff --git a/test/parallel/test-http-localaddress-bind-error.js b/test/parallel/test-http-localaddress-bind-error.js
index 0b828910f12873..a23c6f2a4452a6 100644
--- a/test/parallel/test-http-localaddress-bind-error.js
+++ b/test/parallel/test-http-localaddress-bind-error.js
@@ -1,10 +1,10 @@
'use strict';
const common = require('../common');
-var http = require('http');
+const http = require('http');
-var invalidLocalAddress = '1.2.3.4';
+const invalidLocalAddress = '1.2.3.4';
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
console.log('Connect from: ' + req.connection.remoteAddress);
req.on('end', function() {
diff --git a/test/parallel/test-http-localaddress.js b/test/parallel/test-http-localaddress.js
index d507d12ec89e25..e8df6888866f9c 100644
--- a/test/parallel/test-http-localaddress.js
+++ b/test/parallel/test-http-localaddress.js
@@ -8,7 +8,7 @@ if (!common.hasMultiLocalhost()) {
return;
}
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
console.log('Connect from: ' + req.connection.remoteAddress);
assert.equal('127.0.0.2', req.connection.remoteAddress);
@@ -20,13 +20,13 @@ var server = http.createServer(function(req, res) {
});
server.listen(0, '127.0.0.1', function() {
- var options = { host: 'localhost',
- port: this.address().port,
- path: '/',
- method: 'GET',
- localAddress: '127.0.0.2' };
+ const options = { host: 'localhost',
+ port: this.address().port,
+ path: '/',
+ method: 'GET',
+ localAddress: '127.0.0.2' };
- var req = http.request(options, function(res) {
+ const req = http.request(options, function(res) {
res.on('end', function() {
server.close();
process.exit();
diff --git a/test/parallel/test-http-malformed-request.js b/test/parallel/test-http-malformed-request.js
index 647b67bcd3ff78..a36c9fdbe29451 100644
--- a/test/parallel/test-http-malformed-request.js
+++ b/test/parallel/test-http-malformed-request.js
@@ -1,17 +1,17 @@
'use strict';
require('../common');
-var assert = require('assert');
-var net = require('net');
-var http = require('http');
-var url = require('url');
+const assert = require('assert');
+const net = require('net');
+const http = require('http');
+const url = require('url');
// Make sure no exceptions are thrown when receiving malformed HTTP
// requests.
-var nrequests_completed = 0;
-var nrequests_expected = 1;
+let nrequests_completed = 0;
+const nrequests_expected = 1;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
console.log('req: ' + JSON.stringify(url.parse(req.url)));
res.writeHead(200, {'Content-Type': 'text/plain'});
@@ -23,7 +23,7 @@ var server = http.createServer(function(req, res) {
server.listen(0);
server.on('listening', function() {
- var c = net.createConnection(this.address().port);
+ const c = net.createConnection(this.address().port);
c.on('connect', function() {
c.write('GET /hello?foo=%99bar HTTP/1.1\r\n\r\n');
c.end();
diff --git a/test/parallel/test-http-many-ended-pipelines.js b/test/parallel/test-http-many-ended-pipelines.js
index 7966f47a9efa19..1d443d0b2b5dc4 100644
--- a/test/parallel/test-http-many-ended-pipelines.js
+++ b/test/parallel/test-http-many-ended-pipelines.js
@@ -2,19 +2,19 @@
require('../common');
// no warnings should happen!
-var trace = console.trace;
+const trace = console.trace;
console.trace = function() {
trace.apply(console, arguments);
throw new Error('no tracing should happen here');
};
-var http = require('http');
-var net = require('net');
+const http = require('http');
+const net = require('net');
-var numRequests = 20;
-var first = false;
+const numRequests = 20;
+let first = false;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
if (!first) {
first = true;
req.socket.on('close', function() {
@@ -28,8 +28,9 @@ var server = http.createServer(function(req, res) {
});
server.listen(0, function() {
- var client = net.connect({ port: this.address().port, allowHalfOpen: true });
- for (var i = 0; i < numRequests; i++) {
+ const client =
+ net.connect({ port: this.address().port, allowHalfOpen: true });
+ for (let i = 0; i < numRequests; i++) {
client.write('GET / HTTP/1.1\r\n' +
'Host: some.host.name\r\n' +
'\r\n\r\n');
diff --git a/test/parallel/test-http-max-headers-count.js b/test/parallel/test-http-max-headers-count.js
index 2d68ead110fc6c..018ed33c1b9e49 100644
--- a/test/parallel/test-http-max-headers-count.js
+++ b/test/parallel/test-http-max-headers-count.js
@@ -1,26 +1,26 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var requests = 0;
-var responses = 0;
+let requests = 0;
+let responses = 0;
-var headers = {};
-var N = 2000;
-for (var i = 0; i < N; ++i) {
+const headers = {};
+const N = 2000;
+for (let i = 0; i < N; ++i) {
headers['key' + i] = i;
}
-var maxAndExpected = [ // for server
+const maxAndExpected = [ // for server
[50, 50],
[1500, 1500],
[0, N + 2] // Host and Connection
];
-var max = maxAndExpected[requests][0];
-var expected = maxAndExpected[requests][1];
+let max = maxAndExpected[requests][0];
+let expected = maxAndExpected[requests][1];
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
assert.equal(Object.keys(req.headers).length, expected);
if (++requests < maxAndExpected.length) {
max = maxAndExpected[requests][0];
@@ -33,7 +33,7 @@ var server = http.createServer(function(req, res) {
server.maxHeadersCount = max;
server.listen(0, function() {
- var maxAndExpected = [ // for client
+ const maxAndExpected = [ // for client
[20, 20],
[1200, 1200],
[0, N + 3] // Connection, Date and Transfer-Encoding
@@ -41,9 +41,9 @@ server.listen(0, function() {
doRequest();
function doRequest() {
- var max = maxAndExpected[responses][0];
- var expected = maxAndExpected[responses][1];
- var req = http.request({
+ const max = maxAndExpected[responses][0];
+ const expected = maxAndExpected[responses][1];
+ const req = http.request({
port: server.address().port,
headers: headers
}, function(res) {
diff --git a/test/parallel/test-http-methods.js b/test/parallel/test-http-methods.js
index d3d4fedd46361b..6ba02807f8706b 100644
--- a/test/parallel/test-http-methods.js
+++ b/test/parallel/test-http-methods.js
@@ -1,8 +1,8 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var util = require('util');
+const assert = require('assert');
+const http = require('http');
+const util = require('util');
assert(Array.isArray(http.METHODS));
assert(http.METHODS.length > 0);
diff --git a/test/parallel/test-http-multi-line-headers.js b/test/parallel/test-http-multi-line-headers.js
index df333cdd62bf9b..2096f533a196d1 100644
--- a/test/parallel/test-http-multi-line-headers.js
+++ b/test/parallel/test-http-multi-line-headers.js
@@ -1,14 +1,14 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var http = require('http');
-var net = require('net');
+const http = require('http');
+const net = require('net');
-var server = net.createServer(function(conn) {
- var body = 'Yet another node.js server.';
+const server = net.createServer(function(conn) {
+ const body = 'Yet another node.js server.';
- var response =
+ const response =
'HTTP/1.1 200 OK\r\n' +
'Connection: close\r\n' +
'Content-Length: ' + body.length + '\r\n' +
diff --git a/test/parallel/test-http-mutable-headers.js b/test/parallel/test-http-mutable-headers.js
index 0228a4e216ec46..fcff395cffe9bb 100644
--- a/test/parallel/test-http-mutable-headers.js
+++ b/test/parallel/test-http-mutable-headers.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
// Simple test of Node's HTTP Client mutable headers
// OutgoingMessage.prototype.setHeader(name, value)
@@ -11,15 +11,15 @@ var http = require('http');
// .method
// .path
-var testsComplete = 0;
-var test = 'headers';
-var content = 'hello world\n';
-var cookies = [
+let testsComplete = 0;
+let test = 'headers';
+const content = 'hello world\n';
+const cookies = [
'session_token=; path=/; expires=Sun, 15-Sep-2030 13:48:52 GMT',
'prefers_open_id=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT'
];
-var s = http.createServer(function(req, res) {
+const s = http.createServer(function(req, res) {
switch (test) {
case 'headers':
assert.throws(function() { res.setHeader(); });
@@ -32,8 +32,8 @@ var s = http.createServer(function(req, res) {
res.setHeader('set-cookie', cookies);
res.setHeader('x-test-array-header', [1, 2, 3]);
- var val1 = res.getHeader('x-test-header');
- var val2 = res.getHeader('x-test-header2');
+ const val1 = res.getHeader('x-test-header');
+ const val2 = res.getHeader('x-test-header2');
assert.equal(val1, 'testing');
assert.equal(val2, 'testing');
@@ -69,7 +69,7 @@ function nextTest() {
return s.close();
}
- var bufferedResponse = '';
+ let bufferedResponse = '';
http.get({ port: s.address().port }, function(response) {
console.log('TEST: ' + test);
diff --git a/test/parallel/test-http-no-content-length.js b/test/parallel/test-http-no-content-length.js
index b27ffda727129e..a6cfad13aa2b44 100644
--- a/test/parallel/test-http-no-content-length.js
+++ b/test/parallel/test-http-no-content-length.js
@@ -1,15 +1,15 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var net = require('net');
-var http = require('http');
+const assert = require('assert');
+const net = require('net');
+const http = require('http');
-var server = net.createServer(function(socket) {
+const server = net.createServer(function(socket) {
// Neither Content-Length nor Connection
socket.end('HTTP/1.1 200 ok\r\n\r\nHello');
}).listen(0, common.mustCall(function() {
http.get({port: this.address().port}, common.mustCall(function(res) {
- var body = '';
+ let body = '';
res.setEncoding('utf8');
res.on('data', function(chunk) {
diff --git a/test/parallel/test-http-outgoing-finish.js b/test/parallel/test-http-outgoing-finish.js
index 56ce777cb3eaaf..73654909d88e1b 100644
--- a/test/parallel/test-http-outgoing-finish.js
+++ b/test/parallel/test-http-outgoing-finish.js
@@ -1,8 +1,8 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var http = require('http');
+const http = require('http');
http.createServer(function(req, res) {
req.resume();
@@ -11,7 +11,7 @@ http.createServer(function(req, res) {
});
this.close();
}).listen(0, function() {
- var req = http.request({
+ const req = http.request({
port: this.address().port,
method: 'PUT'
});
@@ -21,11 +21,11 @@ http.createServer(function(req, res) {
});
});
-var buf = Buffer.alloc(1024 * 16, 'x');
+const buf = Buffer.alloc(1024 * 16, 'x');
function write(out) {
- var name = out.constructor.name;
- var finishEvent = false;
- var endCb = false;
+ const name = out.constructor.name;
+ let finishEvent = false;
+ let endCb = false;
// first, write until it gets some backpressure
while (out.write(buf)) {}
diff --git a/test/parallel/test-http-parser-bad-ref.js b/test/parallel/test-http-parser-bad-ref.js
index 73d5f7eb13049c..69682128fadbdf 100644
--- a/test/parallel/test-http-parser-bad-ref.js
+++ b/test/parallel/test-http-parser-bad-ref.js
@@ -5,16 +5,16 @@
// Flags: --expose_gc
require('../common');
-var assert = require('assert');
-var HTTPParser = process.binding('http_parser').HTTPParser;
+const assert = require('assert');
+const HTTPParser = process.binding('http_parser').HTTPParser;
-var kOnHeaders = HTTPParser.kOnHeaders | 0;
-var kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0;
-var kOnBody = HTTPParser.kOnBody | 0;
-var kOnMessageComplete = HTTPParser.kOnMessageComplete | 0;
+const kOnHeaders = HTTPParser.kOnHeaders | 0;
+const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0;
+const kOnBody = HTTPParser.kOnBody | 0;
+const kOnMessageComplete = HTTPParser.kOnMessageComplete | 0;
-var headersComplete = 0;
-var messagesComplete = 0;
+let headersComplete = 0;
+let messagesComplete = 0;
function flushPool() {
Buffer.allocUnsafe(Buffer.poolSize - 1);
@@ -24,7 +24,7 @@ function flushPool() {
function demoBug(part1, part2) {
flushPool();
- var parser = new HTTPParser('REQUEST');
+ const parser = new HTTPParser('REQUEST');
parser.headers = [];
parser.url = '';
@@ -49,7 +49,7 @@ function demoBug(part1, part2) {
// We use a function to eliminate references to the Buffer b
// We want b to be GCed. The parser will hold a bad reference to it.
(function() {
- var b = Buffer.from(part1);
+ const b = Buffer.from(part1);
flushPool();
console.log('parse the first part of the message');
@@ -59,7 +59,7 @@ function demoBug(part1, part2) {
flushPool();
(function() {
- var b = Buffer.from(part2);
+ const b = Buffer.from(part2);
console.log('parse the second part of the message');
parser.execute(b, 0, b.length);
diff --git a/test/parallel/test-http-parser-free.js b/test/parallel/test-http-parser-free.js
index 125374bbedde63..80cc3cc64ee5b3 100644
--- a/test/parallel/test-http-parser-free.js
+++ b/test/parallel/test-http-parser-free.js
@@ -1,20 +1,20 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var N = 100;
-var responses = 0;
+const assert = require('assert');
+const http = require('http');
+const N = 100;
+let responses = 0;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.end('Hello');
});
server.listen(0, function() {
http.globalAgent.maxSockets = 1;
- var parser;
- for (var i = 0; i < N; ++i) {
+ let parser;
+ for (let i = 0; i < N; ++i) {
(function makeRequest(i) {
- var req = http.get({port: server.address().port}, function(res) {
+ const req = http.get({port: server.address().port}, function(res) {
if (!parser) {
parser = req.parser;
} else {
diff --git a/test/parallel/test-http-parser.js b/test/parallel/test-http-parser.js
index abc1d096dff0d8..e1215fbd13ae40 100644
--- a/test/parallel/test-http-parser.js
+++ b/test/parallel/test-http-parser.js
@@ -1,19 +1,19 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
const binding = process.binding('http_parser');
const methods = binding.methods;
const HTTPParser = binding.HTTPParser;
-var CRLF = '\r\n';
-var REQUEST = HTTPParser.REQUEST;
-var RESPONSE = HTTPParser.RESPONSE;
+const CRLF = '\r\n';
+const REQUEST = HTTPParser.REQUEST;
+const RESPONSE = HTTPParser.RESPONSE;
-var kOnHeaders = HTTPParser.kOnHeaders | 0;
-var kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0;
-var kOnBody = HTTPParser.kOnBody | 0;
-var kOnMessageComplete = HTTPParser.kOnMessageComplete | 0;
+const kOnHeaders = HTTPParser.kOnHeaders | 0;
+const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0;
+const kOnBody = HTTPParser.kOnBody | 0;
+const kOnMessageComplete = HTTPParser.kOnMessageComplete | 0;
// The purpose of this test is not to check HTTP compliance but to test the
// binding. Tests for pathological http messages should be submitted
@@ -22,7 +22,7 @@ var kOnMessageComplete = HTTPParser.kOnMessageComplete | 0;
function newParser(type) {
- var parser = new HTTPParser(type);
+ const parser = new HTTPParser(type);
parser.headers = [];
parser.url = '';
@@ -47,7 +47,7 @@ function newParser(type) {
function mustCall(f, times) {
- var actual = 0;
+ let actual = 0;
process.setMaxListeners(256);
process.on('exit', function() {
@@ -63,7 +63,7 @@ function mustCall(f, times) {
function expectBody(expected) {
return mustCall(function(buf, start, len) {
- var body = '' + buf.slice(start, start + len);
+ const body = '' + buf.slice(start, start + len);
assert.equal(body, expected);
});
}
@@ -447,11 +447,11 @@ function expectBody(expected) {
assert.strictEqual(expected_body, '');
}
- for (var i = 1; i < request.length - 1; ++i) {
- var a = request.slice(0, i);
+ for (let i = 1; i < request.length - 1; ++i) {
+ const a = request.slice(0, i);
console.error('request.slice(0, ' + i + ') = ',
JSON.stringify(a.toString()));
- var b = request.slice(i);
+ const b = request.slice(i);
console.error('request.slice(' + i + ') = ',
JSON.stringify(b.toString()));
test(a, b);
@@ -571,11 +571,11 @@ function expectBody(expected) {
// Test parser 'this' safety
// https://github.com/joyent/node/issues/6690
assert.throws(function() {
- var request = Buffer.from(
+ const request = Buffer.from(
'GET /hello HTTP/1.1' + CRLF +
CRLF);
- var parser = newParser(REQUEST);
- var notparser = { execute: parser.execute };
+ const parser = newParser(REQUEST);
+ const notparser = { execute: parser.execute };
notparser.execute(request, 0, request.length);
}, TypeError);
diff --git a/test/parallel/test-http-pause.js b/test/parallel/test-http-pause.js
index f6562b3afc94ae..8bb8dd4b5da25c 100644
--- a/test/parallel/test-http-pause.js
+++ b/test/parallel/test-http-pause.js
@@ -1,14 +1,14 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var expectedServer = 'Request Body from Client';
-var resultServer = '';
-var expectedClient = 'Response Body from Server';
-var resultClient = '';
+const expectedServer = 'Request Body from Client';
+let resultServer = '';
+const expectedClient = 'Response Body from Server';
+let resultClient = '';
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
console.error('pause server request');
req.pause();
setTimeout(function() {
@@ -27,7 +27,7 @@ var server = http.createServer(function(req, res) {
});
server.listen(0, function() {
- var req = http.request({
+ const req = http.request({
port: this.address().port,
path: '/',
method: 'POST'
diff --git a/test/parallel/test-http-pipe-fs.js b/test/parallel/test-http-pipe-fs.js
index 3205802d7ab0f2..5348637bd07145 100644
--- a/test/parallel/test-http-pipe-fs.js
+++ b/test/parallel/test-http-pipe-fs.js
@@ -1,15 +1,15 @@
'use strict';
-var common = require('../common');
-var http = require('http');
-var fs = require('fs');
-var path = require('path');
+const common = require('../common');
+const http = require('http');
+const fs = require('fs');
+const path = require('path');
common.refreshTmpDir();
-var file = path.join(common.tmpDir, 'http-pipe-fs-test.txt');
+const file = path.join(common.tmpDir, 'http-pipe-fs-test.txt');
-var server = http.createServer(common.mustCall(function(req, res) {
- var stream = fs.createWriteStream(file);
+const server = http.createServer(common.mustCall(function(req, res) {
+ const stream = fs.createWriteStream(file);
req.pipe(stream);
stream.on('close', function() {
res.writeHead(200);
@@ -18,9 +18,9 @@ var server = http.createServer(common.mustCall(function(req, res) {
}, 2)).listen(0, function() {
http.globalAgent.maxSockets = 1;
- for (var i = 0; i < 2; ++i) {
+ for (let i = 0; i < 2; ++i) {
(function(i) {
- var req = http.request({
+ const req = http.request({
port: server.address().port,
method: 'POST',
headers: {
diff --git a/test/parallel/test-http-pipeline-flood.js b/test/parallel/test-http-pipeline-flood.js
index 4f6775656e4e49..99e4c3e7b5b9fe 100644
--- a/test/parallel/test-http-pipeline-flood.js
+++ b/test/parallel/test-http-pipeline-flood.js
@@ -26,7 +26,7 @@ switch (process.argv[2]) {
function parent() {
const http = require('http');
const bigResponse = Buffer.alloc(10240, 'x');
- var backloggedReqs = 0;
+ let backloggedReqs = 0;
const server = http.createServer(function(req, res) {
res.setHeader('content-length', bigResponse.length);
@@ -68,7 +68,7 @@ function child() {
const port = +process.argv[3];
const conn = net.connect({ port: port });
- var req = `GET / HTTP/1.1\r\nHost: localhost:${port}\r\nAccept: */*\r\n\r\n`;
+ let req = `GET / HTTP/1.1\r\nHost: localhost:${port}\r\nAccept: */*\r\n\r\n`;
req = new Array(10241).join(req);
diff --git a/test/parallel/test-http-pipeline-regr-2639.js b/test/parallel/test-http-pipeline-regr-2639.js
index f67803ba159c74..7933e419d324f7 100644
--- a/test/parallel/test-http-pipeline-regr-2639.js
+++ b/test/parallel/test-http-pipeline-regr-2639.js
@@ -6,9 +6,9 @@ const net = require('net');
const COUNT = 10;
-var received = 0;
+let received = 0;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
// Close the server, we have only one TCP connection anyway
if (received++ === 0)
server.close();
@@ -22,7 +22,7 @@ var server = http.createServer(function(req, res) {
}).listen(0, function() {
const s = net.connect(this.address().port);
- var big = 'GET / HTTP/1.0\r\n\r\n'.repeat(COUNT);
+ const big = 'GET / HTTP/1.0\r\n\r\n'.repeat(COUNT);
s.write(big);
s.resume();
diff --git a/test/parallel/test-http-pipeline-regr-3332.js b/test/parallel/test-http-pipeline-regr-3332.js
index fdbb76bf8d643d..3ab9e6104c9848 100644
--- a/test/parallel/test-http-pipeline-regr-3332.js
+++ b/test/parallel/test-http-pipeline-regr-3332.js
@@ -8,9 +8,9 @@ const big = Buffer.alloc(16 * 1024, 'A');
const COUNT = 1e4;
-var received = 0;
+let received = 0;
-var client;
+let client;
const server = http.createServer(function(req, res) {
res.end(big, function() {
if (++received === COUNT) {
@@ -19,7 +19,7 @@ const server = http.createServer(function(req, res) {
}
});
}).listen(0, function() {
- var req = new Array(COUNT + 1).join('GET / HTTP/1.1\r\n\r\n');
+ const req = new Array(COUNT + 1).join('GET / HTTP/1.1\r\n\r\n');
client = net.connect(this.address().port, function() {
client.write(req);
});
diff --git a/test/parallel/test-http-pipeline-regr-3508.js b/test/parallel/test-http-pipeline-regr-3508.js
index b368bae0d7790e..ff735818f68121 100644
--- a/test/parallel/test-http-pipeline-regr-3508.js
+++ b/test/parallel/test-http-pipeline-regr-3508.js
@@ -3,18 +3,18 @@ require('../common');
const http = require('http');
const net = require('net');
-var once = false;
-var first = null;
-var second = null;
+let once = false;
+let first = null;
+let second = null;
const chunk = Buffer.alloc(1024, 'X');
-var size = 0;
+let size = 0;
-var more;
-var done;
+let more;
+let done;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
if (!once)
server.close();
once = true;
@@ -41,7 +41,7 @@ var server = http.createServer(function(req, res) {
});
first.end('hello');
}).listen(0, function() {
- var s = net.connect(this.address().port);
+ const s = net.connect(this.address().port);
more = function() {
s.write('GET / HTTP/1.1\r\n\r\n');
};
diff --git a/test/parallel/test-http-proxy.js b/test/parallel/test-http-proxy.js
index 48367caaa7d89e..8e7fd55a0ed6ea 100644
--- a/test/parallel/test-http-proxy.js
+++ b/test/parallel/test-http-proxy.js
@@ -1,26 +1,26 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var url = require('url');
+const assert = require('assert');
+const http = require('http');
+const url = require('url');
-var cookies = [
+const cookies = [
'session_token=; path=/; expires=Sun, 15-Sep-2030 13:48:52 GMT',
'prefers_open_id=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT'
];
-var headers = {'content-type': 'text/plain',
- 'set-cookie': cookies,
- 'hello': 'world' };
+const headers = {'content-type': 'text/plain',
+ 'set-cookie': cookies,
+ 'hello': 'world' };
-var backend = http.createServer(function(req, res) {
+const backend = http.createServer(function(req, res) {
console.error('backend request');
res.writeHead(200, headers);
res.write('hello world\n');
res.end();
});
-var proxy = http.createServer(function(req, res) {
+const proxy = http.createServer(function(req, res) {
console.error('proxy req headers: ' + JSON.stringify(req.headers));
http.get({
port: backend.address().port,
@@ -46,9 +46,9 @@ var proxy = http.createServer(function(req, res) {
});
});
-var body = '';
+let body = '';
-var nlistening = 0;
+let nlistening = 0;
function startReq() {
nlistening++;
if (nlistening < 2) return;
diff --git a/test/parallel/test-http-raw-headers.js b/test/parallel/test-http-raw-headers.js
index 2e2e9631490395..7ae0c35e3d8d11 100644
--- a/test/parallel/test-http-raw-headers.js
+++ b/test/parallel/test-http-raw-headers.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var http = require('http');
+const http = require('http');
http.createServer(function(req, res) {
- var expectRawHeaders = [
+ const expectRawHeaders = [
'Host',
`localhost:${this.address().port}`,
'transfer-ENCODING',
@@ -15,13 +15,13 @@ http.createServer(function(req, res) {
'Connection',
'close'
];
- var expectHeaders = {
+ const expectHeaders = {
host: `localhost:${this.address().port}`,
'transfer-encoding': 'CHUNKED',
'x-bar': 'yoyoyo',
connection: 'close'
};
- var expectRawTrailers = [
+ const expectRawTrailers = [
'x-bAr',
'yOyOyOy',
'x-baR',
@@ -31,7 +31,7 @@ http.createServer(function(req, res) {
'X-baR',
'OyOyOyO'
];
- var expectTrailers = { 'x-bar': 'yOyOyOy, OyOyOyO, yOyOyOy, OyOyOyO' };
+ const expectTrailers = { 'x-bar': 'yOyOyOy, OyOyOyO, yOyOyOy, OyOyOyO' };
this.close();
@@ -53,7 +53,7 @@ http.createServer(function(req, res) {
]);
res.end('x f o o');
}).listen(0, function() {
- var req = http.request({ port: this.address().port, path: '/' });
+ const req = http.request({ port: this.address().port, path: '/' });
req.addTrailers([
['x-bAr', 'yOyOyOy'],
['x-baR', 'OyOyOyO'],
@@ -64,7 +64,7 @@ http.createServer(function(req, res) {
req.setHeader('x-BaR', 'yoyoyo');
req.end('y b a r');
req.on('response', function(res) {
- var expectRawHeaders = [
+ const expectRawHeaders = [
'Trailer',
'x-foo',
'Date',
@@ -74,7 +74,7 @@ http.createServer(function(req, res) {
'Transfer-Encoding',
'chunked'
];
- var expectHeaders = {
+ const expectHeaders = {
trailer: 'x-foo',
date: null,
connection: 'close',
@@ -85,7 +85,7 @@ http.createServer(function(req, res) {
assert.deepStrictEqual(res.rawHeaders, expectRawHeaders);
assert.deepStrictEqual(res.headers, expectHeaders);
res.on('end', function() {
- var expectRawTrailers = [
+ const expectRawTrailers = [
'x-fOo',
'xOxOxOx',
'x-foO',
@@ -95,7 +95,7 @@ http.createServer(function(req, res) {
'X-foO',
'OxOxOxO'
];
- var expectTrailers = { 'x-foo': 'xOxOxOx, OxOxOxO, xOxOxOx, OxOxOxO' };
+ const expectTrailers = { 'x-foo': 'xOxOxOx, OxOxOxO, xOxOxOx, OxOxOxO' };
assert.deepStrictEqual(res.rawTrailers, expectRawTrailers);
assert.deepStrictEqual(res.trailers, expectTrailers);
diff --git a/test/parallel/test-http-remove-header-stays-removed.js b/test/parallel/test-http-remove-header-stays-removed.js
index 9b8ff35b0fe5d3..077ff0f5b33f40 100644
--- a/test/parallel/test-http-remove-header-stays-removed.js
+++ b/test/parallel/test-http-remove-header-stays-removed.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var http = require('http');
+const http = require('http');
-var server = http.createServer(function(request, response) {
+const server = http.createServer(function(request, response) {
// removed headers should stay removed, even if node automatically adds them
// to the output:
response.removeHeader('connection');
@@ -20,7 +20,7 @@ var server = http.createServer(function(request, response) {
this.close();
});
-var response = '';
+let response = '';
process.on('exit', function() {
assert.equal('beep boop\n', response);
diff --git a/test/parallel/test-http-request-dont-override-options.js b/test/parallel/test-http-request-dont-override-options.js
index 5570dd49a2fc1b..04235fd0e42b4e 100644
--- a/test/parallel/test-http-request-dont-override-options.js
+++ b/test/parallel/test-http-request-dont-override-options.js
@@ -4,7 +4,7 @@ const common = require('../common');
const assert = require('assert');
const http = require('http');
-var requests = 0;
+let requests = 0;
http.createServer(function(req, res) {
res.writeHead(200);
@@ -12,13 +12,13 @@ http.createServer(function(req, res) {
requests++;
}).listen(0, function() {
- var agent = new http.Agent();
+ const agent = new http.Agent();
agent.defaultPort = this.address().port;
// options marked as explicitly undefined for readability
// in this test, they should STAY undefined as options should not
// be mutable / modified
- var options = {
+ const options = {
host: undefined,
hostname: common.localhostIPv4,
port: undefined,
diff --git a/test/parallel/test-http-request-end-twice.js b/test/parallel/test-http-request-end-twice.js
index 230175be8e95c1..ab30c0a1eef8a1 100644
--- a/test/parallel/test-http-request-end-twice.js
+++ b/test/parallel/test-http-request-end-twice.js
@@ -1,14 +1,14 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var server = http.Server(function(req, res) {
+const server = http.Server(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('hello world\n');
});
server.listen(0, function() {
- var req = http.get({port: this.address().port}, function(res) {
+ const req = http.get({port: this.address().port}, function(res) {
res.on('end', function() {
assert.ok(!req.end());
server.close();
diff --git a/test/parallel/test-http-request-end.js b/test/parallel/test-http-request-end.js
index 6beedae20d9e00..dd4a8caf105329 100644
--- a/test/parallel/test-http-request-end.js
+++ b/test/parallel/test-http-request-end.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var expected = 'Post Body For Test';
+const expected = 'Post Body For Test';
-var server = http.Server(function(req, res) {
- var result = '';
+const server = http.Server(function(req, res) {
+ let result = '';
req.setEncoding('utf8');
req.on('data', function(chunk) {
diff --git a/test/parallel/test-http-request-methods.js b/test/parallel/test-http-request-methods.js
index 7f42a9c00a85f3..e4579791ef301a 100644
--- a/test/parallel/test-http-request-methods.js
+++ b/test/parallel/test-http-request-methods.js
@@ -1,13 +1,13 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var net = require('net');
-var http = require('http');
+const assert = require('assert');
+const net = require('net');
+const http = require('http');
// Test that the DELETE, PATCH and PURGE verbs get passed through correctly
['DELETE', 'PATCH', 'PURGE'].forEach(function(method, index) {
- var server = http.createServer(common.mustCall(function(req, res) {
+ const server = http.createServer(common.mustCall(function(req, res) {
assert.strictEqual(req.method, method);
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('hello ');
@@ -17,8 +17,8 @@ var http = require('http');
server.listen(0);
server.on('listening', common.mustCall(function() {
- var c = net.createConnection(this.address().port);
- var server_response = '';
+ const c = net.createConnection(this.address().port);
+ let server_response = '';
c.setEncoding('utf8');
diff --git a/test/parallel/test-http-res-write-after-end.js b/test/parallel/test-http-res-write-after-end.js
index 5a91c556340b1c..2ee0e4e29d95e4 100644
--- a/test/parallel/test-http-res-write-after-end.js
+++ b/test/parallel/test-http-res-write-after-end.js
@@ -1,9 +1,9 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var server = http.Server(common.mustCall(function(req, res) {
+const server = http.Server(common.mustCall(function(req, res) {
res.on('error', common.mustCall(function onResError(err) {
assert.strictEqual(err.message, 'write after end');
}));
@@ -11,7 +11,7 @@ var server = http.Server(common.mustCall(function(req, res) {
res.write('This should write.');
res.end();
- var r = res.write('This should raise an error.');
+ const r = res.write('This should raise an error.');
assert.equal(r, true, 'write after end should return true');
}));
diff --git a/test/parallel/test-http-res-write-end-dont-take-array.js b/test/parallel/test-http-res-write-end-dont-take-array.js
index 5c14b0678520c4..6964ec15965a96 100644
--- a/test/parallel/test-http-res-write-end-dont-take-array.js
+++ b/test/parallel/test-http-res-write-end-dont-take-array.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var test = 1;
+let test = 1;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
if (test === 1) {
// write should accept string
diff --git a/test/parallel/test-http-response-close.js b/test/parallel/test-http-response-close.js
index 54ee61efccf1ea..de179c113e1db1 100644
--- a/test/parallel/test-http-response-close.js
+++ b/test/parallel/test-http-response-close.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var http = require('http');
+const http = require('http');
-var server = http.createServer(common.mustCall(function(req, res) {
+const server = http.createServer(common.mustCall(function(req, res) {
res.writeHead(200);
res.write('a');
diff --git a/test/parallel/test-http-response-multi-content-length.js b/test/parallel/test-http-response-multi-content-length.js
index 3290f74c16e250..7cd802a74aa80c 100644
--- a/test/parallel/test-http-response-multi-content-length.js
+++ b/test/parallel/test-http-response-multi-content-length.js
@@ -24,7 +24,7 @@ const server = http.createServer((req, res) => {
res.end('ok');
});
-var count = 0;
+let count = 0;
server.listen(0, common.mustCall(() => {
for (let n = 1; n <= MAX_COUNT; n++) {
diff --git a/test/parallel/test-http-response-multiheaders.js b/test/parallel/test-http-response-multiheaders.js
index f4c1fd4116b735..8f48dc2377f3c3 100644
--- a/test/parallel/test-http-response-multiheaders.js
+++ b/test/parallel/test-http-response-multiheaders.js
@@ -29,7 +29,7 @@ const norepeat = [
];
const server = http.createServer(function(req, res) {
- var num = req.headers['x-num'];
+ const num = req.headers['x-num'];
if (num === '1') {
for (const name of norepeat) {
res.setHeader(name, ['A', 'B']);
@@ -47,7 +47,7 @@ const server = http.createServer(function(req, res) {
});
server.listen(0, common.mustCall(function() {
- var count = 0;
+ let count = 0;
for (let n = 1; n <= 2; n++) {
// this runs twice, the first time, the server will use
// setHeader, the second time it uses writeHead. The
diff --git a/test/parallel/test-http-response-no-headers.js b/test/parallel/test-http-response-no-headers.js
index 4a3460bc645140..3f44b4ef5fde0b 100644
--- a/test/parallel/test-http-response-no-headers.js
+++ b/test/parallel/test-http-response-no-headers.js
@@ -1,31 +1,31 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
-var expected = {
+const expected = {
'0.9': 'I AM THE WALRUS',
'1.0': 'I AM THE WALRUS',
'1.1': ''
};
function test(httpVersion, callback) {
- var server = net.createServer(function(conn) {
- var reply = 'HTTP/' + httpVersion + ' 200 OK\r\n\r\n' +
- expected[httpVersion];
+ const server = net.createServer(function(conn) {
+ const reply = 'HTTP/' + httpVersion + ' 200 OK\r\n\r\n' +
+ expected[httpVersion];
conn.end(reply);
});
server.listen(0, '127.0.0.1', common.mustCall(function() {
- var options = {
+ const options = {
host: '127.0.0.1',
port: this.address().port
};
- var req = http.get(options, common.mustCall(function(res) {
- var body = '';
+ const req = http.get(options, common.mustCall(function(res) {
+ let body = '';
res.on('data', function(data) {
body += data;
diff --git a/test/parallel/test-http-response-readable.js b/test/parallel/test-http-response-readable.js
index 1d561ca4704808..07c0a40e4bf1a8 100644
--- a/test/parallel/test-http-response-readable.js
+++ b/test/parallel/test-http-response-readable.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var testServer = new http.Server(function(req, res) {
+const testServer = new http.Server(function(req, res) {
res.writeHead(200);
res.end('Hello world');
});
diff --git a/test/parallel/test-http-response-splitting.js b/test/parallel/test-http-response-splitting.js
index f2c7bc5d8d1219..e6927bc1e63f77 100644
--- a/test/parallel/test-http-response-splitting.js
+++ b/test/parallel/test-http-response-splitting.js
@@ -17,7 +17,7 @@ const str = '/welcome?lang=bar%c4%8d%c4%8aContentLength:%200%c4%8d%c4%8a%c' +
const x = 'fooഊSet-Cookie: foo=barഊഊ';
const y = 'foo⠊Set-Cookie: foo=bar';
-var count = 0;
+let count = 0;
function test(res, code, header) {
assert.throws(() => {
diff --git a/test/parallel/test-http-response-status-message.js b/test/parallel/test-http-response-status-message.js
index b14c1f2faf0fce..d17dfb24c6b4c8 100644
--- a/test/parallel/test-http-response-status-message.js
+++ b/test/parallel/test-http-response-status-message.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
-var testsComplete = 0;
+let testsComplete = 0;
-var testCases = [
+const testCases = [
{ path: '/200', statusMessage: 'OK',
response: 'HTTP/1.1 200 OK\r\n\r\n' },
{ path: '/500', statusMessage: 'Internal Server Error',
@@ -19,7 +19,7 @@ var testCases = [
response: 'HTTP/1.1 200\r\n\r\n' }
];
testCases.findByPath = function(path) {
- var matching = this.filter(function(testCase) {
+ const matching = this.filter(function(testCase) {
return testCase.path === path;
});
if (matching.length === 0) {
@@ -28,18 +28,18 @@ testCases.findByPath = function(path) {
return matching[0];
};
-var server = net.createServer(function(connection) {
+const server = net.createServer(function(connection) {
connection.on('data', function(data) {
- var path = data.toString().match(/GET (.*) HTTP.1.1/)[1];
- var testCase = testCases.findByPath(path);
+ const path = data.toString().match(/GET (.*) HTTP.1.1/)[1];
+ const testCase = testCases.findByPath(path);
connection.write(testCase.response);
connection.end();
});
});
-var runTest = function(testCaseIndex) {
- var testCase = testCases[testCaseIndex];
+const runTest = function(testCaseIndex) {
+ const testCase = testCases[testCaseIndex];
http.get({
port: server.address().port,
diff --git a/test/parallel/test-http-server-client-error.js b/test/parallel/test-http-server-client-error.js
index cd20b7321a63f7..260963dc24daaa 100644
--- a/test/parallel/test-http-server-client-error.js
+++ b/test/parallel/test-http-server-client-error.js
@@ -21,7 +21,7 @@ server.listen(0, function() {
const client = net.connect(server.address().port);
client.end('Oopsie-doopsie\r\n');
- var chunks = '';
+ let chunks = '';
client.on('data', function(chunk) {
chunks += chunk;
});
diff --git a/test/parallel/test-http-server-multiheaders.js b/test/parallel/test-http-server-multiheaders.js
index 5b41ee89d87e50..189ab0657bacb0 100644
--- a/test/parallel/test-http-server-multiheaders.js
+++ b/test/parallel/test-http-server-multiheaders.js
@@ -4,10 +4,10 @@
// that support it, and dropping duplicates for other fields.
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var srv = http.createServer(function(req, res) {
+const srv = http.createServer(function(req, res) {
assert.equal(req.headers.accept, 'abc, def, ghijklmnopqrst');
assert.equal(req.headers.host, 'foo');
assert.equal(req.headers['www-authenticate'], 'foo, bar, baz');
diff --git a/test/parallel/test-http-server-multiheaders2.js b/test/parallel/test-http-server-multiheaders2.js
index 9f6d41e6a10cea..82cc9960329a11 100644
--- a/test/parallel/test-http-server-multiheaders2.js
+++ b/test/parallel/test-http-server-multiheaders2.js
@@ -4,10 +4,10 @@
// that support it, and dropping duplicates for other fields.
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var multipleAllowed = [
+const multipleAllowed = [
'Accept',
'Accept-Charset',
'Accept-Encoding',
@@ -31,7 +31,7 @@ var multipleAllowed = [
'X-Some-Random-Header',
];
-var multipleForbidden = [
+const multipleForbidden = [
'Content-Type',
'User-Agent',
'Referer',
@@ -48,7 +48,7 @@ var multipleForbidden = [
//'Content-Length',
];
-var srv = http.createServer(function(req, res) {
+const srv = http.createServer(function(req, res) {
multipleForbidden.forEach(function(header) {
assert.equal(req.headers[header.toLowerCase()],
'foo', 'header parsed incorrectly: ' + header);
@@ -70,7 +70,7 @@ function makeHeader(value) {
};
}
-var headers = []
+const headers = []
.concat(multipleAllowed.map(makeHeader('foo')))
.concat(multipleForbidden.map(makeHeader('foo')))
.concat(multipleAllowed.map(makeHeader('bar')))
diff --git a/test/parallel/test-http-server-stale-close.js b/test/parallel/test-http-server-stale-close.js
index 819f503de547e4..3728453c039447 100644
--- a/test/parallel/test-http-server-stale-close.js
+++ b/test/parallel/test-http-server-stale-close.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var http = require('http');
-var util = require('util');
-var fork = require('child_process').fork;
+const http = require('http');
+const util = require('util');
+const fork = require('child_process').fork;
if (process.env.NODE_TEST_FORK_PORT) {
- var req = http.request({
+ const req = http.request({
headers: {'Content-Length': '42'},
method: 'POST',
host: '127.0.0.1',
@@ -14,7 +14,7 @@ if (process.env.NODE_TEST_FORK_PORT) {
req.write('BAM');
req.end();
} else {
- var server = http.createServer(function(req, res) {
+ const server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Length': '42'});
req.pipe(res);
req.on('close', function() {
diff --git a/test/parallel/test-http-server-unconsume.js b/test/parallel/test-http-server-unconsume.js
index 76238380c7cfde..fca2691aacc25d 100644
--- a/test/parallel/test-http-server-unconsume.js
+++ b/test/parallel/test-http-server-unconsume.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
-var received = '';
+let received = '';
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.writeHead(200);
res.end();
@@ -16,7 +16,7 @@ var server = http.createServer(function(req, res) {
server.close();
}).listen(0, function() {
- var socket = net.connect(this.address().port, function() {
+ const socket = net.connect(this.address().port, function() {
socket.write('PUT / HTTP/1.1\r\n\r\n');
socket.once('data', function() {
diff --git a/test/parallel/test-http-server.js b/test/parallel/test-http-server.js
index 1870bcc7170726..90c2709ebdbc5c 100644
--- a/test/parallel/test-http-server.js
+++ b/test/parallel/test-http-server.js
@@ -1,17 +1,17 @@
'use strict';
require('../common');
-var assert = require('assert');
-var net = require('net');
-var http = require('http');
-var url = require('url');
-var qs = require('querystring');
-
-var request_number = 0;
-var requests_sent = 0;
-var server_response = '';
-var client_got_eof = false;
-
-var server = http.createServer(function(req, res) {
+const assert = require('assert');
+const net = require('net');
+const http = require('http');
+const url = require('url');
+const qs = require('querystring');
+
+let request_number = 0;
+let requests_sent = 0;
+let server_response = '';
+let client_got_eof = false;
+
+const server = http.createServer(function(req, res) {
res.id = request_number;
req.id = request_number++;
@@ -48,7 +48,7 @@ server.listen(0);
server.httpAllowHalfOpen = true;
server.on('listening', function() {
- var c = net.createConnection(this.address().port);
+ const c = net.createConnection(this.address().port);
c.setEncoding('utf8');
@@ -94,10 +94,10 @@ process.on('exit', function() {
assert.strictEqual(4, request_number);
assert.strictEqual(4, requests_sent);
- var hello = new RegExp('/hello');
+ const hello = new RegExp('/hello');
assert.notStrictEqual(null, hello.exec(server_response));
- var quit = new RegExp('/quit');
+ const quit = new RegExp('/quit');
assert.notStrictEqual(null, quit.exec(server_response));
assert.strictEqual(true, client_got_eof);
diff --git a/test/parallel/test-http-set-cookies.js b/test/parallel/test-http-set-cookies.js
index 1f00ebb65e34de..cb06352b3ca85d 100644
--- a/test/parallel/test-http-set-cookies.js
+++ b/test/parallel/test-http-set-cookies.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
-var nresponses = 0;
+let nresponses = 0;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
if (req.url === '/one') {
res.writeHead(200, [['set-cookie', 'A'],
['content-type', 'text/plain']]);
diff --git a/test/parallel/test-http-set-timeout-server.js b/test/parallel/test-http-set-timeout-server.js
index d530503aa1e9aa..7a2447763e4cf9 100644
--- a/test/parallel/test-http-set-timeout-server.js
+++ b/test/parallel/test-http-set-timeout-server.js
@@ -1,10 +1,10 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
-var tests = [];
+const tests = [];
function test(fn) {
if (!tests.length)
@@ -13,7 +13,7 @@ function test(fn) {
}
function run() {
- var fn = tests.shift();
+ const fn = tests.shift();
if (fn) {
console.log('# %s', fn.name);
fn(run);
@@ -23,17 +23,17 @@ function run() {
}
test(function serverTimeout(cb) {
- var caughtTimeout = false;
+ let caughtTimeout = false;
process.on('exit', function() {
assert(caughtTimeout);
});
- var server = http.createServer(function(req, res) {
+ const server = http.createServer(function(req, res) {
// just do nothing, we should get a timeout event.
});
server.listen(common.mustCall(function() {
http.get({ port: server.address().port }).on('error', function() {});
}));
- var s = server.setTimeout(50, function(socket) {
+ const s = server.setTimeout(50, function(socket) {
caughtTimeout = true;
socket.destroy();
server.close();
@@ -43,13 +43,13 @@ test(function serverTimeout(cb) {
});
test(function serverRequestTimeout(cb) {
- var caughtTimeout = false;
+ let caughtTimeout = false;
process.on('exit', function() {
assert(caughtTimeout);
});
- var server = http.createServer(function(req, res) {
+ const server = http.createServer(function(req, res) {
// just do nothing, we should get a timeout event.
- var s = req.setTimeout(50, function() {
+ const s = req.setTimeout(50, function() {
caughtTimeout = true;
req.socket.destroy();
server.close();
@@ -58,8 +58,8 @@ test(function serverRequestTimeout(cb) {
assert.ok(s instanceof http.IncomingMessage);
});
server.listen(common.mustCall(function() {
- var port = server.address().port;
- var req = http.request({ port: port, method: 'POST' });
+ const port = server.address().port;
+ const req = http.request({ port: port, method: 'POST' });
req.on('error', function() {});
req.write('Hello');
// req is in progress
@@ -67,13 +67,13 @@ test(function serverRequestTimeout(cb) {
});
test(function serverResponseTimeout(cb) {
- var caughtTimeout = false;
+ let caughtTimeout = false;
process.on('exit', function() {
assert(caughtTimeout);
});
- var server = http.createServer(function(req, res) {
+ const server = http.createServer(function(req, res) {
// just do nothing, we should get a timeout event.
- var s = res.setTimeout(50, function() {
+ const s = res.setTimeout(50, function() {
caughtTimeout = true;
res.socket.destroy();
server.close();
@@ -82,21 +82,21 @@ test(function serverResponseTimeout(cb) {
assert.ok(s instanceof http.OutgoingMessage);
});
server.listen(common.mustCall(function() {
- var port = server.address().port;
+ const port = server.address().port;
http.get({ port: port }).on('error', function() {});
}));
});
test(function serverRequestNotTimeoutAfterEnd(cb) {
- var caughtTimeoutOnRequest = false;
- var caughtTimeoutOnResponse = false;
+ let caughtTimeoutOnRequest = false;
+ let caughtTimeoutOnResponse = false;
process.on('exit', function() {
assert(!caughtTimeoutOnRequest);
assert(caughtTimeoutOnResponse);
});
- var server = http.createServer(function(req, res) {
+ const server = http.createServer(function(req, res) {
// just do nothing, we should get a timeout event.
- var s = req.setTimeout(50, function(socket) {
+ const s = req.setTimeout(50, function(socket) {
caughtTimeoutOnRequest = true;
});
assert.ok(s instanceof http.IncomingMessage);
@@ -110,18 +110,18 @@ test(function serverRequestNotTimeoutAfterEnd(cb) {
cb();
});
server.listen(common.mustCall(function() {
- var port = server.address().port;
+ const port = server.address().port;
http.get({ port: port }).on('error', function() {});
}));
});
test(function serverResponseTimeoutWithPipeline(cb) {
- var caughtTimeout = '';
+ let caughtTimeout = '';
process.on('exit', function() {
assert.equal(caughtTimeout, '/2');
});
- var server = http.createServer(function(req, res) {
- var s = res.setTimeout(50, function() {
+ const server = http.createServer(function(req, res) {
+ const s = res.setTimeout(50, function() {
caughtTimeout += req.url;
});
assert.ok(s instanceof http.OutgoingMessage);
@@ -133,8 +133,8 @@ test(function serverResponseTimeoutWithPipeline(cb) {
cb();
});
server.listen(common.mustCall(function() {
- var port = server.address().port;
- var c = net.connect({ port: port, allowHalfOpen: true }, function() {
+ const port = server.address().port;
+ const c = net.connect({ port: port, allowHalfOpen: true }, function() {
c.write('GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n');
c.write('GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n');
c.write('GET /3 HTTP/1.1\r\nHost: localhost\r\n\r\n');
@@ -143,15 +143,15 @@ test(function serverResponseTimeoutWithPipeline(cb) {
});
test(function idleTimeout(cb) {
- var caughtTimeoutOnRequest = false;
- var caughtTimeoutOnResponse = false;
- var caughtTimeoutOnServer = false;
+ let caughtTimeoutOnRequest = false;
+ let caughtTimeoutOnResponse = false;
+ let caughtTimeoutOnServer = false;
process.on('exit', function() {
assert(!caughtTimeoutOnRequest);
assert(!caughtTimeoutOnResponse);
assert(caughtTimeoutOnServer);
});
- var server = http.createServer(function(req, res) {
+ const server = http.createServer(function(req, res) {
req.on('timeout', function(socket) {
caughtTimeoutOnRequest = true;
});
@@ -160,7 +160,7 @@ test(function idleTimeout(cb) {
});
res.end();
});
- var s = server.setTimeout(50, function(socket) {
+ const s = server.setTimeout(50, function(socket) {
caughtTimeoutOnServer = true;
socket.destroy();
server.close();
@@ -168,8 +168,8 @@ test(function idleTimeout(cb) {
});
assert.ok(s instanceof http.Server);
server.listen(common.mustCall(function() {
- var port = server.address().port;
- var c = net.connect({ port: port, allowHalfOpen: true }, function() {
+ const port = server.address().port;
+ const c = net.connect({ port: port, allowHalfOpen: true }, function() {
c.write('GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n');
// Keep-Alive
});
diff --git a/test/parallel/test-http-set-timeout.js b/test/parallel/test-http-set-timeout.js
index e8df29e0ccdc67..965b3486faee95 100644
--- a/test/parallel/test-http-set-timeout.js
+++ b/test/parallel/test-http-set-timeout.js
@@ -4,9 +4,9 @@ const assert = require('assert');
const http = require('http');
const net = require('net');
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
console.log('got request. setting 500ms timeout');
- var socket = req.connection.setTimeout(500);
+ const socket = req.connection.setTimeout(500);
assert.ok(socket instanceof net.Socket);
req.connection.on('timeout', common.mustCall(function() {
req.connection.destroy();
@@ -18,7 +18,7 @@ var server = http.createServer(function(req, res) {
server.listen(0, function() {
console.log(`Server running at http://127.0.0.1:${this.address().port}/`);
- var request = http.get({port: this.address().port, path: '/'});
+ const request = http.get({port: this.address().port, path: '/'});
request.on('error', common.mustCall(function() {
console.log('HTTP REQUEST COMPLETE (this is good)');
}));
diff --git a/test/parallel/test-http-set-trailers.js b/test/parallel/test-http-set-trailers.js
index b3f331c6d8b172..7b66933ecd12cd 100644
--- a/test/parallel/test-http-set-trailers.js
+++ b/test/parallel/test-http-set-trailers.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
-var outstanding_reqs = 0;
+let outstanding_reqs = 0;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.writeHead(200, [['content-type', 'text/plain']]);
res.addTrailers({'x-foo': 'bar'});
res.end('stuff' + '\n');
@@ -16,8 +16,8 @@ server.listen(0);
// first, we test an HTTP/1.0 request.
server.on('listening', function() {
- var c = net.createConnection(this.address().port);
- var res_buffer = '';
+ const c = net.createConnection(this.address().port);
+ let res_buffer = '';
c.setEncoding('utf8');
@@ -44,9 +44,9 @@ server.on('listening', function() {
// now, we test an HTTP/1.1 request.
server.on('listening', function() {
- var c = net.createConnection(this.address().port);
- var res_buffer = '';
- var tid;
+ const c = net.createConnection(this.address().port);
+ let res_buffer = '';
+ let tid;
c.setEncoding('utf8');
diff --git a/test/parallel/test-http-should-keep-alive.js b/test/parallel/test-http-should-keep-alive.js
index 3aaa2d3d73acdc..77a3c3922a20f0 100644
--- a/test/parallel/test-http-should-keep-alive.js
+++ b/test/parallel/test-http-should-keep-alive.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
-var SERVER_RESPONSES = [
+const SERVER_RESPONSES = [
'HTTP/1.0 200 ok\r\nContent-Length: 0\r\n\r\n',
'HTTP/1.0 200 ok\r\nContent-Length: 0\r\nConnection: keep-alive\r\n\r\n',
'HTTP/1.0 200 ok\r\nContent-Length: 0\r\nConnection: close\r\n\r\n',
@@ -12,7 +12,7 @@ var SERVER_RESPONSES = [
'HTTP/1.1 200 ok\r\nContent-Length: 0\r\nConnection: keep-alive\r\n\r\n',
'HTTP/1.1 200 ok\r\nContent-Length: 0\r\nConnection: close\r\n\r\n'
];
-var SHOULD_KEEP_ALIVE = [
+const SHOULD_KEEP_ALIVE = [
false, // HTTP/1.0, default
true, // HTTP/1.0, Connection: keep-alive
false, // HTTP/1.0, Connection: close
@@ -20,16 +20,16 @@ var SHOULD_KEEP_ALIVE = [
true, // HTTP/1.1, Connection: keep-alive
false // HTTP/1.1, Connection: close
];
-var requests = 0;
-var responses = 0;
+let requests = 0;
+let responses = 0;
http.globalAgent.maxSockets = 5;
-var server = net.createServer(function(socket) {
+const server = net.createServer(function(socket) {
socket.write(SERVER_RESPONSES[requests]);
++requests;
}).listen(0, function() {
function makeRequest() {
- var req = http.get({port: server.address().port}, function(res) {
+ const req = http.get({port: server.address().port}, function(res) {
assert.equal(req.shouldKeepAlive, SHOULD_KEEP_ALIVE[responses],
SERVER_RESPONSES[responses] + ' should ' +
(SHOULD_KEEP_ALIVE[responses] ? '' : 'not ') +
diff --git a/test/parallel/test-http-status-code.js b/test/parallel/test-http-status-code.js
index c0086a3e3d672f..b5060109bf4985 100644
--- a/test/parallel/test-http-status-code.js
+++ b/test/parallel/test-http-status-code.js
@@ -1,17 +1,17 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
+const assert = require('assert');
+const http = require('http');
// Simple test of Node's HTTP ServerResponse.statusCode
// ServerResponse.prototype.statusCode
-var testsComplete = 0;
-var tests = [200, 202, 300, 404, 451, 500];
-var testIdx = 0;
+let testsComplete = 0;
+const tests = [200, 202, 300, 404, 451, 500];
+let testIdx = 0;
-var s = http.createServer(function(req, res) {
- var t = tests[testIdx];
+const s = http.createServer(function(req, res) {
+ const t = tests[testIdx];
res.writeHead(t, {'Content-Type': 'text/plain'});
console.log('--\nserver: statusCode after writeHead: ' + res.statusCode);
assert.equal(res.statusCode, t);
@@ -25,7 +25,7 @@ function nextTest() {
if (testIdx + 1 === tests.length) {
return s.close();
}
- var test = tests[testIdx];
+ const test = tests[testIdx];
http.get({ port: s.address().port }, function(response) {
console.log('client: expected status: ' + test);
diff --git a/test/parallel/test-http-status-message.js b/test/parallel/test-http-status-message.js
index 6da4b6e4281171..668b02ee0780b4 100644
--- a/test/parallel/test-http-status-message.js
+++ b/test/parallel/test-http-status-message.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
-var s = http.createServer(function(req, res) {
+const s = http.createServer(function(req, res) {
res.statusCode = 200;
res.statusMessage = 'Custom Message';
res.end('');
@@ -14,15 +14,15 @@ s.listen(0, test);
function test() {
- var bufs = [];
- var client = net.connect(this.address().port, function() {
+ const bufs = [];
+ const client = net.connect(this.address().port, function() {
client.write('GET / HTTP/1.1\r\nConnection: close\r\n\r\n');
});
client.on('data', function(chunk) {
bufs.push(chunk);
});
client.on('end', function() {
- var head = Buffer.concat(bufs).toString('latin1').split('\r\n')[0];
+ const head = Buffer.concat(bufs).toString('latin1').split('\r\n')[0];
assert.equal('HTTP/1.1 200 Custom Message', head);
console.log('ok');
s.close();
diff --git a/test/parallel/test-http-timeout-overflow.js b/test/parallel/test-http-timeout-overflow.js
index 49cf3ec0278fca..39b4550d57e529 100644
--- a/test/parallel/test-http-timeout-overflow.js
+++ b/test/parallel/test-http-timeout-overflow.js
@@ -1,13 +1,13 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var http = require('http');
+const http = require('http');
-var serverRequests = 0;
-var clientRequests = 0;
+let serverRequests = 0;
+let clientRequests = 0;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
serverRequests++;
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('OK');
@@ -16,7 +16,7 @@ var server = http.createServer(function(req, res) {
server.listen(0, function() {
function callback() {}
- var req = http.request({
+ const req = http.request({
port: this.address().port,
path: '/',
agent: false
diff --git a/test/parallel/test-http-timeout.js b/test/parallel/test-http-timeout.js
index b8a28fc2c4cf32..63f87ed63089ee 100644
--- a/test/parallel/test-http-timeout.js
+++ b/test/parallel/test-http-timeout.js
@@ -1,24 +1,24 @@
'use strict';
require('../common');
-var http = require('http');
+const http = require('http');
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('OK');
});
-var agent = new http.Agent({maxSockets: 1});
+const agent = new http.Agent({maxSockets: 1});
server.listen(0, function() {
- for (var i = 0; i < 11; ++i) {
+ for (let i = 0; i < 11; ++i) {
createRequest().end();
}
function callback() {}
- var count = 0;
+ let count = 0;
function createRequest() {
const req = http.request(
diff --git a/test/parallel/test-http-unix-socket.js b/test/parallel/test-http-unix-socket.js
index d2b99bde95a234..f9308d86325cd1 100644
--- a/test/parallel/test-http-unix-socket.js
+++ b/test/parallel/test-http-unix-socket.js
@@ -17,12 +17,12 @@ common.refreshTmpDir();
server.listen(common.PIPE, common.mustCall(function() {
- var options = {
+ const options = {
socketPath: common.PIPE,
path: '/'
};
- var req = http.get(options, common.mustCall(function(res) {
+ const req = http.get(options, common.mustCall(function(res) {
assert.strictEqual(res.statusCode, 200);
assert.strictEqual(res.headers['content-type'], 'text/plain');
diff --git a/test/parallel/test-http-upgrade-agent.js b/test/parallel/test-http-upgrade-agent.js
index 48eaa16f898021..a196ba904905a3 100644
--- a/test/parallel/test-http-upgrade-agent.js
+++ b/test/parallel/test-http-upgrade-agent.js
@@ -3,14 +3,14 @@
// the HTTP client. This test uses a raw TCP server to better control server
// behavior.
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var http = require('http');
-var net = require('net');
+const http = require('http');
+const net = require('net');
// Create a TCP server
-var srv = net.createServer(function(c) {
+const srv = net.createServer(function(c) {
c.on('data', function(d) {
c.write('HTTP/1.1 101\r\n');
c.write('hello: world\r\n');
@@ -27,7 +27,7 @@ var srv = net.createServer(function(c) {
srv.listen(0, '127.0.0.1', common.mustCall(function() {
- var options = {
+ const options = {
port: this.address().port,
host: '127.0.0.1',
headers: {
@@ -35,13 +35,13 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() {
'upgrade': 'websocket'
}
};
- var name = options.host + ':' + options.port;
+ const name = options.host + ':' + options.port;
- var req = http.request(options);
+ const req = http.request(options);
req.end();
req.on('upgrade', common.mustCall(function(res, socket, upgradeHead) {
- var recvData = upgradeHead;
+ let recvData = upgradeHead;
socket.on('data', function(d) {
recvData += d;
});
@@ -51,9 +51,9 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() {
}));
console.log(res.headers);
- var expectedHeaders = { 'hello': 'world',
- 'connection': 'upgrade',
- 'upgrade': 'websocket' };
+ const expectedHeaders = { 'hello': 'world',
+ 'connection': 'upgrade',
+ 'upgrade': 'websocket' };
assert.deepStrictEqual(expectedHeaders, res.headers);
// Make sure this request got removed from the pool.
diff --git a/test/parallel/test-http-upgrade-client.js b/test/parallel/test-http-upgrade-client.js
index 51c70122b99d87..34e3e8f24158e7 100644
--- a/test/parallel/test-http-upgrade-client.js
+++ b/test/parallel/test-http-upgrade-client.js
@@ -3,14 +3,14 @@
// the HTTP client. This test uses a raw TCP server to better control server
// behavior.
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var http = require('http');
-var net = require('net');
+const http = require('http');
+const net = require('net');
// Create a TCP server
-var srv = net.createServer(function(c) {
+const srv = net.createServer(function(c) {
c.on('data', function(d) {
c.write('HTTP/1.1 101\r\n');
c.write('hello: world\r\n');
@@ -39,16 +39,16 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() {
['Origin', 'http://www.websocket.org']
]
];
- var left = headers.length;
+ let left = headers.length;
headers.forEach(function(h) {
- var req = http.get({
+ const req = http.get({
port: port,
headers: h
});
- var sawUpgrade = false;
+ let sawUpgrade = false;
req.on('upgrade', common.mustCall(function(res, socket, upgradeHead) {
sawUpgrade = true;
- var recvData = upgradeHead;
+ let recvData = upgradeHead;
socket.on('data', function(d) {
recvData += d;
});
diff --git a/test/parallel/test-http-upgrade-client2.js b/test/parallel/test-http-upgrade-client2.js
index 0c229a354add48..fa14f8ca51f030 100644
--- a/test/parallel/test-http-upgrade-client2.js
+++ b/test/parallel/test-http-upgrade-client2.js
@@ -1,10 +1,10 @@
'use strict';
const common = require('../common');
-var http = require('http');
+const http = require('http');
-var CRLF = '\r\n';
+const CRLF = '\r\n';
-var server = http.createServer();
+const server = http.createServer();
server.on('upgrade', function(req, socket, head) {
socket.write('HTTP/1.1 101 Ok' + CRLF +
'Connection: Upgrade' + CRLF +
@@ -18,12 +18,12 @@ server.listen(0, common.mustCall(function() {
function upgradeRequest(fn) {
console.log('req');
- var header = { 'Connection': 'Upgrade', 'Upgrade': 'Test' };
- var request = http.request({
+ const header = { 'Connection': 'Upgrade', 'Upgrade': 'Test' };
+ const request = http.request({
port: server.address().port,
headers: header
});
- var wasUpgrade = false;
+ let wasUpgrade = false;
function onUpgrade(res, socket, head) {
console.log('client upgraded');
diff --git a/test/parallel/test-http-upgrade-server.js b/test/parallel/test-http-upgrade-server.js
index 8570dec899b672..6c5a62c2ffcc33 100644
--- a/test/parallel/test-http-upgrade-server.js
+++ b/test/parallel/test-http-upgrade-server.js
@@ -1,15 +1,15 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var util = require('util');
-var net = require('net');
-var http = require('http');
+const util = require('util');
+const net = require('net');
+const http = require('http');
-var requests_recv = 0;
-var requests_sent = 0;
-var request_upgradeHead = null;
+let requests_recv = 0;
+let requests_sent = 0;
+let request_upgradeHead = null;
function createTestServer() {
return new testServer();
@@ -37,7 +37,7 @@ function testServer() {
request_upgradeHead = upgradeHead;
socket.on('data', function(d) {
- var data = d.toString('utf8');
+ const data = d.toString('utf8');
if (data === 'kill') {
socket.end();
} else {
@@ -60,9 +60,9 @@ function writeReq(socket, data, encoding) {
connection: Upgrade with listener
-----------------------------------------------*/
function test_upgrade_with_listener() {
- var conn = net.createConnection(server.address().port);
+ const conn = net.createConnection(server.address().port);
conn.setEncoding('utf8');
- var state = 0;
+ let state = 0;
conn.on('connect', function() {
writeReq(conn,
@@ -99,10 +99,10 @@ function test_upgrade_with_listener() {
/*-----------------------------------------------
connection: Upgrade, no listener
-----------------------------------------------*/
-var test_upgrade_no_listener_ended = false;
+let test_upgrade_no_listener_ended = false;
function test_upgrade_no_listener() {
- var conn = net.createConnection(server.address().port);
+ const conn = net.createConnection(server.address().port);
conn.setEncoding('utf8');
conn.on('connect', function() {
@@ -127,7 +127,7 @@ function test_upgrade_no_listener() {
connection: normal
-----------------------------------------------*/
function test_standard_http() {
- var conn = net.createConnection(server.address().port);
+ const conn = net.createConnection(server.address().port);
conn.setEncoding('utf8');
conn.on('connect', function() {
@@ -146,7 +146,7 @@ function test_standard_http() {
}
-var server = createTestServer();
+let server = createTestServer();
server.listen(0, function() {
// All tests get chained after this:
diff --git a/test/parallel/test-http-upgrade-server2.js b/test/parallel/test-http-upgrade-server2.js
index 1644f54977af85..c64b2e843637af 100644
--- a/test/parallel/test-http-upgrade-server2.js
+++ b/test/parallel/test-http-upgrade-server2.js
@@ -1,10 +1,10 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
throw new Error('This shouldn\'t happen.');
});
@@ -21,7 +21,7 @@ process.on('uncaughtException', common.mustCall(function(e) {
server.listen(0, function() {
- var c = net.createConnection(this.address().port);
+ const c = net.createConnection(this.address().port);
c.on('connect', function() {
c.write('GET /blah HTTP/1.1\r\n' +
diff --git a/test/parallel/test-http-url.parse-auth-with-header-in-request.js b/test/parallel/test-http-url.parse-auth-with-header-in-request.js
index fa930bd5ec2e34..cdf3f7a5aea8af 100644
--- a/test/parallel/test-http-url.parse-auth-with-header-in-request.js
+++ b/test/parallel/test-http-url.parse-auth-with-header-in-request.js
@@ -1,15 +1,15 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var url = require('url');
+const assert = require('assert');
+const http = require('http');
+const url = require('url');
function check(request) {
// the correct authorization header is be passed
assert.strictEqual(request.headers.authorization, 'NoAuthForYOU');
}
-var server = http.createServer(function(request, response) {
+const server = http.createServer(function(request, response) {
// run the check function
check.call(this, request, response);
response.writeHead(200, {});
@@ -18,7 +18,8 @@ var server = http.createServer(function(request, response) {
});
server.listen(0, function() {
- var testURL = url.parse(`http://asdf:qwer@localhost:${this.address().port}`);
+ const testURL =
+ url.parse(`http://asdf:qwer@localhost:${this.address().port}`);
// the test here is if you set a specific authorization header in the
// request we should not override that with basic auth
testURL.headers = {
diff --git a/test/parallel/test-http-url.parse-auth.js b/test/parallel/test-http-url.parse-auth.js
index 0e901ebb599b00..25913f4e49a12a 100644
--- a/test/parallel/test-http-url.parse-auth.js
+++ b/test/parallel/test-http-url.parse-auth.js
@@ -1,15 +1,15 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var url = require('url');
+const assert = require('assert');
+const http = require('http');
+const url = require('url');
function check(request) {
// the correct authorization header is be passed
assert.strictEqual(request.headers.authorization, 'Basic dXNlcjpwYXNzOg==');
}
-var server = http.createServer(function(request, response) {
+const server = http.createServer(function(request, response) {
// run the check function
check.call(this, request, response);
response.writeHead(200, {});
@@ -20,7 +20,7 @@ var server = http.createServer(function(request, response) {
server.listen(0, function() {
const port = this.address().port;
// username = "user", password = "pass:"
- var testURL = url.parse(`http://user:pass%3A@localhost:${port}`);
+ const testURL = url.parse(`http://user:pass%3A@localhost:${port}`);
// make the request
http.request(testURL).end();
diff --git a/test/parallel/test-http-url.parse-basic.js b/test/parallel/test-http-url.parse-basic.js
index b0d1274b594d7e..ac22b6e38d80e1 100644
--- a/test/parallel/test-http-url.parse-basic.js
+++ b/test/parallel/test-http-url.parse-basic.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var url = require('url');
+const assert = require('assert');
+const http = require('http');
+const url = require('url');
-var testURL;
+let testURL;
// make sure the basics work
function check(request) {
@@ -17,7 +17,7 @@ function check(request) {
testURL.hostname + ':' + testURL.port);
}
-var server = http.createServer(function(request, response) {
+const server = http.createServer(function(request, response) {
// run the check function
check.call(this, request, response);
response.writeHead(200, {});
@@ -29,7 +29,7 @@ server.listen(0, function() {
testURL = url.parse(`http://localhost:${this.address().port}`);
// make the request
- var clientRequest = http.request(testURL);
+ const clientRequest = http.request(testURL);
// since there is a little magic with the agent
// make sure that an http request uses the http.Agent
assert.ok(clientRequest.agent instanceof http.Agent);
diff --git a/test/parallel/test-http-url.parse-https.request.js b/test/parallel/test-http-url.parse-https.request.js
index edd83a2d1306f5..ad40e76debee90 100644
--- a/test/parallel/test-http-url.parse-https.request.js
+++ b/test/parallel/test-http-url.parse-https.request.js
@@ -1,18 +1,18 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var url = require('url');
-var fs = require('fs');
+const url = require('url');
+const fs = require('fs');
// https options
-var httpsOptions = {
+const httpsOptions = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
@@ -22,7 +22,7 @@ function check(request) {
assert.ok(request.socket._secureEstablished);
}
-var server = https.createServer(httpsOptions, function(request, response) {
+const server = https.createServer(httpsOptions, function(request, response) {
// run the check function
check.call(this, request, response);
response.writeHead(200, {});
@@ -31,11 +31,11 @@ var server = https.createServer(httpsOptions, function(request, response) {
});
server.listen(0, function() {
- var testURL = url.parse(`https://localhost:${this.address().port}`);
+ const testURL = url.parse(`https://localhost:${this.address().port}`);
testURL.rejectUnauthorized = false;
// make the request
- var clientRequest = https.request(testURL);
+ const clientRequest = https.request(testURL);
// since there is a little magic with the agent
// make sure that the request uses the https.Agent
assert.ok(clientRequest.agent instanceof https.Agent);
diff --git a/test/parallel/test-http-url.parse-only-support-http-https-protocol.js b/test/parallel/test-http-url.parse-only-support-http-https-protocol.js
index e7ed82817146ea..b3d7795e72cefa 100644
--- a/test/parallel/test-http-url.parse-only-support-http-https-protocol.js
+++ b/test/parallel/test-http-url.parse-only-support-http-https-protocol.js
@@ -1,8 +1,8 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var url = require('url');
+const assert = require('assert');
+const http = require('http');
+const url = require('url');
assert.throws(function() {
diff --git a/test/parallel/test-http-url.parse-path.js b/test/parallel/test-http-url.parse-path.js
index 73de297d45fca5..6fab8bb0eb3b6b 100644
--- a/test/parallel/test-http-url.parse-path.js
+++ b/test/parallel/test-http-url.parse-path.js
@@ -1,15 +1,15 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var url = require('url');
+const assert = require('assert');
+const http = require('http');
+const url = require('url');
function check(request) {
// a path should come over
assert.strictEqual(request.url, '/asdf');
}
-var server = http.createServer(function(request, response) {
+const server = http.createServer(function(request, response) {
// run the check function
check.call(this, request, response);
response.writeHead(200, {});
@@ -18,7 +18,7 @@ var server = http.createServer(function(request, response) {
});
server.listen(0, function() {
- var testURL = url.parse(`http://localhost:${this.address().port}/asdf`);
+ const testURL = url.parse(`http://localhost:${this.address().port}/asdf`);
// make the request
http.request(testURL).end();
diff --git a/test/parallel/test-http-url.parse-post.js b/test/parallel/test-http-url.parse-post.js
index 0af482c94a875d..d63f404c5403dd 100644
--- a/test/parallel/test-http-url.parse-post.js
+++ b/test/parallel/test-http-url.parse-post.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var url = require('url');
+const assert = require('assert');
+const http = require('http');
+const url = require('url');
-var testURL;
+let testURL;
function check(request) {
//url.parse should not mess with the method
@@ -16,7 +16,7 @@ function check(request) {
testURL.hostname + ':' + testURL.port);
}
-var server = http.createServer(function(request, response) {
+const server = http.createServer(function(request, response) {
// run the check function
check.call(this, request, response);
response.writeHead(200, {});
diff --git a/test/parallel/test-http-url.parse-search.js b/test/parallel/test-http-url.parse-search.js
index 9a1e7565572fcc..f2a5d1806d89a2 100644
--- a/test/parallel/test-http-url.parse-search.js
+++ b/test/parallel/test-http-url.parse-search.js
@@ -1,15 +1,15 @@
'use strict';
require('../common');
-var assert = require('assert');
-var http = require('http');
-var url = require('url');
+const assert = require('assert');
+const http = require('http');
+const url = require('url');
function check(request) {
// a path should come over with params
assert.strictEqual(request.url, '/asdf?qwer=zxcv');
}
-var server = http.createServer(function(request, response) {
+const server = http.createServer(function(request, response) {
// run the check function
check.call(this, request, response);
response.writeHead(200, {});
@@ -19,7 +19,7 @@ var server = http.createServer(function(request, response) {
server.listen(0, function() {
const port = this.address().port;
- var testURL = url.parse(`http://localhost:${port}/asdf?qwer=zxcv`);
+ const testURL = url.parse(`http://localhost:${port}/asdf?qwer=zxcv`);
// make the request
http.request(testURL).end();
diff --git a/test/parallel/test-http-wget.js b/test/parallel/test-http-wget.js
index f7fb1a3656c623..a633873c8bb16f 100644
--- a/test/parallel/test-http-wget.js
+++ b/test/parallel/test-http-wget.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var net = require('net');
-var http = require('http');
+const assert = require('assert');
+const net = require('net');
+const http = require('http');
// wget sends an HTTP/1.0 request with Connection: Keep-Alive
//
@@ -19,7 +19,7 @@ var http = require('http');
// content-length is not provided, that the connection is in fact
// closed.
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('hello ');
res.write('world\n');
@@ -28,8 +28,8 @@ var server = http.createServer(function(req, res) {
server.listen(0);
server.on('listening', common.mustCall(function() {
- var c = net.createConnection(this.address().port);
- var server_response = '';
+ const c = net.createConnection(this.address().port);
+ let server_response = '';
c.setEncoding('utf8');
diff --git a/test/parallel/test-http-write-callbacks.js b/test/parallel/test-http-write-callbacks.js
index b89cdf89af7b90..3783dc305e39a7 100644
--- a/test/parallel/test-http-write-callbacks.js
+++ b/test/parallel/test-http-write-callbacks.js
@@ -1,16 +1,16 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var http = require('http');
+const http = require('http');
-var serverEndCb = false;
-var serverIncoming = '';
-var serverIncomingExpect = 'bazquuxblerg';
+let serverEndCb = false;
+let serverIncoming = '';
+const serverIncomingExpect = 'bazquuxblerg';
-var clientEndCb = false;
-var clientIncoming = '';
-var clientIncomingExpect = 'asdffoobar';
+let clientEndCb = false;
+let clientIncoming = '';
+const clientIncomingExpect = 'asdffoobar';
process.on('exit', function() {
assert(serverEndCb);
@@ -21,7 +21,7 @@ process.on('exit', function() {
});
// Verify that we get a callback when we do res.write(..., cb)
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.statusCode = 400;
res.end('Bad Request.\nMust send Expect:100-continue\n');
});
@@ -51,7 +51,7 @@ server.on('checkContinue', function(req, res) {
});
server.listen(0, function() {
- var req = http.request({
+ const req = http.request({
port: this.address().port,
method: 'PUT',
headers: { 'expect': '100-continue' }
diff --git a/test/parallel/test-http-write-empty-string.js b/test/parallel/test-http-write-empty-string.js
index 534a55823accee..69463fb3a50852 100644
--- a/test/parallel/test-http-write-empty-string.js
+++ b/test/parallel/test-http-write-empty-string.js
@@ -1,10 +1,10 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var http = require('http');
+const http = require('http');
-var server = http.createServer(function(request, response) {
+const server = http.createServer(function(request, response) {
console.log('responding to ' + request.url);
response.writeHead(200, {'Content-Type': 'text/plain'});
@@ -19,7 +19,7 @@ var server = http.createServer(function(request, response) {
server.listen(0, common.mustCall(function() {
http.get({ port: this.address().port }, common.mustCall(function(res) {
- var response = '';
+ let response = '';
assert.equal(200, res.statusCode);
res.setEncoding('ascii');
diff --git a/test/parallel/test-http-write-head.js b/test/parallel/test-http-write-head.js
index bdb5d906a0096f..8ebc2695c82178 100644
--- a/test/parallel/test-http-write-head.js
+++ b/test/parallel/test-http-write-head.js
@@ -10,7 +10,7 @@ const s = http.createServer(common.mustCall((req, res) => {
res.setHeader('test', '1');
// toLowerCase() is used on the name argument, so it must be a string.
- var threw = false;
+ let threw = false;
try {
res.setHeader(0xf00, 'bar');
} catch (e) {
diff --git a/test/parallel/test-http-zero-length-write.js b/test/parallel/test-http-zero-length-write.js
index b928aaeb341a88..63446e460471e4 100644
--- a/test/parallel/test-http-zero-length-write.js
+++ b/test/parallel/test-http-zero-length-write.js
@@ -1,18 +1,18 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var http = require('http');
+const http = require('http');
-var Stream = require('stream');
+const Stream = require('stream');
function getSrc() {
// An old-style readable stream.
// The Readable class prevents this behavior.
- var src = new Stream();
+ const src = new Stream();
// start out paused, just so we don't miss anything yet.
- var paused = false;
+ let paused = false;
src.pause = function() {
paused = true;
};
@@ -20,12 +20,12 @@ function getSrc() {
paused = false;
};
- var chunks = [ '', 'asdf', '', 'foo', '', 'bar', '' ];
- var interval = setInterval(function() {
+ const chunks = [ '', 'asdf', '', 'foo', '', 'bar', '' ];
+ const interval = setInterval(function() {
if (paused)
return;
- var chunk = chunks.shift();
+ const chunk = chunks.shift();
if (chunk !== undefined) {
src.emit('data', chunk);
} else {
@@ -38,10 +38,10 @@ function getSrc() {
}
-var expect = 'asdffoobar';
+const expect = 'asdffoobar';
-var server = http.createServer(function(req, res) {
- var actual = '';
+const server = http.createServer(function(req, res) {
+ let actual = '';
req.setEncoding('utf8');
req.on('data', function(c) {
actual += c;
@@ -54,8 +54,8 @@ var server = http.createServer(function(req, res) {
});
server.listen(0, function() {
- var req = http.request({ port: this.address().port, method: 'POST' });
- var actual = '';
+ const req = http.request({ port: this.address().port, method: 'POST' });
+ let actual = '';
req.on('response', function(res) {
res.setEncoding('utf8');
res.on('data', function(c) {
diff --git a/test/parallel/test-http.js b/test/parallel/test-http.js
index f755bca8bc74ec..a80a2b8856558b 100644
--- a/test/parallel/test-http.js
+++ b/test/parallel/test-http.js
@@ -4,10 +4,10 @@ const assert = require('assert');
const http = require('http');
const url = require('url');
-var responses_sent = 0;
-var responses_recvd = 0;
-var body0 = '';
-var body1 = '';
+let responses_sent = 0;
+let responses_recvd = 0;
+let body0 = '';
+let body1 = '';
const server = http.Server(function(req, res) {
if (responses_sent === 0) {
diff --git a/test/parallel/test-https-agent-disable-session-reuse.js b/test/parallel/test-https-agent-disable-session-reuse.js
index dc9878d4a1c1ed..72f6d068822338 100644
--- a/test/parallel/test-https-agent-disable-session-reuse.js
+++ b/test/parallel/test-https-agent-disable-session-reuse.js
@@ -19,7 +19,7 @@ const options = {
};
const clientSessions = [];
-var serverRequests = 0;
+let serverRequests = 0;
const agent = new https.Agent({
maxCachedSessions: 0
@@ -29,7 +29,7 @@ const server = https.createServer(options, function(req, res) {
serverRequests++;
res.end('ok');
}).listen(0, function() {
- var waiting = TOTAL_REQS;
+ let waiting = TOTAL_REQS;
function request() {
const options = {
agent: agent,
diff --git a/test/parallel/test-https-agent-servername.js b/test/parallel/test-https-agent-servername.js
index 348cf499b65f56..a321f7140396a3 100644
--- a/test/parallel/test-https-agent-servername.js
+++ b/test/parallel/test-https-agent-servername.js
@@ -1,22 +1,22 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
-var fs = require('fs');
+const https = require('https');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'),
ca: fs.readFileSync(common.fixturesDir + '/keys/ca1-cert.pem')
};
-var server = https.Server(options, function(req, res) {
+const server = https.Server(options, function(req, res) {
res.writeHead(200);
res.end('hello world\n');
});
diff --git a/test/parallel/test-https-agent-sni.js b/test/parallel/test-https-agent-sni.js
index 4174fd0b9c1fed..ca15dc3db3a88d 100644
--- a/test/parallel/test-https-agent-sni.js
+++ b/test/parallel/test-https-agent-sni.js
@@ -16,7 +16,7 @@ const options = {
};
const TOTAL = 4;
-var waiting = TOTAL;
+let waiting = TOTAL;
const server = https.Server(options, function(req, res) {
if (--waiting === 0) server.close();
@@ -35,10 +35,10 @@ server.listen(0, function() {
});
}
- var agent = new https.Agent({
+ const agent = new https.Agent({
maxSockets: 1
});
- for (var j = 0; j < TOTAL; j++) {
+ for (let j = 0; j < TOTAL; j++) {
https.get({
agent: agent,
diff --git a/test/parallel/test-https-agent.js b/test/parallel/test-https-agent.js
index 221ed2bbd2fe49..392bdcbf033000 100644
--- a/test/parallel/test-https-agent.js
+++ b/test/parallel/test-https-agent.js
@@ -22,15 +22,15 @@ const server = https.Server(options, function(req, res) {
});
-var responses = 0;
+let responses = 0;
const N = 4;
const M = 4;
server.listen(0, function() {
- for (var i = 0; i < N; i++) {
+ for (let i = 0; i < N; i++) {
setTimeout(function() {
- for (var j = 0; j < M; j++) {
+ for (let j = 0; j < M; j++) {
https.get({
path: '/',
port: server.address().port,
diff --git a/test/parallel/test-https-byteswritten.js b/test/parallel/test-https-byteswritten.js
index 58dfb12dbe2eda..cdea4d1ee930f3 100644
--- a/test/parallel/test-https-byteswritten.js
+++ b/test/parallel/test-https-byteswritten.js
@@ -1,22 +1,22 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var body = 'hello world\n';
+const body = 'hello world\n';
-var httpsServer = https.createServer(options, function(req, res) {
+const httpsServer = https.createServer(options, function(req, res) {
res.on('finish', function() {
assert.strictEqual(typeof req.connection.bytesWritten, 'number');
assert(req.connection.bytesWritten > 0);
diff --git a/test/parallel/test-https-client-checkServerIdentity.js b/test/parallel/test-https-client-checkServerIdentity.js
index 053a5630050748..688c7e22706e0e 100644
--- a/test/parallel/test-https-client-checkServerIdentity.js
+++ b/test/parallel/test-https-client-checkServerIdentity.js
@@ -1,22 +1,22 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var fs = require('fs');
-var path = require('path');
+const fs = require('fs');
+const path = require('path');
-var options = {
+const options = {
key: fs.readFileSync(path.join(common.fixturesDir, 'keys/agent3-key.pem')),
cert: fs.readFileSync(path.join(common.fixturesDir, 'keys/agent3-cert.pem'))
};
-var server = https.createServer(options, common.mustCall(function(req, res) {
+const server = https.createServer(options, common.mustCall(function(req, res) {
res.writeHead(200);
res.end();
req.resume();
@@ -25,7 +25,7 @@ var server = https.createServer(options, common.mustCall(function(req, res) {
});
function authorized() {
- var req = https.request({
+ const req = https.request({
port: server.address().port,
rejectUnauthorized: true,
ca: [fs.readFileSync(path.join(common.fixturesDir, 'keys/ca2-cert.pem'))]
@@ -37,7 +37,7 @@ function authorized() {
}
function override() {
- var options = {
+ const options = {
port: server.address().port,
rejectUnauthorized: true,
ca: [fs.readFileSync(path.join(common.fixturesDir, 'keys/ca2-cert.pem'))],
@@ -46,7 +46,7 @@ function override() {
}
};
options.agent = new https.Agent(options);
- var req = https.request(options, function(res) {
+ const req = https.request(options, function(res) {
assert(req.socket.authorized);
server.close();
});
diff --git a/test/parallel/test-https-client-get-url.js b/test/parallel/test-https-client-get-url.js
index 1a9fdf5f3f808e..e098f32d7c9794 100644
--- a/test/parallel/test-https-client-get-url.js
+++ b/test/parallel/test-https-client-get-url.js
@@ -3,22 +3,22 @@ const common = require('../common');
// disable strict server certificate validation by the client
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
-var assert = require('assert');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var fs = require('fs');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var server = https.createServer(options, common.mustCall(function(req, res) {
+const server = https.createServer(options, common.mustCall(function(req, res) {
assert.equal('GET', req.method);
assert.equal('/foo?bar', req.url);
res.writeHead(200, {'Content-Type': 'text/plain'});
diff --git a/test/parallel/test-https-client-reject.js b/test/parallel/test-https-client-reject.js
index b1708f24b10b83..92bbabe8b3be90 100644
--- a/test/parallel/test-https-client-reject.js
+++ b/test/parallel/test-https-client-reject.js
@@ -1,22 +1,22 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var fs = require('fs');
-var path = require('path');
+const fs = require('fs');
+const path = require('path');
-var options = {
+const options = {
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
};
-var server = https.createServer(options, common.mustCall(function(req, res) {
+const server = https.createServer(options, common.mustCall(function(req, res) {
res.writeHead(200);
res.end();
req.resume();
@@ -25,7 +25,7 @@ var server = https.createServer(options, common.mustCall(function(req, res) {
});
function unauthorized() {
- var req = https.request({
+ const req = https.request({
port: server.address().port,
rejectUnauthorized: false
}, function(res) {
@@ -40,11 +40,11 @@ function unauthorized() {
}
function rejectUnauthorized() {
- var options = {
+ const options = {
port: server.address().port
};
options.agent = new https.Agent(options);
- var req = https.request(options, common.fail);
+ const req = https.request(options, common.fail);
req.on('error', function(err) {
authorized();
});
@@ -52,12 +52,12 @@ function rejectUnauthorized() {
}
function authorized() {
- var options = {
+ const options = {
port: server.address().port,
ca: [fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))]
};
options.agent = new https.Agent(options);
- var req = https.request(options, function(res) {
+ const req = https.request(options, function(res) {
res.resume();
assert(req.socket.authorized);
server.close();
diff --git a/test/parallel/test-https-client-resume.js b/test/parallel/test-https-client-resume.js
index 734e8069021f78..79e1a716bd77cf 100644
--- a/test/parallel/test-https-client-resume.js
+++ b/test/parallel/test-https-client-resume.js
@@ -2,33 +2,33 @@
// Create an ssl server. First connection, validate that not resume.
// Cache session and close connection. Use session on second connection.
// ASSERT resumption.
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var tls = require('tls');
-var fs = require('fs');
+const tls = require('tls');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem')
};
// create server
-var server = https.createServer(options, common.mustCall(function(req, res) {
+const server = https.createServer(options, common.mustCall(function(req, res) {
res.end('Goodbye');
}, 2));
// start listening
server.listen(0, function() {
- var session1 = null;
- var client1 = tls.connect({
+ let session1 = null;
+ const client1 = tls.connect({
port: this.address().port,
rejectUnauthorized: false
}, function() {
@@ -43,13 +43,13 @@ server.listen(0, function() {
client1.on('close', function() {
console.log('close1');
- var opts = {
+ const opts = {
port: server.address().port,
rejectUnauthorized: false,
session: session1
};
- var client2 = tls.connect(opts, function() {
+ const client2 = tls.connect(opts, function() {
console.log('connect2');
assert.ok(client2.isSessionReused(), 'Session *should* be reused.');
client2.write('GET / HTTP/1.0\r\n' +
diff --git a/test/parallel/test-https-close.js b/test/parallel/test-https-close.js
index f77726ceb68bf9..cf950f29d6f8ad 100644
--- a/test/parallel/test-https-close.js
+++ b/test/parallel/test-https-close.js
@@ -13,17 +13,17 @@ const options = {
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var connections = {};
+const connections = {};
-var server = https.createServer(options, function(req, res) {
- var interval = setInterval(function() {
+const server = https.createServer(options, function(req, res) {
+ const interval = setInterval(function() {
res.write('data');
}, 1000);
interval.unref();
});
server.on('connection', function(connection) {
- var key = connection.remoteAddress + ':' + connection.remotePort;
+ const key = connection.remoteAddress + ':' + connection.remotePort;
connection.on('close', function() {
delete connections[key];
});
@@ -33,14 +33,14 @@ server.on('connection', function(connection) {
function shutdown() {
server.close(common.mustCall(function() {}));
- for (var key in connections) {
+ for (const key in connections) {
connections[key].destroy();
delete connections[key];
}
}
server.listen(0, function() {
- var requestOptions = {
+ const requestOptions = {
hostname: '127.0.0.1',
port: this.address().port,
path: '/',
@@ -48,7 +48,7 @@ server.listen(0, function() {
rejectUnauthorized: false
};
- var req = https.request(requestOptions, function(res) {
+ const req = https.request(requestOptions, function(res) {
res.on('data', function(d) {});
setImmediate(shutdown);
});
diff --git a/test/parallel/test-https-connecting-to-http.js b/test/parallel/test-https-connecting-to-http.js
index 53158595054714..ae8507f99cbc00 100644
--- a/test/parallel/test-https-connecting-to-http.js
+++ b/test/parallel/test-https-connecting-to-http.js
@@ -1,19 +1,19 @@
'use strict';
// This tests the situation where you try to connect a https client
// to an http server. You should get an error and exit.
-var common = require('../common');
-var http = require('http');
+const common = require('../common');
+const http = require('http');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var server = http.createServer(common.fail);
+const server = http.createServer(common.fail);
server.listen(0, common.mustCall(function() {
- var req = https.get({ port: this.address().port }, common.fail);
+ const req = https.get({ port: this.address().port }, common.fail);
req.on('error', common.mustCall(function(e) {
console.log('Got expected error: ', e.message);
diff --git a/test/parallel/test-https-drain.js b/test/parallel/test-https-drain.js
index 7648469b0f54a7..0b18795078fd1f 100644
--- a/test/parallel/test-https-drain.js
+++ b/test/parallel/test-https-drain.js
@@ -1,38 +1,38 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var fs = require('fs');
-var path = require('path');
+const fs = require('fs');
+const path = require('path');
-var options = {
+const options = {
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
};
-var bufSize = 1024 * 1024;
-var sent = 0;
-var received = 0;
+const bufSize = 1024 * 1024;
+let sent = 0;
+let received = 0;
-var server = https.createServer(options, function(req, res) {
+const server = https.createServer(options, function(req, res) {
res.writeHead(200);
req.pipe(res);
});
server.listen(0, function() {
- var resumed = false;
- var req = https.request({
+ let resumed = false;
+ const req = https.request({
method: 'POST',
port: this.address().port,
rejectUnauthorized: false
}, function(res) {
- var timer;
+ let timer;
res.pause();
console.error('paused');
send();
diff --git a/test/parallel/test-https-eof-for-eom.js b/test/parallel/test-https-eof-for-eom.js
index 1c814714bfef96..d5e896c7695cfd 100644
--- a/test/parallel/test-https-eof-for-eom.js
+++ b/test/parallel/test-https-eof-for-eom.js
@@ -7,25 +7,25 @@
// This test is to be sure that the https client is handling this case
// correctly.
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
-var tls = require('tls');
+const https = require('https');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var server = tls.Server(options, function(socket) {
+const server = tls.Server(options, function(socket) {
console.log('2) Server got request');
socket.write('HTTP/1.1 200 OK\r\n' +
'Date: Tue, 15 Feb 2011 22:14:54 GMT\r\n' +
@@ -52,7 +52,7 @@ server.listen(0, common.mustCall(function() {
port: this.address().port,
rejectUnauthorized: false
}, common.mustCall(function(res) {
- var bodyBuffer = '';
+ let bodyBuffer = '';
server.close();
console.log('3) Client got response headers.');
diff --git a/test/parallel/test-https-foafssl.js b/test/parallel/test-https-foafssl.js
index 5c9fb613e6fa95..f1b8d442e27893 100644
--- a/test/parallel/test-https-foafssl.js
+++ b/test/parallel/test-https-foafssl.js
@@ -1,24 +1,24 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.opensslCli) {
common.skip('node compiled without OpenSSL CLI.');
return;
}
-var assert = require('assert');
-var join = require('path').join;
+const assert = require('assert');
+const join = require('path').join;
-var fs = require('fs');
-var spawn = require('child_process').spawn;
+const fs = require('fs');
+const spawn = require('child_process').spawn;
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/agent.key'),
cert: fs.readFileSync(common.fixturesDir + '/agent.crt'),
requestCert: true
@@ -34,11 +34,11 @@ const modulus = 'A6F44A9C25791431214F5C87AF9E040177A8BB89AC803F7E09BBC3A5519F' +
'EBDAF1191F4A4E26D71879C4C7867B62FCD508E8CE66E82D128A71E91580' +
'9FCF44E8DE774067F1DE5D70B9C03687';
-var CRLF = '\r\n';
-var body = 'hello world\n';
-var cert;
+const CRLF = '\r\n';
+const body = 'hello world\n';
+let cert;
-var server = https.createServer(options, common.mustCall(function(req, res) {
+const server = https.createServer(options, common.mustCall(function(req, res) {
console.log('got request');
cert = req.connection.getPeerCertificate();
@@ -51,21 +51,21 @@ var server = https.createServer(options, common.mustCall(function(req, res) {
}));
server.listen(0, function() {
- var args = ['s_client',
- '-quiet',
- '-connect', `127.0.0.1:${this.address().port}`,
- '-cert', join(common.fixturesDir, 'foafssl.crt'),
- '-key', join(common.fixturesDir, 'foafssl.key')];
+ const args = ['s_client',
+ '-quiet',
+ '-connect', `127.0.0.1:${this.address().port}`,
+ '-cert', join(common.fixturesDir, 'foafssl.crt'),
+ '-key', join(common.fixturesDir, 'foafssl.key')];
// for the performance and stability issue in s_client on Windows
if (common.isWindows)
args.push('-no_rand_screen');
- var client = spawn(common.opensslCli, args);
+ const client = spawn(common.opensslCli, args);
client.stdout.on('data', function(data) {
- var message = data.toString();
- var contents = message.split(CRLF + CRLF).pop();
+ const message = data.toString();
+ const contents = message.split(CRLF + CRLF).pop();
assert.equal(body, contents);
server.close();
});
diff --git a/test/parallel/test-https-host-headers.js b/test/parallel/test-https-host-headers.js
index e4fd6dfe92ef15..d16afa16006576 100644
--- a/test/parallel/test-https-host-headers.js
+++ b/test/parallel/test-https-host-headers.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
const fs = require('fs');
const options = {
@@ -37,7 +37,7 @@ testHttps();
function testHttps() {
- var counter = 0;
+ let counter = 0;
function cb(res) {
counter--;
diff --git a/test/parallel/test-https-localaddress-bind-error.js b/test/parallel/test-https-localaddress-bind-error.js
index 91c3062a6e1896..662d6f080a0fff 100644
--- a/test/parallel/test-https-localaddress-bind-error.js
+++ b/test/parallel/test-https-localaddress-bind-error.js
@@ -1,21 +1,21 @@
'use strict';
-var common = require('../common');
-var fs = require('fs');
+const common = require('../common');
+const fs = require('fs');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var invalidLocalAddress = '1.2.3.4';
+const invalidLocalAddress = '1.2.3.4';
-var server = https.createServer(options, function(req, res) {
+const server = https.createServer(options, function(req, res) {
console.log('Connect from: ' + req.connection.remoteAddress);
req.on('end', function() {
diff --git a/test/parallel/test-https-localaddress.js b/test/parallel/test-https-localaddress.js
index e6aa0c93a2aaaa..78583b38ecf1cf 100644
--- a/test/parallel/test-https-localaddress.js
+++ b/test/parallel/test-https-localaddress.js
@@ -7,19 +7,19 @@ if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
if (!common.hasMultiLocalhost()) {
common.skip('platform-specific test.');
return;
}
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var server = https.createServer(options, function(req, res) {
+const server = https.createServer(options, function(req, res) {
console.log('Connect from: ' + req.connection.remoteAddress);
assert.equal('127.0.0.2', req.connection.remoteAddress);
@@ -31,7 +31,7 @@ var server = https.createServer(options, function(req, res) {
});
server.listen(0, '127.0.0.1', function() {
- var options = {
+ const options = {
host: 'localhost',
port: this.address().port,
path: '/',
@@ -40,7 +40,7 @@ server.listen(0, '127.0.0.1', function() {
rejectUnauthorized: false
};
- var req = https.request(options, function(res) {
+ const req = https.request(options, function(res) {
res.on('end', function() {
server.close();
process.exit();
diff --git a/test/parallel/test-https-pfx.js b/test/parallel/test-https-pfx.js
index 02715de60da3c8..c30bbc0848d137 100644
--- a/test/parallel/test-https-pfx.js
+++ b/test/parallel/test-https-pfx.js
@@ -1,17 +1,17 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const fs = require('fs');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var pfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx');
+const pfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx');
-var options = {
+const options = {
host: '127.0.0.1',
port: undefined,
path: '/',
@@ -21,7 +21,7 @@ var options = {
rejectUnauthorized: false
};
-var server = https.createServer(options, function(req, res) {
+const server = https.createServer(options, function(req, res) {
assert.equal(req.socket.authorized, false); // not a client cert
assert.equal(req.socket.authorizationError, 'DEPTH_ZERO_SELF_SIGNED_CERT');
res.writeHead(200);
@@ -32,7 +32,7 @@ server.listen(0, options.host, common.mustCall(function() {
options.port = this.address().port;
https.get(options, common.mustCall(function(res) {
- var data = '';
+ let data = '';
res.on('data', function(data_) { data += data_; });
res.on('end', common.mustCall(function() {
diff --git a/test/parallel/test-https-req-split.js b/test/parallel/test-https-req-split.js
index b49c17f28879be..4298abe5eff43d 100644
--- a/test/parallel/test-https-req-split.js
+++ b/test/parallel/test-https-req-split.js
@@ -7,12 +7,12 @@ if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var tls = require('tls');
-var fs = require('fs');
+const tls = require('tls');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
@@ -20,7 +20,7 @@ var options = {
// Force splitting incoming data
tls.SLAB_BUFFER_SIZE = 1;
-var server = https.createServer(options);
+const server = https.createServer(options);
server.on('upgrade', common.mustCall(function(req, socket, upgrade) {
socket.on('data', function(data) {
throw new Error('Unexpected data: ' + data);
@@ -29,7 +29,7 @@ server.on('upgrade', common.mustCall(function(req, socket, upgrade) {
}));
server.listen(0, function() {
- var req = https.request({
+ const req = https.request({
host: '127.0.0.1',
port: this.address().port,
agent: false,
diff --git a/test/parallel/test-https-resume-after-renew.js b/test/parallel/test-https-resume-after-renew.js
index 001952bfd9b591..72006b03750d82 100644
--- a/test/parallel/test-https-resume-after-renew.js
+++ b/test/parallel/test-https-resume-after-renew.js
@@ -1,27 +1,28 @@
'use strict';
-var common = require('../common');
-var fs = require('fs');
-var https = require('https');
-var crypto = require('crypto');
+const common = require('../common');
+const fs = require('fs');
+const https = require('https');
+const crypto = require('crypto');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'),
ca: fs.readFileSync(common.fixturesDir + '/keys/ca1-cert.pem')
};
-var server = https.createServer(options, function(req, res) {
+const server = https.createServer(options, function(req, res) {
res.end('hello');
});
-var aes = Buffer.alloc(16, 'S');
-var hmac = Buffer.alloc(16, 'H');
+const aes = Buffer.alloc(16, 'S');
+const hmac = Buffer.alloc(16, 'H');
server._sharedCreds.context.enableTicketKeyCallback();
+let newName, newIV;
server._sharedCreds.context.onticketkeycallback = function(name, iv, enc) {
if (enc) {
- var newName = Buffer.alloc(16, 'A');
- var newIV = crypto.randomBytes(16);
+ newName = Buffer.alloc(16, 'A');
+ newIV = crypto.randomBytes(16);
} else {
// Renew
return [ 2, hmac, aes ];
@@ -31,7 +32,7 @@ server._sharedCreds.context.onticketkeycallback = function(name, iv, enc) {
};
server.listen(0, function() {
- var addr = this.address();
+ const addr = this.address();
function doReq(callback) {
https.request({
diff --git a/test/parallel/test-https-set-timeout-server.js b/test/parallel/test-https-set-timeout-server.js
index fd00a521a03cb5..99457fea5cbec4 100644
--- a/test/parallel/test-https-set-timeout-server.js
+++ b/test/parallel/test-https-set-timeout-server.js
@@ -1,19 +1,19 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var tls = require('tls');
-var fs = require('fs');
+const tls = require('tls');
+const fs = require('fs');
-var tests = [];
+const tests = [];
-var serverOptions = {
+const serverOptions = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
@@ -25,7 +25,7 @@ function test(fn) {
}
function run() {
- var fn = tests.shift();
+ const fn = tests.shift();
if (fn) {
console.log('# %s', fn.name);
fn(run);
@@ -35,11 +35,11 @@ function run() {
}
test(function serverTimeout(cb) {
- var server = https.createServer(serverOptions, function(req, res) {
+ const server = https.createServer(serverOptions, function(req, res) {
// just do nothing, we should get a timeout event.
});
server.listen(0, common.mustCall(function() {
- var s = server.setTimeout(50, common.mustCall(function(socket) {
+ const s = server.setTimeout(50, common.mustCall(function(socket) {
socket.destroy();
server.close();
cb();
@@ -62,9 +62,9 @@ test(function serverRequestTimeout(cb) {
}));
}
- var server = https.createServer(serverOptions, common.mustCall(handler));
+ let server = https.createServer(serverOptions, common.mustCall(handler));
server.listen(0, function() {
- var req = https.request({
+ const req = https.request({
port: this.address().port,
method: 'POST',
rejectUnauthorized: false
@@ -85,7 +85,7 @@ test(function serverResponseTimeout(cb) {
}));
}
- var server = https.createServer(serverOptions, common.mustCall(handler));
+ let server = https.createServer(serverOptions, common.mustCall(handler));
server.listen(0, function() {
https.get({
port: this.address().port,
@@ -100,7 +100,7 @@ test(function serverRequestNotTimeoutAfterEnd(cb) {
req.setTimeout(50, common.fail);
res.on('timeout', common.mustCall(function(socket) {}));
}
- var server = https.createServer(serverOptions, common.mustCall(handler));
+ const server = https.createServer(serverOptions, common.mustCall(handler));
server.on('timeout', function(socket) {
socket.destroy();
server.close();
@@ -115,11 +115,11 @@ test(function serverRequestNotTimeoutAfterEnd(cb) {
});
test(function serverResponseTimeoutWithPipeline(cb) {
- var caughtTimeout = '';
+ let caughtTimeout = '';
process.on('exit', function() {
assert.equal(caughtTimeout, '/2');
});
- var server = https.createServer(serverOptions, function(req, res) {
+ const server = https.createServer(serverOptions, function(req, res) {
res.setTimeout(50, function() {
caughtTimeout += req.url;
});
@@ -131,12 +131,12 @@ test(function serverResponseTimeoutWithPipeline(cb) {
cb();
});
server.listen(0, function() {
- var options = {
+ const options = {
port: this.address().port,
allowHalfOpen: true,
rejectUnauthorized: false
};
- var c = tls.connect(options, function() {
+ const c = tls.connect(options, function() {
c.write('GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n');
c.write('GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n');
c.write('GET /3 HTTP/1.1\r\nHost: localhost\r\n\r\n');
@@ -145,19 +145,19 @@ test(function serverResponseTimeoutWithPipeline(cb) {
});
test(function idleTimeout(cb) {
- var server = https.createServer(serverOptions,
- common.mustCall(function(req, res) {
- req.on('timeout', common.fail);
- res.on('timeout', common.fail);
- res.end();
- }));
+ const server = https.createServer(serverOptions,
+ common.mustCall(function(req, res) {
+ req.on('timeout', common.fail);
+ res.on('timeout', common.fail);
+ res.end();
+ }));
server.setTimeout(50, common.mustCall(function(socket) {
socket.destroy();
server.close();
cb();
}));
server.listen(0, function() {
- var options = {
+ const options = {
port: this.address().port,
allowHalfOpen: true,
rejectUnauthorized: false
diff --git a/test/parallel/test-https-socket-options.js b/test/parallel/test-https-socket-options.js
index 70013d1770ff98..05137b35c437ff 100644
--- a/test/parallel/test-https-socket-options.js
+++ b/test/parallel/test-https-socket-options.js
@@ -1,26 +1,26 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var fs = require('fs');
+const fs = require('fs');
-var http = require('http');
+const http = require('http');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var body = 'hello world\n';
+const body = 'hello world\n';
// Try first with http server
-var server_http = http.createServer(function(req, res) {
+const server_http = http.createServer(function(req, res) {
console.log('got HTTP request');
res.writeHead(200, { 'content-type': 'text/plain' });
res.end(body);
@@ -28,7 +28,7 @@ var server_http = http.createServer(function(req, res) {
server_http.listen(0, function() {
- var req = http.request({
+ const req = http.request({
port: this.address().port,
rejectUnauthorized: false
}, function(res) {
@@ -45,14 +45,14 @@ server_http.listen(0, function() {
// Then try https server (requires functions to be
// mirroed in tls.js's CryptoStream)
-var server_https = https.createServer(options, function(req, res) {
+const server_https = https.createServer(options, function(req, res) {
console.log('got HTTPS request');
res.writeHead(200, { 'content-type': 'text/plain' });
res.end(body);
});
server_https.listen(0, function() {
- var req = https.request({
+ const req = https.request({
port: this.address().port,
rejectUnauthorized: false
}, function(res) {
diff --git a/test/parallel/test-https-strict.js b/test/parallel/test-https-strict.js
index e62f8ad01549e5..f4cff31bdf3538 100644
--- a/test/parallel/test-https-strict.js
+++ b/test/parallel/test-https-strict.js
@@ -3,16 +3,16 @@ const common = require('../common');
// disable strict server certificate validation by the client
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
-var assert = require('assert');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var fs = require('fs');
-var path = require('path');
+const fs = require('fs');
+const path = require('path');
function file(fname) {
return path.resolve(common.fixturesDir, 'keys', fname);
@@ -23,60 +23,60 @@ function read(fname) {
}
// key1 is signed by ca1.
-var key1 = read('agent1-key.pem');
-var cert1 = read('agent1-cert.pem');
+const key1 = read('agent1-key.pem');
+const cert1 = read('agent1-cert.pem');
// key2 has a self signed cert
-var key2 = read('agent2-key.pem');
-var cert2 = read('agent2-cert.pem');
+const key2 = read('agent2-key.pem');
+const cert2 = read('agent2-cert.pem');
// key3 is signed by ca2.
-var key3 = read('agent3-key.pem');
-var cert3 = read('agent3-cert.pem');
+const key3 = read('agent3-key.pem');
+const cert3 = read('agent3-cert.pem');
-var ca1 = read('ca1-cert.pem');
-var ca2 = read('ca2-cert.pem');
+const ca1 = read('ca1-cert.pem');
+const ca2 = read('ca2-cert.pem');
// different agents to use different CA lists.
// this api is beyond bad.
-var agent0 = new https.Agent();
-var agent1 = new https.Agent({ ca: [ca1] });
-var agent2 = new https.Agent({ ca: [ca2] });
-var agent3 = new https.Agent({ ca: [ca1, ca2] });
+const agent0 = new https.Agent();
+const agent1 = new https.Agent({ ca: [ca1] });
+const agent2 = new https.Agent({ ca: [ca2] });
+const agent3 = new https.Agent({ ca: [ca1, ca2] });
-var options1 = {
+const options1 = {
key: key1,
cert: cert1
};
-var options2 = {
+const options2 = {
key: key2,
cert: cert2
};
-var options3 = {
+const options3 = {
key: key3,
cert: cert3
};
-var server1 = server(options1);
-var server2 = server(options2);
-var server3 = server(options3);
+const server1 = server(options1);
+const server2 = server(options2);
+const server3 = server(options3);
-var listenWait = 0;
+let listenWait = 0;
server1.listen(0, listening());
server2.listen(0, listening());
server3.listen(0, listening());
-var responseErrors = {};
-var expectResponseCount = 0;
-var responseCount = 0;
-var pending = 0;
+const responseErrors = {};
+let expectResponseCount = 0;
+let responseCount = 0;
+let pending = 0;
function server(options, port) {
- var s = https.createServer(options, handler);
+ const s = https.createServer(options, handler);
s.requests = [];
s.expectCount = 0;
return s;
@@ -101,7 +101,7 @@ function listening() {
function makeReq(path, port, error, host, ca) {
pending++;
- var options = {
+ const options = {
port: port,
path: path,
ca: ca
@@ -125,9 +125,9 @@ function makeReq(path, port, error, host, ca) {
if (host) {
options.headers = { host: host };
}
- var req = https.get(options);
+ const req = https.get(options);
expectResponseCount++;
- var server = port === server1.address().port ? server1
+ const server = port === server1.address().port ? server1
: port === server2.address().port ? server2
: port === server3.address().port ? server3
: null;
diff --git a/test/parallel/test-https-timeout-server-2.js b/test/parallel/test-https-timeout-server-2.js
index 07b7984f2d644b..8729af1ae8b4ba 100644
--- a/test/parallel/test-https-timeout-server-2.js
+++ b/test/parallel/test-https-timeout-server-2.js
@@ -1,26 +1,26 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var tls = require('tls');
-var fs = require('fs');
+const tls = require('tls');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var server = https.createServer(options, common.fail);
+const server = https.createServer(options, common.fail);
server.on('secureConnection', function(cleartext) {
- var s = cleartext.setTimeout(50, function() {
+ const s = cleartext.setTimeout(50, function() {
cleartext.destroy();
server.close();
});
diff --git a/test/parallel/test-internal-modules-expose.js b/test/parallel/test-internal-modules-expose.js
index ed3cecb6f29719..dd3a7f7a3cd0b7 100644
--- a/test/parallel/test-internal-modules-expose.js
+++ b/test/parallel/test-internal-modules-expose.js
@@ -2,6 +2,6 @@
// Flags: --expose_internals
require('../common');
-var assert = require('assert');
+const assert = require('assert');
assert.equal(typeof require('internal/freelist').FreeList, 'function');
diff --git a/test/parallel/test-listen-fd-cluster.js b/test/parallel/test-listen-fd-cluster.js
index 606109030b51d0..de1fbed7b56aff 100644
--- a/test/parallel/test-listen-fd-cluster.js
+++ b/test/parallel/test-listen-fd-cluster.js
@@ -1,9 +1,9 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
-var cluster = require('cluster');
+const common = require('../common');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
+const cluster = require('cluster');
console.error('Cluster listen fd test', process.argv[2] || 'runner');
@@ -22,7 +22,7 @@ switch (process.argv[2]) {
case 'worker': return worker();
}
-var ok;
+let ok;
process.on('exit', function() {
assert.ok(ok);
@@ -41,7 +41,7 @@ test(function(parent, port) {
port: port,
path: '/',
}).on('response', function(res) {
- var s = '';
+ let s = '';
res.on('data', function(c) {
s += c.toString();
});
@@ -61,15 +61,15 @@ test(function(parent, port) {
function test(cb) {
console.error('about to listen in parent');
- var server = net.createServer(function(conn) {
+ const server = net.createServer(function(conn) {
console.error('connection on parent');
conn.end('hello from parent\n');
}).listen(0, function() {
const port = this.address().port;
console.error('server listening on %d', port);
- var spawn = require('child_process').spawn;
- var master = spawn(process.execPath, [__filename, 'master'], {
+ const spawn = require('child_process').spawn;
+ const master = spawn(process.execPath, [__filename, 'master'], {
stdio: [ 0, 'pipe', 2, server._handle, 'ipc' ],
detached: true
});
@@ -100,7 +100,7 @@ function master() {
cluster.setupMaster({
args: [ 'worker' ]
});
- var worker = cluster.fork();
+ const worker = cluster.fork();
worker.on('message', function(msg) {
if (msg === 'worker ready') {
process.send('started worker');
diff --git a/test/parallel/test-listen-fd-detached-inherit.js b/test/parallel/test-listen-fd-detached-inherit.js
index 5dfe346a49f441..2ac4d83dba6691 100644
--- a/test/parallel/test-listen-fd-detached-inherit.js
+++ b/test/parallel/test-listen-fd-detached-inherit.js
@@ -1,9 +1,9 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
-var spawn = require('child_process').spawn;
+const common = require('../common');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
+const spawn = require('child_process').spawn;
if (common.isWindows) {
common.skip('This test is disabled on windows.');
@@ -23,24 +23,24 @@ switch (process.argv[2]) {
// concurrency in HTTP servers! Use the cluster module, or if you want
// a more low-level approach, use child process IPC manually.
function test() {
- var parent = spawn(process.execPath, [__filename, 'parent'], {
+ const parent = spawn(process.execPath, [__filename, 'parent'], {
stdio: [ 0, 'pipe', 2 ]
});
- var json = '';
+ let json = '';
parent.stdout.on('data', function(c) {
json += c.toString();
if (json.indexOf('\n') !== -1) next();
});
function next() {
console.error('output from parent = %s', json);
- var child = JSON.parse(json);
+ const child = JSON.parse(json);
// now make sure that we can request to the child, then kill it.
http.get({
server: 'localhost',
port: child.port,
path: '/',
}).on('response', function(res) {
- var s = '';
+ let s = '';
res.on('data', function(c) {
s += c.toString();
});
@@ -62,13 +62,13 @@ function test() {
// Listen on port, and then pass the handle to the detached child.
// Then output the child's pid, and immediately exit.
function parent() {
- var server = net.createServer(function(conn) {
+ const server = net.createServer(function(conn) {
conn.end('HTTP/1.1 403 Forbidden\r\n\r\nI got problems.\r\n');
throw new Error('Should not see connections on parent');
}).listen(0, function() {
console.error('server listening on %d', this.address().port);
- var child = spawn(process.execPath, [__filename, 'child'], {
+ const child = spawn(process.execPath, [__filename, 'child'], {
stdio: [ 0, 1, 2, server._handle ],
detached: true
});
diff --git a/test/parallel/test-listen-fd-detached.js b/test/parallel/test-listen-fd-detached.js
index 0629f7ea7970d7..1194d001610fce 100644
--- a/test/parallel/test-listen-fd-detached.js
+++ b/test/parallel/test-listen-fd-detached.js
@@ -1,9 +1,9 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
-var spawn = require('child_process').spawn;
+const common = require('../common');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
+const spawn = require('child_process').spawn;
if (common.isWindows) {
common.skip('This test is disabled on windows.');
@@ -23,24 +23,24 @@ switch (process.argv[2]) {
// concurrency in HTTP servers! Use the cluster module, or if you want
// a more low-level approach, use child process IPC manually.
function test() {
- var parent = spawn(process.execPath, [__filename, 'parent'], {
+ const parent = spawn(process.execPath, [__filename, 'parent'], {
stdio: [ 0, 'pipe', 2 ]
});
- var json = '';
+ let json = '';
parent.stdout.on('data', function(c) {
json += c.toString();
if (json.indexOf('\n') !== -1) next();
});
function next() {
console.error('output from parent = %s', json);
- var child = JSON.parse(json);
+ const child = JSON.parse(json);
// now make sure that we can request to the child, then kill it.
http.get({
server: 'localhost',
port: child.port,
path: '/',
}).on('response', function(res) {
- var s = '';
+ let s = '';
res.on('data', function(c) {
s += c.toString();
});
@@ -60,14 +60,14 @@ function test() {
}
function parent() {
- var server = net.createServer(function(conn) {
+ const server = net.createServer(function(conn) {
console.error('connection on parent');
conn.end('hello from parent\n');
}).listen(0, function() {
console.error('server listening on %d', this.address().port);
- var spawn = require('child_process').spawn;
- var child = spawn(process.execPath, [__filename, 'child'], {
+ const spawn = require('child_process').spawn;
+ const child = spawn(process.execPath, [__filename, 'child'], {
stdio: [ 'ignore', 'ignore', 'ignore', server._handle ],
detached: true
});
diff --git a/test/parallel/test-listen-fd-server.js b/test/parallel/test-listen-fd-server.js
index eda75e5c723261..60aa8717a8c24e 100644
--- a/test/parallel/test-listen-fd-server.js
+++ b/test/parallel/test-listen-fd-server.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const http = require('http');
+const net = require('net');
if (common.isWindows) {
common.skip('This test is disabled on windows.');
@@ -13,7 +13,7 @@ switch (process.argv[2]) {
case 'child': return child();
}
-var ok;
+let ok;
process.on('exit', function() {
assert.ok(ok);
@@ -31,7 +31,7 @@ test(function(child, port) {
port: port,
path: '/',
}).on('response', function(res) {
- var s = '';
+ let s = '';
res.on('data', function(c) {
s += c.toString();
});
@@ -67,15 +67,15 @@ function child() {
}
function test(cb) {
- var server = net.createServer(function(conn) {
+ const server = net.createServer(function(conn) {
console.error('connection on parent');
conn.end('hello from parent\n');
}).listen(0, function() {
const port = this.address().port;
console.error('server listening on %d', port);
- var spawn = require('child_process').spawn;
- var child = spawn(process.execPath, [__filename, 'child'], {
+ const spawn = require('child_process').spawn;
+ const child = spawn(process.execPath, [__filename, 'child'], {
stdio: [ 0, 1, 2, server._handle, 'ipc' ]
});
diff --git a/test/parallel/test-memory-usage-emfile.js b/test/parallel/test-memory-usage-emfile.js
index 92c103669a9a85..09ab270b70fa21 100644
--- a/test/parallel/test-memory-usage-emfile.js
+++ b/test/parallel/test-memory-usage-emfile.js
@@ -1,13 +1,13 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var fs = require('fs');
+const fs = require('fs');
-var files = [];
+const files = [];
while (files.length < 256)
files.push(fs.openSync(__filename, 'r'));
-var r = process.memoryUsage();
+const r = process.memoryUsage();
assert.equal(true, r['rss'] > 0);
diff --git a/test/parallel/test-memory-usage.js b/test/parallel/test-memory-usage.js
index c5905c537ac613..cba3f9a5172a07 100644
--- a/test/parallel/test-memory-usage.js
+++ b/test/parallel/test-memory-usage.js
@@ -1,8 +1,8 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var r = process.memoryUsage();
+const r = process.memoryUsage();
assert.ok(r.rss > 0);
assert.ok(r.heapTotal > 0);
assert.ok(r.heapUsed > 0);
diff --git a/test/parallel/test-microtask-queue-integration-domain.js b/test/parallel/test-microtask-queue-integration-domain.js
index 1e07fa5d415ba3..7110af7648ae8a 100644
--- a/test/parallel/test-microtask-queue-integration-domain.js
+++ b/test/parallel/test-microtask-queue-integration-domain.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// Requiring the domain module here changes the function that is used by node to
// call process.nextTick's callbacks to a variant that specifically handles
@@ -9,21 +9,21 @@ var assert = require('assert');
// removed.
require('domain');
-var implementations = [
+const implementations = [
function(fn) {
Promise.resolve().then(fn);
}
];
-var expected = 0;
-var done = 0;
+let expected = 0;
+let done = 0;
process.on('exit', function() {
assert.equal(done, expected);
});
function test(scheduleMicrotask) {
- var nextTickCalled = false;
+ let nextTickCalled = false;
expected++;
scheduleMicrotask(function() {
diff --git a/test/parallel/test-microtask-queue-integration.js b/test/parallel/test-microtask-queue-integration.js
index 2cc608d96aec3d..d212bbae96b001 100644
--- a/test/parallel/test-microtask-queue-integration.js
+++ b/test/parallel/test-microtask-queue-integration.js
@@ -1,22 +1,22 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var implementations = [
+const implementations = [
function(fn) {
Promise.resolve().then(fn);
}
];
-var expected = 0;
-var done = 0;
+let expected = 0;
+let done = 0;
process.on('exit', function() {
assert.equal(done, expected);
});
function test(scheduleMicrotask) {
- var nextTickCalled = false;
+ let nextTickCalled = false;
expected++;
scheduleMicrotask(function() {
diff --git a/test/parallel/test-microtask-queue-run-domain.js b/test/parallel/test-microtask-queue-run-domain.js
index fb5139f71d65aa..7d34ec829a003c 100644
--- a/test/parallel/test-microtask-queue-run-domain.js
+++ b/test/parallel/test-microtask-queue-run-domain.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// Requiring the domain module here changes the function that is used by node to
// call process.nextTick's callbacks to a variant that specifically handles
@@ -13,7 +13,7 @@ function enqueueMicrotask(fn) {
Promise.resolve().then(fn);
}
-var done = 0;
+let done = 0;
process.on('exit', function() {
assert.equal(done, 2);
@@ -29,7 +29,7 @@ setTimeout(function() {
// no nextTick, microtask with nextTick
setTimeout(function() {
- var called = false;
+ let called = false;
enqueueMicrotask(function() {
process.nextTick(function() {
diff --git a/test/parallel/test-microtask-queue-run-immediate-domain.js b/test/parallel/test-microtask-queue-run-immediate-domain.js
index 4a7729ab98a062..e09087f74e32a9 100644
--- a/test/parallel/test-microtask-queue-run-immediate-domain.js
+++ b/test/parallel/test-microtask-queue-run-immediate-domain.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// Requiring the domain module here changes the function that is used by node to
// call process.nextTick's callbacks to a variant that specifically handles
@@ -13,7 +13,7 @@ function enqueueMicrotask(fn) {
Promise.resolve().then(fn);
}
-var done = 0;
+let done = 0;
process.on('exit', function() {
assert.equal(done, 2);
@@ -29,7 +29,7 @@ setImmediate(function() {
// no nextTick, microtask with nextTick
setImmediate(function() {
- var called = false;
+ let called = false;
enqueueMicrotask(function() {
process.nextTick(function() {
diff --git a/test/parallel/test-microtask-queue-run-immediate.js b/test/parallel/test-microtask-queue-run-immediate.js
index 479062ad4710f4..c5ed6c6dcbc1ae 100644
--- a/test/parallel/test-microtask-queue-run-immediate.js
+++ b/test/parallel/test-microtask-queue-run-immediate.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
function enqueueMicrotask(fn) {
Promise.resolve().then(fn);
}
-var done = 0;
+let done = 0;
process.on('exit', function() {
assert.equal(done, 2);
@@ -22,7 +22,7 @@ setImmediate(function() {
// no nextTick, microtask with nextTick
setImmediate(function() {
- var called = false;
+ let called = false;
enqueueMicrotask(function() {
process.nextTick(function() {
diff --git a/test/parallel/test-microtask-queue-run.js b/test/parallel/test-microtask-queue-run.js
index ce743d93003249..71e1fbedbaecbd 100644
--- a/test/parallel/test-microtask-queue-run.js
+++ b/test/parallel/test-microtask-queue-run.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
function enqueueMicrotask(fn) {
Promise.resolve().then(fn);
}
-var done = 0;
+let done = 0;
process.on('exit', function() {
assert.equal(done, 2);
@@ -22,7 +22,7 @@ setTimeout(function() {
// no nextTick, microtask with nextTick
setTimeout(function() {
- var called = false;
+ let called = false;
enqueueMicrotask(function() {
process.nextTick(function() {
diff --git a/test/parallel/test-module-globalpaths-nodepath.js b/test/parallel/test-module-globalpaths-nodepath.js
index 3369df0676015b..a4781d27a7a9c6 100644
--- a/test/parallel/test-module-globalpaths-nodepath.js
+++ b/test/parallel/test-module-globalpaths-nodepath.js
@@ -1,11 +1,11 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var module = require('module');
+const mod = require('module');
-var partA, partB;
-var partC = '';
+let partA, partB;
+const partC = '';
if (common.isWindows) {
partA = 'C:\\Users\\Rocko Artischocko\\AppData\\Roaming\\npm';
@@ -17,10 +17,10 @@ if (common.isWindows) {
process.env['NODE_PATH'] = partA + ':' + partB + ':' + partC;
}
-module._initPaths();
+mod._initPaths();
-assert.ok(module.globalPaths.indexOf(partA) !== -1);
-assert.ok(module.globalPaths.indexOf(partB) !== -1);
-assert.ok(module.globalPaths.indexOf(partC) === -1);
+assert.ok(mod.globalPaths.indexOf(partA) !== -1);
+assert.ok(mod.globalPaths.indexOf(partB) !== -1);
+assert.ok(mod.globalPaths.indexOf(partC) === -1);
-assert.ok(Array.isArray(module.globalPaths));
+assert.ok(Array.isArray(mod.globalPaths));
diff --git a/test/parallel/test-module-loading-error.js b/test/parallel/test-module-loading-error.js
index 145530985401e4..03481b690f79f4 100644
--- a/test/parallel/test-module-loading-error.js
+++ b/test/parallel/test-module-loading-error.js
@@ -1,16 +1,16 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
console.error('load test-module-loading-error.js');
-var error_desc = {
+const error_desc = {
win32: ['%1 is not a valid Win32 application'],
linux: ['file too short', 'Exec format error'],
sunos: ['unknown file type', 'not an ELF file'],
darwin: ['file too short']
};
-var dlerror_msg = error_desc[process.platform];
+const dlerror_msg = error_desc[process.platform];
if (!dlerror_msg) {
common.skip('platform not supported.');
diff --git a/test/parallel/test-module-version.js b/test/parallel/test-module-version.js
index 7f96e8bb60f0ac..04f011bbfacd8e 100644
--- a/test/parallel/test-module-version.js
+++ b/test/parallel/test-module-version.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// check for existence
assert(process.config.variables.hasOwnProperty('node_module_version'));
diff --git a/test/parallel/test-net-after-close.js b/test/parallel/test-net-after-close.js
index a73663e7da86db..d46f096116d02e 100644
--- a/test/parallel/test-net-after-close.js
+++ b/test/parallel/test-net-after-close.js
@@ -1,15 +1,15 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var server = net.createServer(function(s) {
+const server = net.createServer(function(s) {
console.error('SERVER: got connection');
s.end();
});
server.listen(0, common.mustCall(function() {
- var c = net.createConnection(this.address().port);
+ const c = net.createConnection(this.address().port);
c.on('close', common.mustCall(function() {
console.error('connection closed');
assert.strictEqual(c._handle, null);
diff --git a/test/parallel/test-net-better-error-messages-path.js b/test/parallel/test-net-better-error-messages-path.js
index 9222a1cc758aaa..2f821ef5d703be 100644
--- a/test/parallel/test-net-better-error-messages-path.js
+++ b/test/parallel/test-net-better-error-messages-path.js
@@ -1,9 +1,9 @@
'use strict';
-var common = require('../common');
-var net = require('net');
-var assert = require('assert');
-var fp = '/tmp/fadagagsdfgsdf';
-var c = net.connect(fp);
+const common = require('../common');
+const net = require('net');
+const assert = require('assert');
+const fp = '/tmp/fadagagsdfgsdf';
+const c = net.connect(fp);
c.on('connect', common.fail);
diff --git a/test/parallel/test-net-binary.js b/test/parallel/test-net-binary.js
index 47e0be8d04dcf6..bcc554ac4024f6 100644
--- a/test/parallel/test-net-binary.js
+++ b/test/parallel/test-net-binary.js
@@ -3,8 +3,8 @@ require('../common');
const assert = require('assert');
const net = require('net');
-var binaryString = '';
-for (var i = 255; i >= 0; i--) {
+let binaryString = '';
+for (let i = 255; i >= 0; i--) {
const s = `'\\${i.toString(8)}'`;
const S = eval(s);
assert.strictEqual(S.charCodeAt(0), i);
@@ -13,7 +13,7 @@ for (var i = 255; i >= 0; i--) {
}
// safe constructor
-var echoServer = net.Server(function(connection) {
+const echoServer = net.Server(function(connection) {
connection.setEncoding('latin1');
connection.on('data', function(chunk) {
connection.write(chunk, 'latin1');
@@ -24,10 +24,10 @@ var echoServer = net.Server(function(connection) {
});
echoServer.listen(0);
-var recv = '';
+let recv = '';
echoServer.on('listening', function() {
- var j = 0;
+ let j = 0;
const c = net.createConnection({
port: this.address().port
});
diff --git a/test/parallel/test-net-bind-twice.js b/test/parallel/test-net-bind-twice.js
index 9b9fc7c5db37dd..17fdc90cb3742b 100644
--- a/test/parallel/test-net-bind-twice.js
+++ b/test/parallel/test-net-bind-twice.js
@@ -1,11 +1,11 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var server1 = net.createServer(common.fail);
+const server1 = net.createServer(common.fail);
server1.listen(0, '127.0.0.1', common.mustCall(function() {
- var server2 = net.createServer(common.fail);
+ const server2 = net.createServer(common.fail);
server2.listen(this.address().port, '127.0.0.1', common.fail);
server2.on('error', common.mustCall(function(e) {
diff --git a/test/parallel/test-net-buffersize.js b/test/parallel/test-net-buffersize.js
index 872d8de7b42f3b..e8ba17a76e6c69 100644
--- a/test/parallel/test-net-buffersize.js
+++ b/test/parallel/test-net-buffersize.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var iter = 10;
+const iter = 10;
-var server = net.createServer(function(socket) {
+const server = net.createServer(function(socket) {
socket.on('readable', function() {
socket.read();
});
@@ -16,13 +16,13 @@ var server = net.createServer(function(socket) {
});
server.listen(0, function() {
- var client = net.connect(this.address().port);
+ const client = net.connect(this.address().port);
client.on('finish', function() {
assert.strictEqual(client.bufferSize, 0);
});
- for (var i = 1; i < iter; i++) {
+ for (let i = 1; i < iter; i++) {
client.write('a');
assert.strictEqual(client.bufferSize, i);
}
diff --git a/test/parallel/test-net-bytes-stats.js b/test/parallel/test-net-bytes-stats.js
index a8643b03b97250..4cc6eee8373e86 100644
--- a/test/parallel/test-net-bytes-stats.js
+++ b/test/parallel/test-net-bytes-stats.js
@@ -1,13 +1,13 @@
'use strict';
require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var bytesRead = 0;
-var bytesWritten = 0;
-var count = 0;
+let bytesRead = 0;
+let bytesWritten = 0;
+let count = 0;
-var tcp = net.Server(function(s) {
+const tcp = net.Server(function(s) {
console.log('tcp server connection');
// trigger old mode.
@@ -21,7 +21,7 @@ var tcp = net.Server(function(s) {
tcp.listen(0, function doTest() {
console.error('listening');
- var socket = net.createConnection(this.address().port);
+ const socket = net.createConnection(this.address().port);
socket.on('connect', function() {
count++;
diff --git a/test/parallel/test-net-can-reset-timeout.js b/test/parallel/test-net-can-reset-timeout.js
index 7dbd5cad2ae6bb..faa460e847aa08 100644
--- a/test/parallel/test-net-can-reset-timeout.js
+++ b/test/parallel/test-net-can-reset-timeout.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var net = require('net');
+const net = require('net');
-var server = net.createServer(common.mustCall(function(stream) {
+const server = net.createServer(common.mustCall(function(stream) {
stream.setTimeout(100);
stream.resume();
@@ -20,7 +20,7 @@ var server = net.createServer(common.mustCall(function(stream) {
}));
server.listen(0, function() {
- var c = net.createConnection(this.address().port);
+ const c = net.createConnection(this.address().port);
c.on('data', function() {
c.end();
diff --git a/test/parallel/test-net-connect-buffer.js b/test/parallel/test-net-connect-buffer.js
index 3ef5b0ea9f075d..c43ee1abd0e305 100644
--- a/test/parallel/test-net-connect-buffer.js
+++ b/test/parallel/test-net-connect-buffer.js
@@ -1,17 +1,17 @@
'use strict';
require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var dataWritten = false;
-var connectHappened = false;
+let dataWritten = false;
+let connectHappened = false;
-var tcp = net.Server(function(s) {
+const tcp = net.Server(function(s) {
tcp.close();
console.log('tcp server connection');
- var buf = '';
+ let buf = '';
s.on('data', function(d) {
buf += d;
});
@@ -30,7 +30,7 @@ var tcp = net.Server(function(s) {
});
tcp.listen(0, function() {
- var socket = net.Stream({ highWaterMark: 0 });
+ const socket = net.Stream({ highWaterMark: 0 });
console.log('Connecting to socket ');
@@ -65,13 +65,13 @@ tcp.listen(0, function() {
// Write a string that contains a multi-byte character sequence to test that
// `bytesWritten` is incremented with the # of bytes, not # of characters.
- var a = "L'État, c'est ";
- var b = 'moi';
+ const a = "L'État, c'est ";
+ const b = 'moi';
// We're still connecting at this point so the datagram is first pushed onto
// the connect queue. Make sure that it's not added to `bytesWritten` again
// when the actual write happens.
- var r = socket.write(a, function(er) {
+ const r = socket.write(a, function(er) {
console.error('write cb');
dataWritten = true;
assert.ok(connectHappened);
diff --git a/test/parallel/test-net-connect-local-error.js b/test/parallel/test-net-connect-local-error.js
index 2a0c20f6ea4a5e..f23245ac93a49f 100644
--- a/test/parallel/test-net-connect-local-error.js
+++ b/test/parallel/test-net-connect-local-error.js
@@ -3,7 +3,7 @@ const common = require('../common');
const assert = require('assert');
const net = require('net');
-var client = net.connect({
+const client = net.connect({
port: common.PORT + 1,
localPort: common.PORT,
localAddress: common.localhostIPv4
diff --git a/test/parallel/test-net-connect-options-ipv6.js b/test/parallel/test-net-connect-options-ipv6.js
index 7f638d66f59508..e9d8a78cbbefef 100644
--- a/test/parallel/test-net-connect-options-ipv6.js
+++ b/test/parallel/test-net-connect-options-ipv6.js
@@ -9,9 +9,9 @@ if (!common.hasIPv6) {
}
const hosts = common.localIPv6Hosts;
-var hostIdx = 0;
-var host = hosts[hostIdx];
-var localhostTries = 10;
+let hostIdx = 0;
+let host = hosts[hostIdx];
+let localhostTries = 10;
const server = net.createServer({allowHalfOpen: true}, function(socket) {
socket.resume();
diff --git a/test/parallel/test-net-connect-options.js b/test/parallel/test-net-connect-options.js
index 3446790d7b3c4a..e794c40859856a 100644
--- a/test/parallel/test-net-connect-options.js
+++ b/test/parallel/test-net-connect-options.js
@@ -1,9 +1,9 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var server = net.createServer({
+const server = net.createServer({
allowHalfOpen: true
}, common.mustCall(function(socket) {
socket.resume();
@@ -12,7 +12,7 @@ var server = net.createServer({
}));
server.listen(0, function() {
- var client = net.connect({
+ const client = net.connect({
host: '127.0.0.1',
port: this.address().port,
allowHalfOpen: true
diff --git a/test/parallel/test-net-connect-paused-connection.js b/test/parallel/test-net-connect-paused-connection.js
index 8c0e1c93cfb208..a0a90eefc1db3e 100644
--- a/test/parallel/test-net-connect-paused-connection.js
+++ b/test/parallel/test-net-connect-paused-connection.js
@@ -1,7 +1,7 @@
'use strict';
const common = require('../common');
-var net = require('net');
+const net = require('net');
net.createServer(function(conn) {
conn.unref();
diff --git a/test/parallel/test-net-create-connection.js b/test/parallel/test-net-create-connection.js
index a21f92a3a5674c..a5d8cd101d974d 100644
--- a/test/parallel/test-net-create-connection.js
+++ b/test/parallel/test-net-create-connection.js
@@ -5,8 +5,8 @@ const dns = require('dns');
const net = require('net');
const expectedConnections = 7;
-var clientConnected = 0;
-var serverConnected = 0;
+let clientConnected = 0;
+let serverConnected = 0;
const server = net.createServer(function(socket) {
socket.end();
diff --git a/test/parallel/test-net-dns-custom-lookup.js b/test/parallel/test-net-dns-custom-lookup.js
index 07eb71c5ed5811..c7a01f5fa6faec 100644
--- a/test/parallel/test-net-dns-custom-lookup.js
+++ b/test/parallel/test-net-dns-custom-lookup.js
@@ -1,16 +1,16 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
function check(addressType, cb) {
- var server = net.createServer(function(client) {
+ const server = net.createServer(function(client) {
client.end();
server.close();
cb && cb();
});
- var address = addressType === 4 ? common.localhostIPv4 : '::1';
+ const address = addressType === 4 ? common.localhostIPv4 : '::1';
server.listen(0, address, common.mustCall(function() {
net.connect({
port: this.address().port,
diff --git a/test/parallel/test-net-dns-error.js b/test/parallel/test-net-dns-error.js
index b36d84d3e9e214..aa288c5fde1ffa 100644
--- a/test/parallel/test-net-dns-error.js
+++ b/test/parallel/test-net-dns-error.js
@@ -1,16 +1,16 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var net = require('net');
+const net = require('net');
-var host = '*'.repeat(256);
+const host = '*'.repeat(256);
function do_not_call() {
throw new Error('This function should not have been called.');
}
-var socket = net.connect(42, host, do_not_call);
+const socket = net.connect(42, host, do_not_call);
socket.on('error', common.mustCall(function(err) {
assert.equal(err.code, 'ENOTFOUND');
}));
diff --git a/test/parallel/test-net-dns-lookup-skip.js b/test/parallel/test-net-dns-lookup-skip.js
index 513a6d0422498e..0997e6cc6c1c5d 100644
--- a/test/parallel/test-net-dns-lookup-skip.js
+++ b/test/parallel/test-net-dns-lookup-skip.js
@@ -1,14 +1,14 @@
'use strict';
-var common = require('../common');
-var net = require('net');
+const common = require('../common');
+const net = require('net');
function check(addressType) {
- var server = net.createServer(function(client) {
+ const server = net.createServer(function(client) {
client.end();
server.close();
});
- var address = addressType === 4 ? '127.0.0.1' : '::1';
+ const address = addressType === 4 ? '127.0.0.1' : '::1';
server.listen(0, address, function() {
net.connect(this.address().port, address).on('lookup', common.fail);
});
diff --git a/test/parallel/test-net-dns-lookup.js b/test/parallel/test-net-dns-lookup.js
index 4f3cd2991cf925..8d9930f4b7a366 100644
--- a/test/parallel/test-net-dns-lookup.js
+++ b/test/parallel/test-net-dns-lookup.js
@@ -1,9 +1,9 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var server = net.createServer(function(client) {
+const server = net.createServer(function(client) {
client.end();
server.close();
});
diff --git a/test/parallel/test-net-during-close.js b/test/parallel/test-net-during-close.js
index 2649995f89a02f..e8723fb1a692a8 100644
--- a/test/parallel/test-net-during-close.js
+++ b/test/parallel/test-net-during-close.js
@@ -1,14 +1,14 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var server = net.createServer(function(socket) {
+const server = net.createServer(function(socket) {
socket.end();
});
server.listen(0, common.mustCall(function() {
- var client = net.createConnection(this.address().port);
+ const client = net.createConnection(this.address().port);
server.close();
// server connection event has not yet fired
// client is still attempting to connect
diff --git a/test/parallel/test-net-eaddrinuse.js b/test/parallel/test-net-eaddrinuse.js
index 4741c820797154..3d7ceb8d5e38f7 100644
--- a/test/parallel/test-net-eaddrinuse.js
+++ b/test/parallel/test-net-eaddrinuse.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var server1 = net.createServer(function(socket) {
+const server1 = net.createServer(function(socket) {
});
-var server2 = net.createServer(function(socket) {
+const server2 = net.createServer(function(socket) {
});
server1.listen(0, function() {
server2.on('error', function(error) {
diff --git a/test/parallel/test-net-end-without-connect.js b/test/parallel/test-net-end-without-connect.js
index 69abf486316ff2..99324b071d27d6 100644
--- a/test/parallel/test-net-end-without-connect.js
+++ b/test/parallel/test-net-end-without-connect.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var net = require('net');
+const net = require('net');
-var sock = new net.Socket();
+const sock = new net.Socket();
sock.end(); // Should not throw.
diff --git a/test/parallel/test-net-error-twice.js b/test/parallel/test-net-error-twice.js
index 36c33b4b1cc012..98a2c337559b06 100644
--- a/test/parallel/test-net-error-twice.js
+++ b/test/parallel/test-net-error-twice.js
@@ -6,8 +6,8 @@ const net = require('net');
const buf = Buffer.alloc(10 * 1024 * 1024, 0x62);
const errs = [];
-var clientSocket;
-var serverSocket;
+let clientSocket;
+let serverSocket;
function ready() {
if (clientSocket && serverSocket) {
@@ -16,7 +16,7 @@ function ready() {
}
}
-var srv = net.createServer(function onConnection(conn) {
+const srv = net.createServer(function onConnection(conn) {
conn.on('error', function(err) {
errs.push(err);
if (errs.length > 1 && errs[0] === errs[1])
@@ -28,7 +28,7 @@ var srv = net.createServer(function onConnection(conn) {
serverSocket = conn;
ready();
}).listen(0, function() {
- var client = net.connect({ port: this.address().port });
+ const client = net.connect({ port: this.address().port });
client.on('connect', function() {
clientSocket = client;
diff --git a/test/parallel/test-net-internal.js b/test/parallel/test-net-internal.js
index 0c8d1cf9e17a0e..a79d022a5d7eaa 100644
--- a/test/parallel/test-net-internal.js
+++ b/test/parallel/test-net-internal.js
@@ -6,7 +6,7 @@ require('../common');
const assert = require('assert');
const isLegalPort = require('internal/net').isLegalPort;
-for (var n = 0; n <= 0xFFFF; n++) {
+for (let n = 0; n <= 0xFFFF; n++) {
assert(isLegalPort(n));
assert(isLegalPort('' + n));
assert(`0x${n.toString(16)}`);
diff --git a/test/parallel/test-net-isip.js b/test/parallel/test-net-isip.js
index 6b159b59d8c8c0..65d88523fe930e 100644
--- a/test/parallel/test-net-isip.js
+++ b/test/parallel/test-net-isip.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
assert.equal(net.isIP('127.0.0.1'), 4);
assert.equal(net.isIP('x127.0.0.1'), 0);
diff --git a/test/parallel/test-net-keepalive.js b/test/parallel/test-net-keepalive.js
index e466f0ff580d06..950a005addecdf 100644
--- a/test/parallel/test-net-keepalive.js
+++ b/test/parallel/test-net-keepalive.js
@@ -3,9 +3,9 @@ const common = require('../common');
const assert = require('assert');
const net = require('net');
-var serverConnection;
-var clientConnection;
-var echoServer = net.createServer(function(connection) {
+let serverConnection;
+let clientConnection;
+const echoServer = net.createServer(function(connection) {
serverConnection = connection;
setTimeout(common.mustCall(function() {
// make sure both connections are still open
diff --git a/test/parallel/test-net-large-string.js b/test/parallel/test-net-large-string.js
index b469b0289546a1..83612111e2a0aa 100644
--- a/test/parallel/test-net-large-string.js
+++ b/test/parallel/test-net-large-string.js
@@ -1,14 +1,14 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var kPoolSize = 40 * 1024;
-var data = 'あ'.repeat(kPoolSize);
-var encoding = 'UTF-8';
+const kPoolSize = 40 * 1024;
+const data = 'あ'.repeat(kPoolSize);
+const encoding = 'UTF-8';
-var server = net.createServer(common.mustCall(function(socket) {
- var receivedSize = 0;
+const server = net.createServer(common.mustCall(function(socket) {
+ let receivedSize = 0;
socket.setEncoding(encoding);
socket.on('data', function(data) {
@@ -21,7 +21,7 @@ var server = net.createServer(common.mustCall(function(socket) {
}));
server.listen(0, function() {
- var client = net.createConnection(this.address().port);
+ const client = net.createConnection(this.address().port);
client.on('end', function() {
server.close();
});
diff --git a/test/parallel/test-net-listen-close-server-callback-is-not-function.js b/test/parallel/test-net-listen-close-server-callback-is-not-function.js
index 03c08d4f51bf15..472ea37e7146b9 100644
--- a/test/parallel/test-net-listen-close-server-callback-is-not-function.js
+++ b/test/parallel/test-net-listen-close-server-callback-is-not-function.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var net = require('net');
+const net = require('net');
-var server = net.createServer(common.fail);
+const server = net.createServer(common.fail);
server.on('close', common.mustCall(function() {}));
diff --git a/test/parallel/test-net-listen-close-server.js b/test/parallel/test-net-listen-close-server.js
index 92c7274f328918..0a45adecbe83e7 100644
--- a/test/parallel/test-net-listen-close-server.js
+++ b/test/parallel/test-net-listen-close-server.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var net = require('net');
+const net = require('net');
-var server = net.createServer(function(socket) {
+const server = net.createServer(function(socket) {
});
server.listen(0, common.fail);
server.on('error', common.fail);
diff --git a/test/parallel/test-net-listen-error.js b/test/parallel/test-net-listen-error.js
index 9523fcb2e7f456..7b721d1004f37f 100644
--- a/test/parallel/test-net-listen-error.js
+++ b/test/parallel/test-net-listen-error.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var net = require('net');
+const net = require('net');
-var server = net.createServer(function(socket) {
+const server = net.createServer(function(socket) {
});
server.listen(1, '1.1.1.1', common.fail); // EACCESS or EADDRNOTAVAIL
server.on('error', common.mustCall(function(error) {}));
diff --git a/test/parallel/test-net-listen-exclusive-random-ports.js b/test/parallel/test-net-listen-exclusive-random-ports.js
index f46f9a01d773ce..6b9c750f55ea69 100644
--- a/test/parallel/test-net-listen-exclusive-random-ports.js
+++ b/test/parallel/test-net-listen-exclusive-random-ports.js
@@ -1,17 +1,17 @@
'use strict';
require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
-var net = require('net');
+const assert = require('assert');
+const cluster = require('cluster');
+const net = require('net');
function noop() {}
if (cluster.isMaster) {
- var worker1 = cluster.fork();
+ const worker1 = cluster.fork();
worker1.on('message', function(port1) {
assert.equal(port1, port1 | 0, 'first worker could not listen');
- var worker2 = cluster.fork();
+ const worker2 = cluster.fork();
worker2.on('message', function(port2) {
assert.equal(port2, port2 | 0, 'second worker could not listen');
@@ -21,7 +21,7 @@ if (cluster.isMaster) {
});
});
} else {
- var server = net.createServer(noop);
+ const server = net.createServer(noop);
server.on('error', function(err) {
process.send(err.code);
diff --git a/test/parallel/test-net-listen-port-option.js b/test/parallel/test-net-listen-port-option.js
index 77c9cb42f0a930..c4851bd533dfbe 100644
--- a/test/parallel/test-net-listen-port-option.js
+++ b/test/parallel/test-net-listen-port-option.js
@@ -1,7 +1,7 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
function close() { this.close(); }
net.Server().listen({ port: undefined }, close);
diff --git a/test/parallel/test-net-listen-shared-ports.js b/test/parallel/test-net-listen-shared-ports.js
index 2062dd0ce136bb..ce344be4a6f492 100644
--- a/test/parallel/test-net-listen-shared-ports.js
+++ b/test/parallel/test-net-listen-shared-ports.js
@@ -1,17 +1,17 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var cluster = require('cluster');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const cluster = require('cluster');
+const net = require('net');
function noop() {}
if (cluster.isMaster) {
- var worker1 = cluster.fork();
+ const worker1 = cluster.fork();
worker1.on('message', function(msg) {
assert.equal(msg, 'success');
- var worker2 = cluster.fork();
+ const worker2 = cluster.fork();
worker2.on('message', function(msg) {
assert.equal(msg, 'server2:EADDRINUSE');
@@ -20,8 +20,8 @@ if (cluster.isMaster) {
});
});
} else {
- var server1 = net.createServer(noop);
- var server2 = net.createServer(noop);
+ const server1 = net.createServer(noop);
+ const server2 = net.createServer(noop);
server1.on('error', function(err) {
// no errors expected
diff --git a/test/parallel/test-net-local-address-port.js b/test/parallel/test-net-local-address-port.js
index 56f8eab5855c46..e6f1bbaa6c7ed7 100644
--- a/test/parallel/test-net-local-address-port.js
+++ b/test/parallel/test-net-local-address-port.js
@@ -3,7 +3,7 @@ const common = require('../common');
const assert = require('assert');
const net = require('net');
-var server = net.createServer(common.mustCall(function(socket) {
+const server = net.createServer(common.mustCall(function(socket) {
assert.strictEqual(socket.localAddress, common.localhostIPv4);
assert.strictEqual(socket.localPort, this.address().port);
socket.on('end', function() {
@@ -13,7 +13,8 @@ var server = net.createServer(common.mustCall(function(socket) {
}));
server.listen(0, common.localhostIPv4, function() {
- var client = net.createConnection(this.address().port, common.localhostIPv4);
+ const client = net.createConnection(this.address().port,
+ common.localhostIPv4);
client.on('connect', function() {
client.end();
});
diff --git a/test/parallel/test-net-localport.js b/test/parallel/test-net-localport.js
index 4af9dcfd08aeca..b100e4ae768c29 100644
--- a/test/parallel/test-net-localport.js
+++ b/test/parallel/test-net-localport.js
@@ -1,9 +1,9 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
-var server = net.createServer(function(socket) {
+const server = net.createServer(function(socket) {
console.log(socket.remotePort);
assert.strictEqual(socket.remotePort, common.PORT);
socket.end();
@@ -11,7 +11,7 @@ var server = net.createServer(function(socket) {
server.close();
});
}).listen(0).on('listening', function() {
- var client = net.connect({
+ const client = net.connect({
host: '127.0.0.1',
port: this.address().port,
localPort: common.PORT,
diff --git a/test/parallel/test-net-pause-resume-connecting.js b/test/parallel/test-net-pause-resume-connecting.js
index 6f3e78a94a56df..f441252fed6e70 100644
--- a/test/parallel/test-net-pause-resume-connecting.js
+++ b/test/parallel/test-net-pause-resume-connecting.js
@@ -9,7 +9,7 @@ let conn;
// Server
-var server = net.createServer(function(conn) {
+const server = net.createServer(function(conn) {
connections++;
conn.end('This was the year he fell to pieces.');
diff --git a/test/parallel/test-net-persistent-keepalive.js b/test/parallel/test-net-persistent-keepalive.js
index d1dfb370167714..6338b5932de1fa 100644
--- a/test/parallel/test-net-persistent-keepalive.js
+++ b/test/parallel/test-net-persistent-keepalive.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var serverConnection;
-var clientConnection;
-var echoServer = net.createServer(function(connection) {
+let serverConnection;
+let clientConnection;
+const echoServer = net.createServer(function(connection) {
serverConnection = connection;
setTimeout(function() {
// make sure both connections are still open
@@ -27,7 +27,7 @@ echoServer.on('listening', function() {
clientConnection = new net.Socket();
// send a keepalive packet after 1000 ms
// and make sure it persists
- var s = clientConnection.setKeepAlive(true, 400);
+ const s = clientConnection.setKeepAlive(true, 400);
assert.ok(s instanceof net.Socket);
clientConnection.connect(this.address().port);
clientConnection.setTimeout(0);
diff --git a/test/parallel/test-net-persistent-nodelay.js b/test/parallel/test-net-persistent-nodelay.js
index e23b8718dfee6d..3f94424b0e1197 100644
--- a/test/parallel/test-net-persistent-nodelay.js
+++ b/test/parallel/test-net-persistent-nodelay.js
@@ -1,18 +1,18 @@
'use strict';
require('../common');
-var assert = require('assert');
-var net = require('net');
-var TCPWrap = process.binding('tcp_wrap').TCP;
+const assert = require('assert');
+const net = require('net');
+const TCPWrap = process.binding('tcp_wrap').TCP;
-var echoServer = net.createServer(function(connection) {
+const echoServer = net.createServer(function(connection) {
connection.end();
});
echoServer.listen(0);
-var callCount = 0;
+let callCount = 0;
-var Socket = net.Socket;
-var setNoDelay = TCPWrap.prototype.setNoDelay;
+const Socket = net.Socket;
+const setNoDelay = TCPWrap.prototype.setNoDelay;
TCPWrap.prototype.setNoDelay = function(enable) {
setNoDelay.call(this, enable);
@@ -20,11 +20,11 @@ TCPWrap.prototype.setNoDelay = function(enable) {
};
echoServer.on('listening', function() {
- var sock1 = new Socket();
+ const sock1 = new Socket();
// setNoDelay before the handle is created
// there is probably a better way to test this
- var s = sock1.setNoDelay();
+ const s = sock1.setNoDelay();
assert.ok(s instanceof net.Socket);
sock1.connect(this.address().port);
sock1.on('end', function() {
diff --git a/test/parallel/test-net-persistent-ref-unref.js b/test/parallel/test-net-persistent-ref-unref.js
index 32782e7c591444..1d3cbc6ffaef18 100644
--- a/test/parallel/test-net-persistent-ref-unref.js
+++ b/test/parallel/test-net-persistent-ref-unref.js
@@ -1,17 +1,17 @@
'use strict';
require('../common');
-var assert = require('assert');
-var net = require('net');
-var TCPWrap = process.binding('tcp_wrap').TCP;
+const assert = require('assert');
+const net = require('net');
+const TCPWrap = process.binding('tcp_wrap').TCP;
-var echoServer = net.createServer(function(conn) {
+const echoServer = net.createServer(function(conn) {
conn.end();
});
-var ref = TCPWrap.prototype.ref;
-var unref = TCPWrap.prototype.unref;
+const ref = TCPWrap.prototype.ref;
+const unref = TCPWrap.prototype.unref;
-var refCount = 0;
+let refCount = 0;
TCPWrap.prototype.ref = function() {
ref.call(this);
@@ -28,7 +28,7 @@ TCPWrap.prototype.unref = function() {
echoServer.listen(0);
echoServer.on('listening', function() {
- var sock = new net.Socket();
+ const sock = new net.Socket();
sock.unref();
sock.ref();
sock.connect(this.address().port);
diff --git a/test/parallel/test-net-pingpong.js b/test/parallel/test-net-pingpong.js
index b49b3a78778719..9280991f39e5d9 100644
--- a/test/parallel/test-net-pingpong.js
+++ b/test/parallel/test-net-pingpong.js
@@ -5,9 +5,9 @@ const net = require('net');
function pingPongTest(port, host) {
const N = 1000;
- var count = 0;
- var sentPongs = 0;
- var sent_final_ping = false;
+ let count = 0;
+ let sentPongs = 0;
+ let sent_final_ping = false;
const server = net.createServer(
{ allowHalfOpen: true },
diff --git a/test/parallel/test-net-pipe-connect-errors.js b/test/parallel/test-net-pipe-connect-errors.js
index 3e00befc341682..2c1332efa11429 100644
--- a/test/parallel/test-net-pipe-connect-errors.js
+++ b/test/parallel/test-net-pipe-connect-errors.js
@@ -8,7 +8,7 @@ const assert = require('assert');
// Test if ENOTSOCK is fired when trying to connect to a file which is not
// a socket.
-var emptyTxt;
+let emptyTxt;
if (common.isWindows) {
// on Win, common.PIPE will be a named pipe, so we use an existing empty
@@ -34,7 +34,7 @@ if (common.isWindows) {
fs.writeFileSync(emptyTxt, '');
}
-var notSocketClient = net.createConnection(emptyTxt, function() {
+const notSocketClient = net.createConnection(emptyTxt, function() {
common.fail('connection callback should not run');
});
@@ -45,7 +45,7 @@ notSocketClient.on('error', common.mustCall(function(err) {
// Trying to connect to not-existing socket should result in ENOENT error
-var noEntSocketClient = net.createConnection('no-ent-file', function() {
+const noEntSocketClient = net.createConnection('no-ent-file', function() {
common.fail('connection to non-existent socket, callback should not run');
});
@@ -63,7 +63,7 @@ if (!common.isWindows && process.getuid() !== 0) {
accessServer.listen(common.PIPE, common.mustCall(function() {
fs.chmodSync(common.PIPE, 0);
- var accessClient = net.createConnection(common.PIPE, function() {
+ const accessClient = net.createConnection(common.PIPE, function() {
common.fail('connection should get EACCES, callback should not run');
});
diff --git a/test/parallel/test-net-reconnect.js b/test/parallel/test-net-reconnect.js
index 980de2637b18bf..47171093ca13f9 100644
--- a/test/parallel/test-net-reconnect.js
+++ b/test/parallel/test-net-reconnect.js
@@ -1,15 +1,15 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var net = require('net');
+const net = require('net');
-var N = 50;
-var client_recv_count = 0;
-var client_end_count = 0;
-var disconnect_count = 0;
+const N = 50;
+let client_recv_count = 0;
+let client_end_count = 0;
+let disconnect_count = 0;
-var server = net.createServer(function(socket) {
+const server = net.createServer(function(socket) {
console.error('SERVER: got socket connection');
socket.resume();
@@ -29,7 +29,7 @@ var server = net.createServer(function(socket) {
server.listen(0, function() {
console.log('SERVER listening');
- var client = net.createConnection(this.address().port);
+ const client = net.createConnection(this.address().port);
client.setEncoding('UTF8');
diff --git a/test/parallel/test-net-remote-address-port.js b/test/parallel/test-net-remote-address-port.js
index 62a7ebfe572908..96e2049f9e32fa 100644
--- a/test/parallel/test-net-remote-address-port.js
+++ b/test/parallel/test-net-remote-address-port.js
@@ -4,15 +4,15 @@ const assert = require('assert');
const net = require('net');
-var conns_closed = 0;
+let conns_closed = 0;
-var remoteAddrCandidates = [ common.localhostIPv4 ];
+const remoteAddrCandidates = [ common.localhostIPv4 ];
if (common.hasIPv6) remoteAddrCandidates.push('::ffff:127.0.0.1');
-var remoteFamilyCandidates = ['IPv4'];
+const remoteFamilyCandidates = ['IPv4'];
if (common.hasIPv6) remoteFamilyCandidates.push('IPv6');
-var server = net.createServer(common.mustCall(function(socket) {
+const server = net.createServer(common.mustCall(function(socket) {
assert.notEqual(-1, remoteAddrCandidates.indexOf(socket.remoteAddress));
assert.notEqual(-1, remoteFamilyCandidates.indexOf(socket.remoteFamily));
assert.ok(socket.remotePort);
@@ -28,8 +28,8 @@ var server = net.createServer(common.mustCall(function(socket) {
}, 2));
server.listen(0, 'localhost', function() {
- var client = net.createConnection(this.address().port, 'localhost');
- var client2 = net.createConnection(this.address().port);
+ const client = net.createConnection(this.address().port, 'localhost');
+ const client2 = net.createConnection(this.address().port);
client.on('connect', function() {
assert.notEqual(-1, remoteAddrCandidates.indexOf(client.remoteAddress));
assert.notEqual(-1, remoteFamilyCandidates.indexOf(client.remoteFamily));
diff --git a/test/parallel/test-net-server-bind.js b/test/parallel/test-net-server-bind.js
index c77341418c2c6d..e4dc64216441cf 100644
--- a/test/parallel/test-net-server-bind.js
+++ b/test/parallel/test-net-server-bind.js
@@ -1,13 +1,13 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
// With only a callback, server should get a port assigned by the OS
-var address0;
-var server0 = net.createServer(function(socket) { });
+let address0;
+const server0 = net.createServer(function(socket) { });
server0.listen(function() {
address0 = server0.address();
@@ -18,9 +18,9 @@ server0.listen(function() {
// No callback to listen(), assume we can bind in 100 ms
-var address1;
-var connectionKey1;
-var server1 = net.createServer(function(socket) { });
+let address1;
+let connectionKey1;
+const server1 = net.createServer(function(socket) { });
server1.listen(common.PORT);
@@ -34,8 +34,8 @@ setTimeout(function() {
// Callback to listen()
-var address2;
-var server2 = net.createServer(function(socket) { });
+let address2;
+const server2 = net.createServer(function(socket) { });
server2.listen(common.PORT + 1, function() {
address2 = server2.address();
@@ -46,8 +46,8 @@ server2.listen(common.PORT + 1, function() {
// Backlog argument
-var address3;
-var server3 = net.createServer(function(socket) { });
+let address3;
+const server3 = net.createServer(function(socket) { });
server3.listen(common.PORT + 2, '0.0.0.0', 127, function() {
address3 = server3.address();
@@ -58,8 +58,8 @@ server3.listen(common.PORT + 2, '0.0.0.0', 127, function() {
// Backlog argument without host argument
-var address4;
-var server4 = net.createServer(function(socket) { });
+let address4;
+const server4 = net.createServer(function(socket) { });
server4.listen(common.PORT + 3, 127, function() {
address4 = server4.address();
@@ -72,7 +72,7 @@ process.on('exit', function() {
assert.ok(address0.port > 100);
assert.equal(common.PORT, address1.port);
- var expectedConnectionKey1;
+ let expectedConnectionKey1;
if (address1.family === 'IPv6')
expectedConnectionKey1 = '6::::' + address1.port;
diff --git a/test/parallel/test-net-server-close.js b/test/parallel/test-net-server-close.js
index 006ca529c79ab3..c44dc230c90662 100644
--- a/test/parallel/test-net-server-close.js
+++ b/test/parallel/test-net-server-close.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var events = [];
-var sockets = [];
+const events = [];
+const sockets = [];
process.on('exit', function() {
assert.equal(server.connections, 0);
@@ -15,7 +15,7 @@ process.on('exit', function() {
assert.equal(events.join(' ').match(/client/g).length, 2);
});
-var server = net.createServer(function(c) {
+let server = net.createServer(function(c) {
c.on('close', function() {
events.push('client');
});
diff --git a/test/parallel/test-net-server-connections.js b/test/parallel/test-net-server-connections.js
index ae89d9aac7b3f7..4e41d29a505199 100644
--- a/test/parallel/test-net-server-connections.js
+++ b/test/parallel/test-net-server-connections.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var net = require('net');
+const net = require('net');
// test that server.connections property is no longer enumerable now that it
// has been marked as deprecated
-var server = new net.Server();
+const server = new net.Server();
assert.equal(Object.keys(server).indexOf('connections'), -1);
diff --git a/test/parallel/test-net-server-listen-remove-callback.js b/test/parallel/test-net-server-listen-remove-callback.js
index 9bdfd628072798..a678922683eeb1 100644
--- a/test/parallel/test-net-server-listen-remove-callback.js
+++ b/test/parallel/test-net-server-listen-remove-callback.js
@@ -1,13 +1,13 @@
'use strict';
require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
// Server should only fire listen callback once
-var server = net.createServer();
+const server = net.createServer();
server.on('close', function() {
- var listeners = server.listeners('listening');
+ const listeners = server.listeners('listening');
console.log('Closed, listeners:', listeners.length);
assert.equal(0, listeners.length);
});
diff --git a/test/parallel/test-net-server-max-connections-close-makes-more-available.js b/test/parallel/test-net-server-max-connections-close-makes-more-available.js
index fb9831d05b3e50..06233f6c8633ed 100644
--- a/test/parallel/test-net-server-max-connections-close-makes-more-available.js
+++ b/test/parallel/test-net-server-max-connections-close-makes-more-available.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var net = require('net');
+const net = require('net');
// Sets the server's maxConnections property to 1.
// Open 2 connections (connection 0 and connection 1).
@@ -13,16 +13,16 @@ var net = require('net');
// Connection 2 should be accepted.
// Connection 3 should be rejected.
-var connections = [];
-var received = [];
-var sent = [];
+const connections = [];
+const received = [];
+const sent = [];
-var createConnection = function(index) {
+const createConnection = function(index) {
console.error('creating connection ' + index);
return new Promise(function(resolve, reject) {
- var connection = net.createConnection(server.address().port, function() {
- var msg = '' + index;
+ const connection = net.createConnection(server.address().port, function() {
+ const msg = '' + index;
console.error('sending message: ' + msg);
this.write(msg);
sent.push(msg);
@@ -47,7 +47,7 @@ var createConnection = function(index) {
});
};
-var closeConnection = function(index) {
+const closeConnection = function(index) {
console.error('closing connection ' + index);
return new Promise(function(resolve, reject) {
connections[index].on('end', function() {
@@ -57,7 +57,7 @@ var closeConnection = function(index) {
});
};
-var server = net.createServer(function(socket) {
+let server = net.createServer(function(socket) {
socket.on('data', function(data) {
console.error('received message: ' + data);
received.push('' + data);
diff --git a/test/parallel/test-net-server-max-connections.js b/test/parallel/test-net-server-max-connections.js
index 99d3b345f40974..f560a7dafc4446 100644
--- a/test/parallel/test-net-server-max-connections.js
+++ b/test/parallel/test-net-server-max-connections.js
@@ -9,7 +9,7 @@ const net = require('net');
// and the last 10 connections are rejected.
const N = 20;
-var closes = 0;
+let closes = 0;
const waits = [];
const server = net.createServer(common.mustCall(function(connection) {
@@ -26,7 +26,7 @@ server.maxConnections = N / 2;
function makeConnection(index) {
const c = net.createConnection(server.address().port);
- var gotData = false;
+ let gotData = false;
c.on('connect', function() {
if (index + 1 < N) {
@@ -45,7 +45,7 @@ function makeConnection(index) {
}
if (closes === N / 2) {
- var cb;
+ let cb;
console.error('calling wait callback.');
while (cb = waits.shift()) {
cb();
diff --git a/test/parallel/test-net-server-pause-on-connect.js b/test/parallel/test-net-server-pause-on-connect.js
index 798175737b80b3..ee5ac4e2807b0a 100644
--- a/test/parallel/test-net-server-pause-on-connect.js
+++ b/test/parallel/test-net-server-pause-on-connect.js
@@ -3,8 +3,8 @@ const common = require('../common');
const assert = require('assert');
const net = require('net');
const msg = 'test';
-var stopped = true;
-var server1Sock;
+let stopped = true;
+let server1Sock;
const server1ConnHandler = function(socket) {
diff --git a/test/parallel/test-net-server-unref-persistent.js b/test/parallel/test-net-server-unref-persistent.js
index d68e94cfbda8c8..beb91832ea9448 100644
--- a/test/parallel/test-net-server-unref-persistent.js
+++ b/test/parallel/test-net-server-unref-persistent.js
@@ -1,7 +1,7 @@
'use strict';
const common = require('../common');
-var net = require('net');
-var server = net.createServer();
+const net = require('net');
+const server = net.createServer();
// unref before listening
server.unref();
diff --git a/test/parallel/test-net-server-unref.js b/test/parallel/test-net-server-unref.js
index 91b25887a28d3e..60df9fc700ec64 100644
--- a/test/parallel/test-net-server-unref.js
+++ b/test/parallel/test-net-server-unref.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var net = require('net');
+const net = require('net');
-var s = net.createServer();
+const s = net.createServer();
s.listen(0);
s.unref();
diff --git a/test/parallel/test-net-socket-destroy-twice.js b/test/parallel/test-net-socket-destroy-twice.js
index 917e9849999b05..998ad05a1d6487 100644
--- a/test/parallel/test-net-socket-destroy-twice.js
+++ b/test/parallel/test-net-socket-destroy-twice.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common');
-var net = require('net');
+const common = require('../common');
+const net = require('net');
-var conn = net.createConnection(common.PORT);
+const conn = net.createConnection(common.PORT);
conn.on('error', common.mustCall(function() {
conn.destroy();
diff --git a/test/parallel/test-net-socket-local-address.js b/test/parallel/test-net-socket-local-address.js
index 82f174dc2c1924..e888667eab4c4f 100644
--- a/test/parallel/test-net-socket-local-address.js
+++ b/test/parallel/test-net-socket-local-address.js
@@ -9,9 +9,9 @@ if (common.inFreeBSDJail) {
return;
}
-var conns = 0;
-var clientLocalPorts = [];
-var serverRemotePorts = [];
+let conns = 0;
+const clientLocalPorts = [];
+const serverRemotePorts = [];
const client = new net.Socket();
const server = net.createServer((socket) => {
serverRemotePorts.push(socket.remotePort);
diff --git a/test/parallel/test-net-socket-timeout-unref.js b/test/parallel/test-net-socket-timeout-unref.js
index fb4f6a658e21d2..1789ec7a1cabbd 100644
--- a/test/parallel/test-net-socket-timeout-unref.js
+++ b/test/parallel/test-net-socket-timeout-unref.js
@@ -12,7 +12,7 @@ const server = net.createServer(function(c) {
server.listen(0);
server.unref();
-var connections = 0;
+let connections = 0;
const sockets = [];
const delays = [8, 5, 3, 6, 2, 4];
diff --git a/test/parallel/test-net-stream.js b/test/parallel/test-net-stream.js
index d090038ce753be..9d091bd66f3a1e 100644
--- a/test/parallel/test-net-stream.js
+++ b/test/parallel/test-net-stream.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var s = new net.Stream();
+const s = new net.Stream();
// test that destroy called on a stream with a server only ever decrements the
// server connection count once
@@ -18,11 +18,11 @@ assert.equal(9, s.server.connections);
s.destroy();
assert.equal(9, s.server.connections);
-var SIZE = 2E6;
-var N = 10;
-var buf = Buffer.alloc(SIZE, 'a');
+const SIZE = 2E6;
+const N = 10;
+const buf = Buffer.alloc(SIZE, 'a');
-var server = net.createServer(function(socket) {
+const server = net.createServer(function(socket) {
socket.setNoDelay();
socket.on('error', function(err) {
@@ -31,13 +31,13 @@ var server = net.createServer(function(socket) {
server.close();
});
- for (var i = 0; i < N; ++i) {
+ for (let i = 0; i < N; ++i) {
socket.write(buf, function() { });
}
socket.end();
}).listen(0, function() {
- var conn = net.connect(this.address().port);
+ const conn = net.connect(this.address().port);
conn.on('data', function(buf) {
conn.pause();
setTimeout(function() {
diff --git a/test/parallel/test-net-write-after-close.js b/test/parallel/test-net-write-after-close.js
index e01aef80f3635b..0a1dcd98b2b3c7 100644
--- a/test/parallel/test-net-write-after-close.js
+++ b/test/parallel/test-net-write-after-close.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var net = require('net');
+const net = require('net');
-var server = net.createServer(common.mustCall(function(socket) {
+const server = net.createServer(common.mustCall(function(socket) {
socket.resume();
socket.on('error', common.mustCall(function(error) {
@@ -17,7 +17,7 @@ var server = net.createServer(common.mustCall(function(socket) {
}));
server.listen(0, function() {
- var client = net.connect(this.address().port, function() {
+ const client = net.connect(this.address().port, function() {
client.end();
});
});
diff --git a/test/parallel/test-net-write-connect-write.js b/test/parallel/test-net-write-connect-write.js
index 315db6bc02b309..ee20ede49fb5a5 100644
--- a/test/parallel/test-net-write-connect-write.js
+++ b/test/parallel/test-net-write-connect-write.js
@@ -1,13 +1,13 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var server = net.createServer(function(socket) {
+const server = net.createServer(function(socket) {
socket.pipe(socket);
}).listen(0, common.mustCall(function() {
- var conn = net.connect(this.address().port);
- var received = '';
+ const conn = net.connect(this.address().port);
+ let received = '';
conn.setEncoding('utf8');
conn.write('before');
diff --git a/test/parallel/test-net-write-slow.js b/test/parallel/test-net-write-slow.js
index 6054e2b7882ac2..c1b2c60e2e202a 100644
--- a/test/parallel/test-net-write-slow.js
+++ b/test/parallel/test-net-write-slow.js
@@ -1,22 +1,22 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
-var SIZE = 2E5;
-var N = 10;
-var flushed = 0;
-var received = 0;
-var buf = Buffer.alloc(SIZE, 'a');
+const SIZE = 2E5;
+const N = 10;
+let flushed = 0;
+let received = 0;
+const buf = Buffer.alloc(SIZE, 'a');
-var server = net.createServer(function(socket) {
+const server = net.createServer(function(socket) {
socket.setNoDelay();
socket.setTimeout(9999);
socket.on('timeout', function() {
common.fail(`flushed: ${flushed}, received: ${received}/${SIZE * N}`);
});
- for (var i = 0; i < N; ++i) {
+ for (let i = 0; i < N; ++i) {
socket.write(buf, function() {
++flushed;
if (flushed === N) {
@@ -27,7 +27,7 @@ var server = net.createServer(function(socket) {
socket.end();
}).listen(0, common.mustCall(function() {
- var conn = net.connect(this.address().port);
+ const conn = net.connect(this.address().port);
conn.on('data', function(buf) {
received += buf.length;
conn.pause();
diff --git a/test/parallel/test-next-tick-domain.js b/test/parallel/test-next-tick-domain.js
index 8f9d9bb4aa50f7..6edb7e3050c067 100644
--- a/test/parallel/test-next-tick-domain.js
+++ b/test/parallel/test-next-tick-domain.js
@@ -1,8 +1,8 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var origNextTick = process.nextTick;
+const origNextTick = process.nextTick;
require('domain');
diff --git a/test/parallel/test-next-tick-errors.js b/test/parallel/test-next-tick-errors.js
index 180b769eaa105b..4f47c3f954d92e 100644
--- a/test/parallel/test-next-tick-errors.js
+++ b/test/parallel/test-next-tick-errors.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
const order = [];
let exceptionHandled = false;
diff --git a/test/parallel/test-next-tick-intentional-starvation.js b/test/parallel/test-next-tick-intentional-starvation.js
index 414524e5405ecc..ee829c94ab6929 100644
--- a/test/parallel/test-next-tick-intentional-starvation.js
+++ b/test/parallel/test-next-tick-intentional-starvation.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// this is the inverse of test-next-tick-starvation.
// it verifies that process.nextTick will *always* come before other
@@ -9,14 +9,14 @@ var assert = require('assert');
// WARNING: unsafe!
process.maxTickDepth = Infinity;
-var ran = false;
-var starved = false;
-var start = +new Date();
-var timerRan = false;
+let ran = false;
+let starved = false;
+const start = +new Date();
+let timerRan = false;
function spin() {
ran = true;
- var now = +new Date();
+ const now = +new Date();
if (now - start > 100) {
console.log('The timer is starving, just as we planned.');
starved = true;
diff --git a/test/parallel/test-next-tick-ordering.js b/test/parallel/test-next-tick-ordering.js
index 63f8d37828e53c..2f13147d8ed733 100644
--- a/test/parallel/test-next-tick-ordering.js
+++ b/test/parallel/test-next-tick-ordering.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
-var i;
+const assert = require('assert');
+let i;
-var N = 30;
-var done = [];
+const N = 30;
+const done = [];
function get_printer(timeout) {
return function() {
diff --git a/test/parallel/test-next-tick-ordering2.js b/test/parallel/test-next-tick-ordering2.js
index 11ac84b5319dda..7cfec867f3ed01 100644
--- a/test/parallel/test-next-tick-ordering2.js
+++ b/test/parallel/test-next-tick-ordering2.js
@@ -1,8 +1,8 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var order = [];
+const order = [];
process.nextTick(function() {
setTimeout(function() {
order.push('setTimeout');
diff --git a/test/parallel/test-next-tick.js b/test/parallel/test-next-tick.js
index 2a98b46da10f17..3001ad0e561a77 100644
--- a/test/parallel/test-next-tick.js
+++ b/test/parallel/test-next-tick.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
process.nextTick(common.mustCall(function() {
process.nextTick(common.mustCall(function() {
@@ -14,7 +14,7 @@ setTimeout(common.mustCall(function() {
process.nextTick(common.mustCall(function() {}));
-var obj = {};
+const obj = {};
process.nextTick(function(a, b) {
assert.equal(a, 42);
diff --git a/test/parallel/test-path-makelong.js b/test/parallel/test-path-makelong.js
index 50a77e9d87b8dc..293d6284f173bc 100644
--- a/test/parallel/test-path-makelong.js
+++ b/test/parallel/test-path-makelong.js
@@ -1,11 +1,11 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var path = require('path');
+const assert = require('assert');
+const path = require('path');
if (common.isWindows) {
- var file = path.join(common.fixturesDir, 'a.js');
- var resolvedFile = path.resolve(file);
+ const file = path.join(common.fixturesDir, 'a.js');
+ const resolvedFile = path.resolve(file);
assert.equal('\\\\?\\' + resolvedFile, path._makeLong(file));
assert.equal('\\\\?\\' + resolvedFile, path._makeLong('\\\\?\\' + file));
diff --git a/test/parallel/test-path-parse-format.js b/test/parallel/test-path-parse-format.js
index aaa92111074099..b316dc5e754a8b 100644
--- a/test/parallel/test-path-parse-format.js
+++ b/test/parallel/test-path-parse-format.js
@@ -170,7 +170,7 @@ function checkErrors(path) {
function checkParseFormat(path, paths) {
paths.forEach(function(element) {
- var output = path.parse(element);
+ const output = path.parse(element);
assert.strictEqual(typeof output.root, 'string');
assert.strictEqual(typeof output.dir, 'string');
assert.strictEqual(typeof output.base, 'string');
diff --git a/test/parallel/test-path.js b/test/parallel/test-path.js
index 49d77bd440aa0d..6f2ea3fd48ad55 100644
--- a/test/parallel/test-path.js
+++ b/test/parallel/test-path.js
@@ -453,9 +453,9 @@ if (common.isWindows) {
// See https://github.com/nodejs/node/issues/7215
const currentDriveLetter = path.parse(process.cwd()).root.substring(0, 2);
const resolveFixture = path.join(common.fixturesDir, 'path-resolve.js');
- var spawnResult = child.spawnSync(
+ const spawnResult = child.spawnSync(
process.argv[0], [resolveFixture, currentDriveLetter]);
- var resolvedPath = spawnResult.stdout.toString().trim();
+ const resolvedPath = spawnResult.stdout.toString().trim();
assert.equal(resolvedPath.toLowerCase(), process.cwd().toLowerCase());
}
diff --git a/test/parallel/test-pipe-address.js b/test/parallel/test-pipe-address.js
index 85e3daa3522e78..49f6802d3f7c7a 100644
--- a/test/parallel/test-pipe-address.js
+++ b/test/parallel/test-pipe-address.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
-var server = net.createServer(common.fail);
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
+const server = net.createServer(common.fail);
common.refreshTmpDir();
diff --git a/test/parallel/test-pipe-return-val.js b/test/parallel/test-pipe-return-val.js
index a14f925916bee0..5e6e83dbc7a952 100644
--- a/test/parallel/test-pipe-return-val.js
+++ b/test/parallel/test-pipe-return-val.js
@@ -2,11 +2,11 @@
// This test ensures SourceStream.pipe(DestStream) returns DestStream
require('../common');
-var Stream = require('stream').Stream;
-var assert = require('assert');
+const Stream = require('stream').Stream;
+const assert = require('assert');
-var sourceStream = new Stream();
-var destStream = new Stream();
-var result = sourceStream.pipe(destStream);
+const sourceStream = new Stream();
+const destStream = new Stream();
+const result = sourceStream.pipe(destStream);
assert.strictEqual(result, destStream);
diff --git a/test/parallel/test-pipe-stream.js b/test/parallel/test-pipe-stream.js
index 6298495087ac06..2776ba868e6963 100644
--- a/test/parallel/test-pipe-stream.js
+++ b/test/parallel/test-pipe-stream.js
@@ -1,13 +1,13 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
common.refreshTmpDir();
function test(clazz, cb) {
- var have_ping = false;
- var have_pong = false;
+ let have_ping = false;
+ let have_pong = false;
function check() {
assert.ok(have_ping);
@@ -15,7 +15,7 @@ function test(clazz, cb) {
}
function ping() {
- var conn = new clazz();
+ const conn = new clazz();
conn.on('error', function(err) {
throw err;
@@ -48,11 +48,11 @@ function test(clazz, cb) {
});
}
- var timeout = setTimeout(function() {
+ const timeout = setTimeout(function() {
server.close();
}, 2000);
- var server = net.Server();
+ let server = net.Server();
server.listen(common.PIPE, ping);
server.on('connection', pong);
server.on('close', function() {
diff --git a/test/parallel/test-pipe-unref.js b/test/parallel/test-pipe-unref.js
index 35c25524b4cfc8..34b5ef651bf6aa 100644
--- a/test/parallel/test-pipe-unref.js
+++ b/test/parallel/test-pipe-unref.js
@@ -1,10 +1,10 @@
'use strict';
-var common = require('../common');
-var net = require('net');
+const common = require('../common');
+const net = require('net');
common.refreshTmpDir();
-var s = net.Server();
+const s = net.Server();
s.listen(common.PIPE);
s.unref();
diff --git a/test/parallel/test-preload.js b/test/parallel/test-preload.js
index 8cae173f87ae37..88b441d887df54 100644
--- a/test/parallel/test-preload.js
+++ b/test/parallel/test-preload.js
@@ -14,7 +14,7 @@ if (common.isSunOS) {
const nodeBinary = process.argv[0];
const preloadOption = function(preloads) {
- var option = '';
+ let option = '';
preloads.forEach(function(preload, index) {
option += '-r ' + preload + ' ';
});
@@ -75,7 +75,7 @@ const stdinProc = childProcess.spawn(
{stdio: 'pipe'}
);
stdinProc.stdin.end("console.log('hello');");
-var stdinStdout = '';
+let stdinStdout = '';
stdinProc.stdout.on('data', function(d) {
stdinStdout += d;
});
@@ -91,7 +91,7 @@ const replProc = childProcess.spawn(
{stdio: 'pipe'}
);
replProc.stdin.end('.exit\n');
-var replStdout = '';
+let replStdout = '';
replProc.stdout.on('data', function(d) {
replStdout += d;
});
diff --git a/test/parallel/test-process-argv-0.js b/test/parallel/test-process-argv-0.js
index c3aacb60fa5403..d6b4bfe232323e 100644
--- a/test/parallel/test-process-argv-0.js
+++ b/test/parallel/test-process-argv-0.js
@@ -1,15 +1,15 @@
'use strict';
require('../common');
-var path = require('path');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
+const path = require('path');
+const assert = require('assert');
+const spawn = require('child_process').spawn;
if (process.argv[2] !== 'child') {
- var child = spawn(process.execPath, [__filename, 'child'], {
+ const child = spawn(process.execPath, [__filename, 'child'], {
cwd: path.dirname(process.execPath)
});
- var childArgv0 = '';
+ let childArgv0 = '';
child.stdout.on('data', function(chunk) {
childArgv0 += chunk;
});
diff --git a/test/parallel/test-process-before-exit.js b/test/parallel/test-process-before-exit.js
index 5d8855869a8e4a..ec7a7f76e57ef9 100644
--- a/test/parallel/test-process-before-exit.js
+++ b/test/parallel/test-process-before-exit.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var N = 5;
-var n = 0;
+const N = 5;
+let n = 0;
function f() {
if (++n < N) setTimeout(f, 5);
diff --git a/test/parallel/test-process-binding.js b/test/parallel/test-process-binding.js
index 722e9333aff60a..475891aa5d30d8 100644
--- a/test/parallel/test-process-binding.js
+++ b/test/parallel/test-process-binding.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
assert.throws(
function() {
diff --git a/test/parallel/test-process-config.js b/test/parallel/test-process-config.js
index ab38a48e5aacdd..a1767464fd5978 100644
--- a/test/parallel/test-process-config.js
+++ b/test/parallel/test-process-config.js
@@ -1,8 +1,8 @@
'use strict';
require('../common');
-var assert = require('assert');
-var fs = require('fs');
-var path = require('path');
+const assert = require('assert');
+const fs = require('fs');
+const path = require('path');
// check for existence
assert(process.hasOwnProperty('config'));
@@ -10,8 +10,8 @@ assert(process.hasOwnProperty('config'));
// ensure that `process.config` is an Object
assert.strictEqual(Object(process.config), process.config);
-var configPath = path.resolve(__dirname, '..', '..', 'config.gypi');
-var config = fs.readFileSync(configPath, 'utf8');
+const configPath = path.resolve(__dirname, '..', '..', 'config.gypi');
+let config = fs.readFileSync(configPath, 'utf8');
// clean up comment at the first line
config = config.split('\n').slice(1).join('\n').replace(/'/g, '"');
diff --git a/test/parallel/test-process-exec-argv.js b/test/parallel/test-process-exec-argv.js
index e32971ae81a893..8125850b424d84 100644
--- a/test/parallel/test-process-exec-argv.js
+++ b/test/parallel/test-process-exec-argv.js
@@ -1,15 +1,15 @@
'use strict';
require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
+const assert = require('assert');
+const spawn = require('child_process').spawn;
if (process.argv[2] === 'child') {
process.stdout.write(JSON.stringify(process.execArgv));
} else {
- var execArgv = ['--stack-size=256'];
- var args = [__filename, 'child', 'arg0'];
- var child = spawn(process.execPath, execArgv.concat(args));
- var out = '';
+ const execArgv = ['--stack-size=256'];
+ const args = [__filename, 'child', 'arg0'];
+ const child = spawn(process.execPath, execArgv.concat(args));
+ let out = '';
child.stdout.on('data', function(chunk) {
out += chunk;
diff --git a/test/parallel/test-process-exit-code.js b/test/parallel/test-process-exit-code.js
index 8d657528d05561..337502ffcb30e8 100644
--- a/test/parallel/test-process-exit-code.js
+++ b/test/parallel/test-process-exit-code.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
switch (process.argv[2]) {
case 'child1':
@@ -70,10 +70,10 @@ function parent() {
}
function test(arg, exit) {
- var spawn = require('child_process').spawn;
- var node = process.execPath;
- var f = __filename;
- var option = { stdio: [ 0, 1, 'ignore' ] };
+ const spawn = require('child_process').spawn;
+ const node = process.execPath;
+ const f = __filename;
+ const option = { stdio: [ 0, 1, 'ignore' ] };
spawn(node, [f, arg], option).on('exit', function(code) {
assert.equal(code, exit, 'wrong exit for ' +
arg + '\nexpected:' + exit +
diff --git a/test/parallel/test-process-exit-from-before-exit.js b/test/parallel/test-process-exit-from-before-exit.js
index b37df0a5bd340d..82458217c6f062 100644
--- a/test/parallel/test-process-exit-from-before-exit.js
+++ b/test/parallel/test-process-exit-from-before-exit.js
@@ -1,5 +1,5 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
process.on('beforeExit', common.mustCall(function() {
setTimeout(common.fail, 5);
diff --git a/test/parallel/test-process-exit-recursive.js b/test/parallel/test-process-exit-recursive.js
index 53426a6b1cdaf0..1634aad15497f5 100644
--- a/test/parallel/test-process-exit-recursive.js
+++ b/test/parallel/test-process-exit-recursive.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// recursively calling .exit() should not overflow the call stack
-var nexits = 0;
+let nexits = 0;
process.on('exit', function(code) {
assert.equal(nexits++, 0);
diff --git a/test/parallel/test-process-exit.js b/test/parallel/test-process-exit.js
index 0ea36f158eaf9b..f7df7737ed1531 100644
--- a/test/parallel/test-process-exit.js
+++ b/test/parallel/test-process-exit.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// calling .exit() from within "exit" should not overflow the call stack
-var nexits = 0;
+let nexits = 0;
process.on('exit', function(code) {
assert.equal(nexits++, 0);
diff --git a/test/parallel/test-process-getactivehandles.js b/test/parallel/test-process-getactivehandles.js
index a9222c984b30ca..8ceb2bcd2a32f7 100644
--- a/test/parallel/test-process-getactivehandles.js
+++ b/test/parallel/test-process-getactivehandles.js
@@ -6,7 +6,7 @@ const net = require('net');
const NUM = 8;
const connections = [];
const clients = [];
-var clients_counter = 0;
+let clients_counter = 0;
const server = net.createServer(function listener(c) {
connections.push(c);
diff --git a/test/parallel/test-process-getgroups.js b/test/parallel/test-process-getgroups.js
index 002ec7c1ab4c7c..87b5a29863f2ed 100644
--- a/test/parallel/test-process-getgroups.js
+++ b/test/parallel/test-process-getgroups.js
@@ -1,7 +1,7 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var exec = require('child_process').exec;
+const assert = require('assert');
+const exec = require('child_process').exec;
if (common.isOSX) {
common.skip('Output of `id -G` is unreliable on Darwin.');
@@ -9,12 +9,12 @@ if (common.isOSX) {
}
if (typeof process.getgroups === 'function') {
- var groups = process.getgroups();
+ const groups = process.getgroups();
assert(Array.isArray(groups));
assert(groups.length > 0);
exec('id -G', function(err, stdout) {
if (err) throw err;
- var real_groups = stdout.match(/\d+/g).map(Number);
+ const real_groups = stdout.match(/\d+/g).map(Number);
assert.equal(groups.length, real_groups.length);
check(groups, real_groups);
check(real_groups, groups);
@@ -22,5 +22,5 @@ if (typeof process.getgroups === 'function') {
}
function check(a, b) {
- for (var i = 0; i < a.length; ++i) assert.notStrictEqual(b.indexOf(a[i]), -1);
+ for (let i = 0; i < a.length; ++i) assert.notStrictEqual(b.indexOf(a[i]), -1);
}
diff --git a/test/parallel/test-process-hrtime.js b/test/parallel/test-process-hrtime.js
index 9280b671f316d6..faa598d0a57362 100644
--- a/test/parallel/test-process-hrtime.js
+++ b/test/parallel/test-process-hrtime.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// the default behavior, return an Array "tuple" of numbers
const tuple = process.hrtime();
diff --git a/test/parallel/test-process-kill-null.js b/test/parallel/test-process-kill-null.js
index 2516773f08786a..6c0ee8fa049a50 100644
--- a/test/parallel/test-process-kill-null.js
+++ b/test/parallel/test-process-kill-null.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
+const assert = require('assert');
+const spawn = require('child_process').spawn;
-var cat = spawn('cat');
-var called;
+const cat = spawn('cat');
+let called;
assert.ok(process.kill(cat.pid, 0));
diff --git a/test/parallel/test-process-kill-pid.js b/test/parallel/test-process-kill-pid.js
index ee0554c32083f6..2c6ef37fc120df 100644
--- a/test/parallel/test-process-kill-pid.js
+++ b/test/parallel/test-process-kill-pid.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// test variants of pid
//
@@ -34,9 +34,9 @@ assert.throws(function() { process.kill(1, 'test'); }, Error);
// that we don't kill our process group, or try to actually send ANY signals on
// windows, which doesn't support them.
function kill(tryPid, trySig, expectPid, expectSig) {
- var getPid;
- var getSig;
- var origKill = process._kill;
+ let getPid;
+ let getSig;
+ const origKill = process._kill;
process._kill = function(pid, sig) {
getPid = pid;
getSig = sig;
diff --git a/test/parallel/test-process-next-tick.js b/test/parallel/test-process-next-tick.js
index 343511445280d4..e67ebae0a29559 100644
--- a/test/parallel/test-process-next-tick.js
+++ b/test/parallel/test-process-next-tick.js
@@ -1,12 +1,12 @@
'use strict';
const common = require('../common');
-var N = 2;
+const N = 2;
function cb() {
throw new Error();
}
-for (var i = 0; i < N; ++i) {
+for (let i = 0; i < N; ++i) {
process.nextTick(common.mustCall(cb));
}
diff --git a/test/parallel/test-process-raw-debug.js b/test/parallel/test-process-raw-debug.js
index ab461902911a93..74c99b1f8f8058 100644
--- a/test/parallel/test-process-raw-debug.js
+++ b/test/parallel/test-process-raw-debug.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var os = require('os');
+const assert = require('assert');
+const os = require('os');
switch (process.argv[2]) {
case 'child':
@@ -13,10 +13,10 @@ switch (process.argv[2]) {
}
function parent() {
- var spawn = require('child_process').spawn;
- var child = spawn(process.execPath, [__filename, 'child']);
+ const spawn = require('child_process').spawn;
+ const child = spawn(process.execPath, [__filename, 'child']);
- var output = '';
+ let output = '';
child.stderr.on('data', function(c) {
output += c;
@@ -42,7 +42,7 @@ function child() {
throw new Error('No ticking!');
};
- var stderr = process.stderr;
+ const stderr = process.stderr;
stderr.write = function() {
throw new Error('No writing to stderr!');
};
diff --git a/test/parallel/test-process-remove-all-signal-listeners.js b/test/parallel/test-process-remove-all-signal-listeners.js
index 131d57cdfccaa7..76a96f7683e452 100644
--- a/test/parallel/test-process-remove-all-signal-listeners.js
+++ b/test/parallel/test-process-remove-all-signal-listeners.js
@@ -14,7 +14,7 @@ if (process.argv[2] !== '--do-test') {
// We are the master, fork a child so we can verify it exits with correct
// status.
process.env.DOTEST = 'y';
- var child = spawn(process.execPath, [__filename, '--do-test']);
+ const child = spawn(process.execPath, [__filename, '--do-test']);
child.once('exit', common.mustCall(function(code, signal) {
assert.equal(signal, 'SIGINT');
diff --git a/test/parallel/test-process-versions.js b/test/parallel/test-process-versions.js
index 12136958fc8c37..27311f7eda84e3 100644
--- a/test/parallel/test-process-versions.js
+++ b/test/parallel/test-process-versions.js
@@ -2,8 +2,8 @@
const common = require('../common');
const assert = require('assert');
-var expected_keys = ['ares', 'http_parser', 'modules', 'node',
- 'uv', 'v8', 'zlib'];
+const expected_keys = ['ares', 'http_parser', 'modules', 'node',
+ 'uv', 'v8', 'zlib'];
if (common.hasCrypto) {
expected_keys.push('openssl');
diff --git a/test/parallel/test-process-wrap.js b/test/parallel/test-process-wrap.js
index b5d4dc35e4fe00..326854e98335df 100644
--- a/test/parallel/test-process-wrap.js
+++ b/test/parallel/test-process-wrap.js
@@ -1,14 +1,14 @@
'use strict';
require('../common');
-var assert = require('assert');
-var Process = process.binding('process_wrap').Process;
-var Pipe = process.binding('pipe_wrap').Pipe;
-var pipe = new Pipe();
-var p = new Process();
+const assert = require('assert');
+const Process = process.binding('process_wrap').Process;
+const Pipe = process.binding('pipe_wrap').Pipe;
+const pipe = new Pipe();
+const p = new Process();
-var processExited = false;
-var gotPipeEOF = false;
-var gotPipeData = false;
+let processExited = false;
+let gotPipeEOF = false;
+let gotPipeData = false;
p.onexit = function(exitCode, signal) {
console.log('exit');
@@ -45,7 +45,7 @@ p.spawn({
// 'this' safety
// https://github.com/joyent/node/issues/6690
assert.throws(function() {
- var notp = { spawn: p.spawn };
+ const notp = { spawn: p.spawn };
notp.spawn({
file: process.execPath,
args: [process.execPath, '-v'],
diff --git a/test/parallel/test-promises-unhandled-rejections.js b/test/parallel/test-promises-unhandled-rejections.js
index 3c7a40380505de..e2453c915a4a24 100644
--- a/test/parallel/test-promises-unhandled-rejections.js
+++ b/test/parallel/test-promises-unhandled-rejections.js
@@ -1,17 +1,17 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var domain = require('domain');
+const common = require('../common');
+const assert = require('assert');
+const domain = require('domain');
-var asyncTest = (function() {
- var asyncTestsEnabled = false;
- var asyncTestLastCheck;
- var asyncTestQueue = [];
- var asyncTestHandle;
- var currentTest = null;
+const asyncTest = (function() {
+ let asyncTestsEnabled = false;
+ let asyncTestLastCheck;
+ const asyncTestQueue = [];
+ let asyncTestHandle;
+ let currentTest = null;
function fail(error) {
- var stack = currentTest
+ const stack = currentTest
? error.stack + '\nFrom previous event:\n' + currentTest.stack
: error.stack;
@@ -23,7 +23,7 @@ var asyncTest = (function() {
}
function nextAsyncTest() {
- var called = false;
+ let called = false;
function done(err) {
if (called) return fail(new Error('done called twice'));
called = true;
@@ -33,7 +33,7 @@ var asyncTest = (function() {
}
if (asyncTestQueue.length) {
- var test = asyncTestQueue.shift();
+ const test = asyncTestQueue.shift();
currentTest = test;
test.action(done);
} else {
@@ -42,7 +42,7 @@ var asyncTest = (function() {
}
return function asyncTest(description, fn) {
- var stack = new Error().stack.split('\n').slice(1).join('\n');
+ const stack = new Error().stack.split('\n').slice(1).join('\n');
asyncTestQueue.push({
action: fn,
stack: stack,
@@ -53,7 +53,7 @@ var asyncTest = (function() {
asyncTestLastCheck = Date.now();
process.on('uncaughtException', fail);
asyncTestHandle = setInterval(function() {
- var now = Date.now();
+ const now = Date.now();
if (now - asyncTestLastCheck > 10000) {
return fail(new Error('Async test timeout exceeded'));
}
@@ -65,7 +65,7 @@ var asyncTest = (function() {
})();
function setupException(fn) {
- var listeners = process.listeners('uncaughtException');
+ const listeners = process.listeners('uncaughtException');
process.removeAllListeners('uncaughtException');
process.on('uncaughtException', fn);
return function clean() {
@@ -108,7 +108,7 @@ function onUnhandledFail(done) {
asyncTest('synchronously rejected promise should trigger' +
' unhandledRejection', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
});
@@ -117,7 +117,7 @@ asyncTest('synchronously rejected promise should trigger' +
asyncTest('synchronously rejected promise should trigger' +
' unhandledRejection', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
});
@@ -128,7 +128,7 @@ asyncTest('synchronously rejected promise should trigger' +
asyncTest('Promise rejected after setImmediate should trigger' +
' unhandledRejection', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
});
@@ -141,7 +141,7 @@ asyncTest('Promise rejected after setImmediate should trigger' +
asyncTest('Promise rejected after setTimeout(,1) should trigger' +
' unhandled rejection', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
});
@@ -154,12 +154,12 @@ asyncTest('Promise rejected after setTimeout(,1) should trigger' +
asyncTest('Catching a promise rejection after setImmediate is not' +
' soon enough to stop unhandledRejection', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
});
- var _reject;
- var promise = new Promise(function(_, reject) {
+ let _reject;
+ const promise = new Promise(function(_, reject) {
_reject = reject;
});
_reject(e);
@@ -170,13 +170,13 @@ asyncTest('Catching a promise rejection after setImmediate is not' +
asyncTest('When re-throwing new errors in a promise catch, only the' +
' re-thrown error should hit unhandledRejection', function(done) {
- var e = new Error();
- var e2 = new Error();
+ const e = new Error();
+ const e2 = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e2, reason);
assert.strictEqual(promise2, promise);
});
- var promise2 = Promise.reject(e).then(common.fail, function(reason) {
+ let promise2 = Promise.reject(e).then(common.fail, function(reason) {
assert.strictEqual(e, reason);
throw e2;
});
@@ -184,7 +184,7 @@ asyncTest('When re-throwing new errors in a promise catch, only the' +
asyncTest('Test params of unhandledRejection for a synchronously-rejected' +
'promise', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(promise, promise);
@@ -195,13 +195,13 @@ asyncTest('Test params of unhandledRejection for a synchronously-rejected' +
asyncTest('When re-throwing new errors in a promise catch, only the ' +
're-thrown error should hit unhandledRejection: original promise' +
' rejected async with setTimeout(,1)', function(done) {
- var e = new Error();
- var e2 = new Error();
+ const e = new Error();
+ const e2 = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e2, reason);
assert.strictEqual(promise2, promise);
});
- var promise2 = new Promise(function(_, reject) {
+ let promise2 = new Promise(function(_, reject) {
setTimeout(function() {
reject(e);
}, 1);
@@ -214,13 +214,13 @@ asyncTest('When re-throwing new errors in a promise catch, only the ' +
asyncTest('When re-throwing new errors in a promise catch, only the re-thrown' +
' error should hit unhandledRejection: promise catch attached a' +
' process.nextTick after rejection', function(done) {
- var e = new Error();
- var e2 = new Error();
+ const e = new Error();
+ const e2 = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e2, reason);
assert.strictEqual(promise2, promise);
});
- var promise = new Promise(function(_, reject) {
+ const promise = new Promise(function(_, reject) {
setTimeout(function() {
reject(e);
process.nextTick(function() {
@@ -231,14 +231,14 @@ asyncTest('When re-throwing new errors in a promise catch, only the re-thrown' +
});
}, 1);
});
- var promise2;
+ let 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();
+ const e = new Error();
onUnhandledFail(done);
Promise.reject(e).then(common.fail, function() {});
}
@@ -248,7 +248,7 @@ asyncTest(
'unhandledRejection should not be triggered if a promise catch is' +
' attached synchronously upon the promise\'s creation',
function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledFail(done);
new Promise(function(_, reject) {
reject(e);
@@ -258,9 +258,9 @@ asyncTest(
asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' +
' prevent unhandledRejection', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledFail(done);
- var promise = Promise.reject(e);
+ const promise = Promise.reject(e);
process.nextTick(function() {
promise.then(common.fail, function() {});
});
@@ -268,9 +268,9 @@ asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' +
asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' +
' prevent unhandledRejection', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledFail(done);
- var promise = new Promise(function(_, reject) {
+ const promise = new Promise(function(_, reject) {
reject(e);
});
process.nextTick(function() {
@@ -297,7 +297,7 @@ asyncTest('While inside setImmediate, catching a rejected promise derived ' +
asyncTest('catching a promise which is asynchronously rejected (via' +
'resolution to an asynchronously-rejected promise) prevents' +
' unhandledRejection', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledFail(done);
Promise.resolve().then(function() {
return new Promise(function(_, reject) {
@@ -312,7 +312,7 @@ asyncTest('catching a promise which is asynchronously rejected (via' +
asyncTest('Catching a rejected promise derived from throwing in a' +
' fulfillment handler prevents unhandledRejection', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledFail(done);
Promise.resolve().then(function() {
throw e;
@@ -324,7 +324,7 @@ asyncTest('Catching a rejected promise derived from throwing in a' +
asyncTest('Catching a rejected promise derived from returning a' +
' synchronously-rejected promise in a fulfillment handler' +
' prevents unhandledRejection', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledFail(done);
Promise.resolve().then(function() {
return Promise.reject(e);
@@ -336,8 +336,8 @@ asyncTest('Catching a rejected promise derived from returning a' +
asyncTest('A rejected promise derived from returning an' +
' asynchronously-rejected promise in a fulfillment handler' +
' does trigger unhandledRejection', function(done) {
- var e = new Error();
- var _promise;
+ const e = new Error();
+ let _promise;
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(_promise, promise);
@@ -353,8 +353,8 @@ asyncTest('A rejected promise derived from returning an' +
asyncTest('A rejected promise derived from throwing in a fulfillment handler' +
' does trigger unhandledRejection', function(done) {
- var e = new Error();
- var _promise;
+ const e = new Error();
+ let _promise;
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(_promise, promise);
@@ -368,8 +368,8 @@ 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;
+ const e = new Error();
+ let _promise;
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(_promise, promise);
@@ -383,7 +383,7 @@ asyncTest(
// Combinations with Promise.all
asyncTest('Catching the Promise.all() of a collection that includes a' +
'rejected promise prevents unhandledRejection', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledFail(done);
Promise.all([Promise.reject(e)]).then(common.fail, function() {});
});
@@ -392,9 +392,9 @@ asyncTest(
'Catching the Promise.all() of a collection that includes a ' +
'nextTick-async rejected promise prevents unhandledRejection',
function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledFail(done);
- var p = new Promise(function(_, reject) {
+ let p = new Promise(function(_, reject) {
process.nextTick(function() {
reject(e);
});
@@ -409,19 +409,19 @@ asyncTest(
asyncTest('Failing to catch the Promise.all() of a collection that includes' +
' a rejected promise triggers unhandledRejection for the returned' +
' promise, not the passed promise', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(p, promise);
});
- var p = Promise.all([Promise.reject(e)]);
+ let p = Promise.all([Promise.reject(e)]);
});
asyncTest('Waiting setTimeout(, 10) to catch a promise causes an' +
' unhandledRejection + rejectionHandled pair', function(done) {
clean();
- var unhandledPromises = [];
- var e = new Error();
+ const unhandledPromises = [];
+ const e = new Error();
process.on('unhandledRejection', function(reason, promise) {
assert.strictEqual(e, reason);
unhandledPromises.push(promise);
@@ -433,7 +433,7 @@ asyncTest('Waiting setTimeout(, 10) to catch a promise causes an' +
done();
});
- var thePromise = new Promise(function() {
+ let thePromise = new Promise(function() {
throw e;
});
setTimeout(function() {
@@ -446,11 +446,11 @@ asyncTest('Waiting setTimeout(, 10) to catch a promise causes an' +
asyncTest('Waiting for some combination of process.nextTick + promise' +
' microtasks to attach a catch handler is still soon enough to' +
' prevent unhandledRejection', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledFail(done);
- var a = Promise.reject(e);
+ const a = Promise.reject(e);
process.nextTick(function() {
Promise.resolve().then(function() {
process.nextTick(function() {
@@ -465,11 +465,11 @@ asyncTest('Waiting for some combination of process.nextTick + promise' +
asyncTest('Waiting for some combination of process.nextTick + promise' +
' microtasks to attach a catch handler is still soon enough to ' +
'prevent unhandledRejection: inside setImmediate', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledFail(done);
setImmediate(function() {
- var a = Promise.reject(e);
+ const a = Promise.reject(e);
process.nextTick(function() {
Promise.resolve().then(function() {
process.nextTick(function() {
@@ -485,11 +485,11 @@ asyncTest('Waiting for some combination of process.nextTick + promise' +
asyncTest('Waiting for some combination of process.nextTick + promise ' +
'microtasks to attach a catch handler is still soon enough to ' +
'prevent unhandledRejection: inside setTimeout', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledFail(done);
setTimeout(function() {
- var a = Promise.reject(e);
+ const a = Promise.reject(e);
process.nextTick(function() {
Promise.resolve().then(function() {
process.nextTick(function() {
@@ -505,11 +505,11 @@ asyncTest('Waiting for some combination of process.nextTick + promise ' +
asyncTest('Waiting for some combination of promise microtasks + ' +
'process.nextTick to attach a catch handler is still soon enough' +
' to prevent unhandledRejection', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledFail(done);
- var a = Promise.reject(e);
+ const a = Promise.reject(e);
Promise.resolve().then(function() {
process.nextTick(function() {
Promise.resolve().then(function() {
@@ -526,11 +526,11 @@ asyncTest(
' process.nextTick to attach a catch handler is still soon enough' +
' to prevent unhandledRejection: inside setImmediate',
function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledFail(done);
setImmediate(function() {
- var a = Promise.reject(e);
+ const a = Promise.reject(e);
Promise.resolve().then(function() {
process.nextTick(function() {
Promise.resolve().then(function() {
@@ -547,11 +547,11 @@ asyncTest(
asyncTest('Waiting for some combination of promise microtasks +' +
' process.nextTick to attach a catch handler is still soon enough' +
' to prevent unhandledRejection: inside setTimeout', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledFail(done);
setTimeout(function() {
- var a = Promise.reject(e);
+ const a = Promise.reject(e);
Promise.resolve().then(function() {
process.nextTick(function() {
Promise.resolve().then(function() {
@@ -567,12 +567,12 @@ asyncTest('Waiting for some combination of promise microtasks +' +
asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
' handler; unhandledRejection will be triggered in that case.' +
' (setImmediate before promise creation/rejection)', function(done) {
- var e = new Error();
+ const e = new Error();
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(e, reason);
assert.strictEqual(p, promise);
});
- var p = Promise.reject(e);
+ let p = Promise.reject(e);
setImmediate(function() {
Promise.resolve().then(function() {
p.catch(function() {});
@@ -598,7 +598,7 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
});
});
});
- var p = Promise.reject();
+ let p = Promise.reject();
});
asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
@@ -608,7 +608,7 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' +
assert.strictEqual(undefined, reason);
assert.strictEqual(p, promise);
});
- var p = Promise.reject();
+ let p = Promise.reject();
setImmediate(function() {
Promise.resolve().then(function() {
Promise.resolve().then(function() {
@@ -626,14 +626,14 @@ 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;
+ const d = domain.create();
+ let domainReceivedError;
d.on('error', function(e) {
domainReceivedError = e;
});
d.run(function() {
- var e = new Error('error');
- var domainError = new Error('domain error');
+ const e = new Error('error');
+ const domainError = new Error('domain error');
onUnhandledSucceed(done, function(reason, promise) {
assert.strictEqual(reason, e);
assert.strictEqual(domainReceivedError, domainError);
@@ -650,9 +650,9 @@ asyncTest(
asyncTest('nextTick is immediately scheduled when called inside an event' +
' handler', function(done) {
clean();
- var e = new Error('error');
+ const e = new Error('error');
process.on('unhandledRejection', function(reason, promise) {
- var order = [];
+ const order = [];
process.nextTick(function() {
order.push(1);
});
@@ -669,9 +669,9 @@ asyncTest('Throwing an error inside a rejectionHandled handler goes to' +
' unhandledException, and does not cause .catch() to throw an' +
'exception', function(done) {
clean();
- var e = new Error();
- var e2 = new Error();
- var tearDownException = setupException(function(err) {
+ const e = new Error();
+ const e2 = new Error();
+ const tearDownException = setupException(function(err) {
assert.equal(e2, err);
tearDownException();
done();
@@ -679,7 +679,7 @@ asyncTest('Throwing an error inside a rejectionHandled handler goes to' +
process.on('rejectionHandled', function() {
throw e2;
});
- var p = Promise.reject(e);
+ const p = Promise.reject(e);
setTimeout(function() {
try {
p.catch(function() {});
diff --git a/test/parallel/test-promises-warning-on-unhandled-rejection.js b/test/parallel/test-promises-warning-on-unhandled-rejection.js
index 9b1e7f3266aba0..92bdc27e4a68cf 100644
--- a/test/parallel/test-promises-warning-on-unhandled-rejection.js
+++ b/test/parallel/test-promises-warning-on-unhandled-rejection.js
@@ -7,7 +7,7 @@
const common = require('../common');
const assert = require('assert');
-var b = 0;
+let b = 0;
process.on('warning', common.mustCall((warning) => {
switch (b++) {
diff --git a/test/parallel/test-querystring-maxKeys-non-finite.js b/test/parallel/test-querystring-maxKeys-non-finite.js
index aab7c45f1b6bed..8aa47f7de0e2dc 100644
--- a/test/parallel/test-querystring-maxKeys-non-finite.js
+++ b/test/parallel/test-querystring-maxKeys-non-finite.js
@@ -13,7 +13,7 @@ https://github.com/expressjs/body-parser/
blob/ed25264fb494cf0c8bc992b8257092cd4f694d5e/test/urlencoded.js#L636-L651
*/
function createManyParams(count) {
- var str = '';
+ let str = '';
if (count === 0) {
return str;
@@ -21,8 +21,8 @@ function createManyParams(count) {
str += '0=0';
- for (var i = 1; i < count; i++) {
- var n = i.toString(36);
+ for (let i = 1; i < count; i++) {
+ const n = i.toString(36);
str += '&' + n + '=' + n;
}
diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js
index 6247235e967ac2..fed9eb9b8506ac 100644
--- a/test/parallel/test-querystring.js
+++ b/test/parallel/test-querystring.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// test using assert
-var qs = require('querystring');
+const qs = require('querystring');
function createWithNoPrototype(properties) {
const noProto = Object.create(null);
@@ -15,7 +15,7 @@ function createWithNoPrototype(properties) {
// folding block, commented to pass gjslint
// {{{
// [ wonkyQS, canonicalQS, obj ]
-var qsTestCases = [
+const qsTestCases = [
['__proto__=1',
'__proto__=1',
createWithNoPrototype([{key: '__proto__', value: '1'}])],
@@ -56,7 +56,7 @@ var qsTestCases = [
];
// [ wonkyQS, canonicalQS, obj ]
-var qsColonTestCases = [
+const qsColonTestCases = [
['foo:bar', 'foo:bar', {'foo': 'bar'}],
['foo:bar;foo:quux', 'foo:bar;foo:quux', {'foo': ['bar', 'quux']}],
['foo:1&bar:2;baz:quux',
@@ -67,9 +67,9 @@ var qsColonTestCases = [
];
// [wonkyObj, qs, canonicalObj]
-var extendedFunction = function() {};
+const extendedFunction = function() {};
extendedFunction.prototype = {a: 'b'};
-var qsWeirdObjects = [
+const qsWeirdObjects = [
[{regexp: /./g}, 'regexp=', {'regexp': ''}],
[{regexp: new RegExp('.', 'g')}, 'regexp=', {'regexp': ''}],
[{fn: function() {}}, 'fn=', {'fn': ''}],
@@ -87,10 +87,10 @@ var qsWeirdObjects = [
];
// }}}
-var vm = require('vm');
-var foreignObject = vm.runInNewContext('({"foo": ["bar", "baz"]})');
+const vm = require('vm');
+const foreignObject = vm.runInNewContext('({"foo": ["bar", "baz"]})');
-var qsNoMungeTestCases = [
+const qsNoMungeTestCases = [
['', {}],
['foo=bar&foo=baz', {'foo': ['bar', 'baz']}],
['foo=bar&foo=baz', foreignObject],
@@ -259,7 +259,7 @@ assert.equal(
function testUnlimitedKeys() {
const query = {};
- for (var i = 0; i < 2000; i++) query[i] = i;
+ for (let i = 0; i < 2000; i++) query[i] = i;
const url = qs.stringify(query);
@@ -270,7 +270,7 @@ function testUnlimitedKeys() {
testUnlimitedKeys();
-var b = qs.unescapeBuffer('%d3%f2Ug%1f6v%24%5e%98%cb' +
+const b = qs.unescapeBuffer('%d3%f2Ug%1f6v%24%5e%98%cb' +
'%0d%ac%a2%2f%9d%eb%d8%a2%e6');
//
assert.equal(0xd3, b[0]);
@@ -320,7 +320,7 @@ check(qs.parse('a=a', null, null, { decodeURIComponent: errDecode }),
function demoEncode(str) {
return str[0];
}
-var obj = { aa: 'aa', bb: 'bb', cc: 'cc' };
+const obj = { aa: 'aa', bb: 'bb', cc: 'cc' };
assert.equal(
qs.stringify(obj, null, null, { encodeURIComponent: demoEncode }),
'a=a&b=b&c=c');
@@ -332,7 +332,7 @@ qsUnescapeTestCases.forEach(function(testCase) {
});
// test overriding .unescape
-var prevUnescape = qs.unescape;
+const prevUnescape = qs.unescape;
qs.unescape = function(str) {
return str.replace(/o/g, '_');
};
diff --git a/test/parallel/test-readdouble.js b/test/parallel/test-readdouble.js
index a6fc91c351f089..728a2b4605d9ff 100644
--- a/test/parallel/test-readdouble.js
+++ b/test/parallel/test-readdouble.js
@@ -9,7 +9,7 @@ const assert = require('assert');
* Test (64 bit) double
*/
function test(clazz) {
- var buffer = new clazz(8);
+ const buffer = new clazz(8);
buffer[0] = 0x55;
buffer[1] = 0x55;
diff --git a/test/parallel/test-readfloat.js b/test/parallel/test-readfloat.js
index 533b7caa8f1047..437e4778671bd2 100644
--- a/test/parallel/test-readfloat.js
+++ b/test/parallel/test-readfloat.js
@@ -9,7 +9,7 @@ const assert = require('assert');
* Test (32 bit) float
*/
function test(clazz) {
- var buffer = new clazz(4);
+ const buffer = new clazz(4);
buffer[0] = 0;
buffer[1] = 0;
diff --git a/test/parallel/test-readint.js b/test/parallel/test-readint.js
index c068ddcb6c554a..086dd4e3aa0d1a 100644
--- a/test/parallel/test-readint.js
+++ b/test/parallel/test-readint.js
@@ -9,7 +9,7 @@ const assert = require('assert');
* Test 8 bit signed integers
*/
function test8(clazz) {
- var data = new clazz(4);
+ const data = new clazz(4);
data[0] = 0x23;
assert.equal(0x23, data.readInt8(0));
@@ -29,7 +29,7 @@ function test8(clazz) {
function test16(clazz) {
- var buffer = new clazz(6);
+ const buffer = new clazz(6);
buffer[0] = 0x16;
buffer[1] = 0x79;
@@ -62,7 +62,7 @@ function test16(clazz) {
function test32(clazz) {
- var buffer = new clazz(6);
+ const buffer = new clazz(6);
buffer[0] = 0x43;
buffer[1] = 0x53;
diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js
index 96f67c320e1789..49809dda81a3a2 100644
--- a/test/parallel/test-readline-interface.js
+++ b/test/parallel/test-readline-interface.js
@@ -17,8 +17,8 @@ FakeInput.prototype.write = function() {};
FakeInput.prototype.end = function() {};
function isWarned(emitter) {
- for (var name in emitter) {
- var listeners = emitter[name];
+ for (const name in emitter) {
+ const listeners = emitter[name];
if (listeners.warned) return true;
}
return false;
@@ -53,9 +53,9 @@ function isWarned(emitter) {
}
[ true, false ].forEach(function(terminal) {
- var fi;
- var rli;
- var called;
+ let fi;
+ let rli;
+ let called;
// disable history
fi = new FakeInput();
@@ -126,8 +126,8 @@ function isWarned(emitter) {
// sending multiple newlines at once
fi = new FakeInput();
rli = new readline.Interface({ input: fi, output: fi, terminal: terminal });
- var expectedLines = ['foo', 'bar', 'baz'];
- var callCount = 0;
+ let expectedLines = ['foo', 'bar', 'baz'];
+ let callCount = 0;
rli.on('line', function(line) {
assert.equal(line, expectedLines[callCount]);
callCount++;
@@ -265,7 +265,7 @@ function isWarned(emitter) {
// \t does not become part of the input when there is a completer function
fi = new FakeInput();
- var completer = function(line) {
+ const completer = function(line) {
return [[], line];
};
rli = new readline.Interface({
@@ -280,7 +280,7 @@ function isWarned(emitter) {
assert.strictEqual(called, false);
called = true;
});
- for (var character of '\tfo\to\t') {
+ for (const character of '\tfo\to\t') {
fi.emit('data', character);
}
fi.emit('data', '\n');
@@ -304,7 +304,7 @@ function isWarned(emitter) {
});
// sending a multi-byte utf8 char over multiple writes
- var buf = Buffer.from('☮', 'utf8');
+ const buf = Buffer.from('☮', 'utf8');
fi = new FakeInput();
rli = new readline.Interface({ input: fi, output: fi, terminal: terminal });
callCount = 0;
@@ -324,7 +324,7 @@ function isWarned(emitter) {
// check that nothing fails if 'keypress' event throws.
fi = new FakeInput();
rli = new readline.Interface({ input: fi, output: fi, terminal: true });
- var keys = [];
+ const keys = [];
fi.on('keypress', function(key) {
keys.push(key);
if (key === 'X') {
@@ -358,7 +358,7 @@ function isWarned(emitter) {
rli.question(expectedLines[0], function() {
rli.close();
});
- var cursorPos = rli._getCursorPos();
+ let cursorPos = rli._getCursorPos();
assert.equal(cursorPos.rows, 0);
assert.equal(cursorPos.cols, expectedLines[0].length);
rli.close();
@@ -425,8 +425,8 @@ function isWarned(emitter) {
assert.deepStrictEqual(fi.listeners(terminal ? 'keypress' : 'data'), []);
// check EventEmitter memory leak
- for (var i = 0; i < 12; i++) {
- var rl = readline.createInterface({
+ for (let i = 0; i < 12; i++) {
+ const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
diff --git a/test/parallel/test-readline-keys.js b/test/parallel/test-readline-keys.js
index 85e3f4df6ff917..f45bcb97e02d55 100644
--- a/test/parallel/test-readline-keys.js
+++ b/test/parallel/test-readline-keys.js
@@ -13,11 +13,11 @@ function FakeInput() {
inherits(FakeInput, PassThrough);
-var fi = new FakeInput();
-var fo = new FakeInput();
+const fi = new FakeInput();
+const fo = new FakeInput();
new Interface({ input: fi, output: fo, terminal: true });
-var keys = [];
+let keys = [];
fi.on('keypress', function(s, k) {
keys.push(k);
});
diff --git a/test/parallel/test-readline-set-raw-mode.js b/test/parallel/test-readline-set-raw-mode.js
index acf0dc44a631c7..78c42f5f5f627d 100644
--- a/test/parallel/test-readline-set-raw-mode.js
+++ b/test/parallel/test-readline-set-raw-mode.js
@@ -1,14 +1,14 @@
'use strict';
require('../common');
-var assert = require('assert');
-var readline = require('readline');
-var Stream = require('stream');
+const assert = require('assert');
+const readline = require('readline');
+const Stream = require('stream');
-var stream = new Stream();
-var expectedRawMode = true;
-var rawModeCalled = false;
-var resumeCalled = false;
-var pauseCalled = false;
+const stream = new Stream();
+let expectedRawMode = true;
+let rawModeCalled = false;
+let resumeCalled = false;
+let pauseCalled = false;
stream.setRawMode = function(mode) {
rawModeCalled = true;
@@ -23,7 +23,7 @@ stream.pause = function() {
// when the "readline" starts in "terminal" mode,
// then setRawMode(true) should be called
-var rli = readline.createInterface({
+const rli = readline.createInterface({
input: stream,
output: stream,
terminal: true
diff --git a/test/parallel/test-readline-undefined-columns.js b/test/parallel/test-readline-undefined-columns.js
index f3197ff59a9a55..a56a3d54dbbb96 100644
--- a/test/parallel/test-readline-undefined-columns.js
+++ b/test/parallel/test-readline-undefined-columns.js
@@ -20,7 +20,7 @@ readline.createInterface({
}
});
-var output = '';
+let output = '';
oStream.on('data', function(data) {
output += data;
diff --git a/test/parallel/test-readuint.js b/test/parallel/test-readuint.js
index 9fcaf45603fd83..0d1f79b12eabd4 100644
--- a/test/parallel/test-readuint.js
+++ b/test/parallel/test-readuint.js
@@ -14,7 +14,7 @@ const assert = require('assert');
* - Correctly interpreting values that are beyond the signed range as unsigned
*/
function test8(clazz) {
- var data = new clazz(4);
+ const data = new clazz(4);
data[0] = 23;
data[1] = 23;
@@ -39,7 +39,7 @@ function test8(clazz) {
* - Correctly interpreting values that are beyond the signed range as unsigned
*/
function test16(clazz) {
- var data = new clazz(4);
+ const data = new clazz(4);
data[0] = 0;
data[1] = 0x23;
@@ -67,7 +67,7 @@ function test16(clazz) {
* - Correctly interpreting values that are beyond the signed range as unsigned
*/
function test32(clazz) {
- var data = new clazz(8);
+ const data = new clazz(8);
data[0] = 0x32;
data[1] = 0x65;
diff --git a/test/parallel/test-ref-unref-return.js b/test/parallel/test-ref-unref-return.js
index 89ac52d2bcaa50..aec2fff5ce2271 100644
--- a/test/parallel/test-ref-unref-return.js
+++ b/test/parallel/test-ref-unref-return.js
@@ -1,8 +1,8 @@
'use strict';
require('../common');
-var assert = require('assert');
-var net = require('net');
-var dgram = require('dgram');
+const assert = require('assert');
+const net = require('net');
+const dgram = require('dgram');
assert.ok((new net.Server()).ref() instanceof net.Server);
assert.ok((new net.Server()).unref() instanceof net.Server);
diff --git a/test/parallel/test-regress-GH-1531.js b/test/parallel/test-regress-GH-1531.js
index fa0781c2e2fa72..5189e50929105c 100644
--- a/test/parallel/test-regress-GH-1531.js
+++ b/test/parallel/test-regress-GH-1531.js
@@ -1,20 +1,20 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var fs = require('fs');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var server = https.createServer(options, function(req, res) {
+const server = https.createServer(options, function(req, res) {
res.writeHead(200);
res.end('hello world\n');
});
diff --git a/test/parallel/test-regress-GH-1899.js b/test/parallel/test-regress-GH-1899.js
index 7ce83e00092449..838391acd23b5f 100644
--- a/test/parallel/test-regress-GH-1899.js
+++ b/test/parallel/test-regress-GH-1899.js
@@ -1,13 +1,13 @@
'use strict';
const common = require('../common');
-var path = require('path');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
+const path = require('path');
+const assert = require('assert');
+const spawn = require('child_process').spawn;
-var child = spawn(process.argv[0], [
+const child = spawn(process.argv[0], [
path.join(common.fixturesDir, 'GH-1899-output.js')
]);
-var output = '';
+let output = '';
child.stdout.on('data', function(data) {
output += data;
diff --git a/test/parallel/test-regress-GH-2245.js b/test/parallel/test-regress-GH-2245.js
index 7558529f9fc50c..c5b0ae4982d993 100644
--- a/test/parallel/test-regress-GH-2245.js
+++ b/test/parallel/test-regress-GH-2245.js
@@ -1,6 +1,6 @@
/* eslint-disable strict */
require('../common');
-var assert = require('assert');
+const assert = require('assert');
/*
In Node.js 0.10, a bug existed that caused strict functions to not capture
@@ -10,7 +10,7 @@ their environment when evaluated. When run in 0.10 `test()` fails with a
function test() {
- var code = [
+ const code = [
'var foo = {m: 1};',
'',
'function bar() {',
diff --git a/test/parallel/test-regress-GH-3542.js b/test/parallel/test-regress-GH-3542.js
index 8db34e72157371..cc0285f7475697 100644
--- a/test/parallel/test-regress-GH-3542.js
+++ b/test/parallel/test-regress-GH-3542.js
@@ -11,7 +11,7 @@ if (!common.isWindows) {
}
function test(p) {
- var result = fs.realpathSync(p);
+ const result = fs.realpathSync(p);
assert.strictEqual(result.toLowerCase(), path.resolve(p).toLowerCase());
fs.realpath(p, common.mustCall(function(err, result) {
diff --git a/test/parallel/test-regress-GH-3739.js b/test/parallel/test-regress-GH-3739.js
index aef54c3ea6c7c4..6b4a62700c6dec 100644
--- a/test/parallel/test-regress-GH-3739.js
+++ b/test/parallel/test-regress-GH-3739.js
@@ -5,13 +5,13 @@ const assert = require('assert');
const fs = require('fs');
const path = require('path');
-var dir = path.resolve(common.tmpDir);
+let dir = path.resolve(common.tmpDir);
// Make sure that the tmp directory is clean
common.refreshTmpDir();
// Make a long path.
-for (var i = 0; i < 50; i++) {
+for (let i = 0; i < 50; i++) {
dir = dir + '/1234567890';
try {
fs.mkdirSync(dir, '0777');
diff --git a/test/parallel/test-regress-GH-4948.js b/test/parallel/test-regress-GH-4948.js
index 0317778787c2e2..196c973cd093e3 100644
--- a/test/parallel/test-regress-GH-4948.js
+++ b/test/parallel/test-regress-GH-4948.js
@@ -2,10 +2,10 @@
// https://github.com/joyent/node/issues/4948
require('../common');
-var http = require('http');
+const http = require('http');
-var reqCount = 0;
-var server = http.createServer(function(serverReq, serverRes) {
+let reqCount = 0;
+const server = http.createServer(function(serverReq, serverRes) {
if (reqCount) {
serverRes.end();
server.close();
@@ -16,8 +16,8 @@ var server = http.createServer(function(serverReq, serverRes) {
// normally the use case would be to call an external site
// does not require connecting locally or to itself to fail
- var r = http.request({hostname: 'localhost',
- port: this.address().port}, function(res) {
+ const r = http.request({hostname: 'localhost',
+ port: this.address().port}, function(res) {
// required, just needs to be in the client response somewhere
serverRes.end();
@@ -31,9 +31,9 @@ var server = http.createServer(function(serverReq, serverRes) {
serverRes.write('some data');
}).listen(0, function() {
// simulate a client request that closes early
- var net = require('net');
+ const net = require('net');
- var sock = new net.Socket();
+ const sock = new net.Socket();
sock.connect(this.address().port, 'localhost');
sock.on('connect', function() {
diff --git a/test/parallel/test-regress-GH-5927.js b/test/parallel/test-regress-GH-5927.js
index a23c947c320cfc..7f55356a15e027 100644
--- a/test/parallel/test-regress-GH-5927.js
+++ b/test/parallel/test-regress-GH-5927.js
@@ -1,20 +1,20 @@
'use strict';
require('../common');
-var assert = require('assert');
-var readline = require('readline');
+const assert = require('assert');
+const readline = require('readline');
-var rl = readline.createInterface(process.stdin, process.stdout);
+const rl = readline.createInterface(process.stdin, process.stdout);
rl.resume();
-var hasPaused = false;
+let hasPaused = false;
-var origPause = rl.pause;
+const origPause = rl.pause;
rl.pause = function() {
hasPaused = true;
origPause.apply(this, arguments);
};
-var origSetRawMode = rl._setRawMode;
+const origSetRawMode = rl._setRawMode;
rl._setRawMode = function(mode) {
assert.ok(hasPaused);
origSetRawMode.apply(this, arguments);
diff --git a/test/parallel/test-regress-GH-6235.js b/test/parallel/test-regress-GH-6235.js
index 0bf9b8965d1184..10092884670980 100644
--- a/test/parallel/test-regress-GH-6235.js
+++ b/test/parallel/test-regress-GH-6235.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
assert.doesNotThrow(function() {
require('vm').runInNewContext('"use strict"; var v = 1; v = 2');
diff --git a/test/parallel/test-regress-GH-746.js b/test/parallel/test-regress-GH-746.js
index 8bfcb0c3e22f12..9a6e0e8980f311 100644
--- a/test/parallel/test-regress-GH-746.js
+++ b/test/parallel/test-regress-GH-746.js
@@ -3,11 +3,11 @@
// This is a regression test for GH-746.
const common = require('../common');
-var net = require('net');
+const net = require('net');
process.stdin.destroy();
-var server = net.createServer(common.mustCall(function(socket) {
+const server = net.createServer(common.mustCall(function(socket) {
console.log('accepted');
socket.end();
server.close();
diff --git a/test/parallel/test-regress-GH-7511.js b/test/parallel/test-regress-GH-7511.js
index d18a3ae02c0d03..11bb5bfd4cb170 100644
--- a/test/parallel/test-regress-GH-7511.js
+++ b/test/parallel/test-regress-GH-7511.js
@@ -4,7 +4,7 @@ const assert = require('assert');
const vm = require('vm');
assert.doesNotThrow(function() {
- var context = vm.createContext({ process: process });
- var result = vm.runInContext('process.env["PATH"]', context);
+ const context = vm.createContext({ process: process });
+ const result = vm.runInContext('process.env["PATH"]', context);
assert.notEqual(undefined, result);
});
diff --git a/test/parallel/test-regress-GH-819.js b/test/parallel/test-regress-GH-819.js
index 20ca75c793ce24..719d4398251eab 100644
--- a/test/parallel/test-regress-GH-819.js
+++ b/test/parallel/test-regress-GH-819.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var net = require('net');
+const net = require('net');
// Connect to something that we need to DNS resolve
-var c = net.createConnection(80, 'google.com');
+const c = net.createConnection(80, 'google.com');
c.destroy();
diff --git a/test/parallel/test-regress-GH-node-9326.js b/test/parallel/test-regress-GH-node-9326.js
index bb55050d2ce55e..f32f45cbd02943 100644
--- a/test/parallel/test-regress-GH-node-9326.js
+++ b/test/parallel/test-regress-GH-node-9326.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
-var child_process = require('child_process');
+const assert = require('assert');
+const child_process = require('child_process');
// NOTE: Was crashing on FreeBSD
-var cp = child_process.spawn(process.execPath, [
+const cp = child_process.spawn(process.execPath, [
'-e',
'process.kill(process.pid, "SIGINT")'
]);
diff --git a/test/parallel/test-repl-.save.load.js b/test/parallel/test-repl-.save.load.js
index 247f359e829d25..00d5f6791d54a5 100644
--- a/test/parallel/test-repl-.save.load.js
+++ b/test/parallel/test-repl-.save.load.js
@@ -1,24 +1,24 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var join = require('path').join;
-var fs = require('fs');
+const assert = require('assert');
+const join = require('path').join;
+const fs = require('fs');
common.refreshTmpDir();
-var repl = require('repl');
+const repl = require('repl');
-var works = [['inner.one'], 'inner.o'];
+const works = [['inner.one'], 'inner.o'];
const putIn = new common.ArrayStream();
-var testMe = repl.start('', putIn);
+const testMe = repl.start('', putIn);
-var testFile = [
+const testFile = [
'var top = function() {',
'var inner = {one:1};'
];
-var saveFileName = join(common.tmpDir, 'test.save.js');
+const saveFileName = join(common.tmpDir, 'test.save.js');
// input some data
putIn.run(testFile);
@@ -69,7 +69,7 @@ testMe.complete('inner.o', function(error, data) {
// clear the REPL
putIn.run(['.clear']);
-var loadFile = join(common.tmpDir, 'file.does.not.exist');
+let loadFile = join(common.tmpDir, 'file.does.not.exist');
// should not break
putIn.write = function(data) {
diff --git a/test/parallel/test-repl-autolibs.js b/test/parallel/test-repl-autolibs.js
index 15f779d3b12269..859ff5c3c9652a 100644
--- a/test/parallel/test-repl-autolibs.js
+++ b/test/parallel/test-repl-autolibs.js
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var util = require('util');
-var repl = require('repl');
+const assert = require('assert');
+const util = require('util');
+const repl = require('repl');
// This test adds global variables
common.globalCheck = false;
@@ -13,7 +13,7 @@ repl.start('', putIn, null, true);
test1();
function test1() {
- var gotWrite = false;
+ let gotWrite = false;
putIn.write = function(data) {
gotWrite = true;
if (data.length) {
@@ -31,7 +31,7 @@ function test1() {
}
function test2() {
- var gotWrite = false;
+ let gotWrite = false;
putIn.write = function(data) {
gotWrite = true;
if (data.length) {
@@ -41,7 +41,7 @@ function test2() {
assert.equal(val, global.url);
}
};
- var val = {};
+ let val = {};
global.url = val;
assert(!gotWrite);
putIn.run(['url']);
diff --git a/test/parallel/test-repl-console.js b/test/parallel/test-repl-console.js
index 98cb958cac8e68..f37dde008044ed 100644
--- a/test/parallel/test-repl-console.js
+++ b/test/parallel/test-repl-console.js
@@ -6,7 +6,7 @@ const repl = require('repl');
// Create a dummy stream that does nothing
const stream = new common.ArrayStream();
-var r = repl.start({
+const r = repl.start({
input: stream,
output: stream,
useGlobal: false
diff --git a/test/parallel/test-repl-definecommand.js b/test/parallel/test-repl-definecommand.js
index 6c0c75bca8db79..07732d534e9def 100644
--- a/test/parallel/test-repl-definecommand.js
+++ b/test/parallel/test-repl-definecommand.js
@@ -6,7 +6,7 @@ const stream = require('stream');
const assert = require('assert');
const repl = require('repl');
-var output = '';
+let output = '';
const inputStream = new stream.PassThrough();
const outputStream = new stream.PassThrough();
outputStream.on('data', function(d) {
diff --git a/test/parallel/test-repl-domain.js b/test/parallel/test-repl-domain.js
index 3cc88b75f72428..19c85980cdcc72 100644
--- a/test/parallel/test-repl-domain.js
+++ b/test/parallel/test-repl-domain.js
@@ -1,7 +1,7 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
-var repl = require('repl');
+const repl = require('repl');
const putIn = new common.ArrayStream();
repl.start('', putIn);
diff --git a/test/parallel/test-repl-end-emits-exit.js b/test/parallel/test-repl-end-emits-exit.js
index 7f2c4b9eb2893f..661f9f0ad0e3a4 100644
--- a/test/parallel/test-repl-end-emits-exit.js
+++ b/test/parallel/test-repl-end-emits-exit.js
@@ -9,7 +9,7 @@ let regularExit = 0;
const stream = new common.ArrayStream();
function testTerminalMode() {
- var r1 = repl.start({
+ const r1 = repl.start({
input: stream,
output: stream,
terminal: true
@@ -28,7 +28,7 @@ function testTerminalMode() {
}
function testRegularMode() {
- var r2 = repl.start({
+ const r2 = repl.start({
input: stream,
output: stream,
terminal: false
diff --git a/test/parallel/test-repl-harmony.js b/test/parallel/test-repl-harmony.js
index a5928800381cfe..743bbe4fabfcd1 100644
--- a/test/parallel/test-repl-harmony.js
+++ b/test/parallel/test-repl-harmony.js
@@ -1,13 +1,13 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var spawn = require('child_process').spawn;
-var args = ['-i'];
-var child = spawn(process.execPath, args);
+const spawn = require('child_process').spawn;
+const args = ['-i'];
+const child = spawn(process.execPath, args);
-var input = '(function(){"use strict"; const y=1;y=2})()\n';
-var expectOut = /^> TypeError: Assignment to constant variable.\n/;
+const input = '(function(){"use strict"; const y=1;y=2})()\n';
+const expectOut = /^> TypeError: Assignment to constant variable.\n/;
child.stderr.setEncoding('utf8');
child.stderr.on('data', function(c) {
@@ -15,7 +15,7 @@ child.stderr.on('data', function(c) {
});
child.stdout.setEncoding('utf8');
-var out = '';
+let out = '';
child.stdout.on('data', function(c) {
out += c;
});
diff --git a/test/parallel/test-repl-history-perm.js b/test/parallel/test-repl-history-perm.js
index 4a374cb0ab12e8..69b973db2b79bc 100644
--- a/test/parallel/test-repl-history-perm.js
+++ b/test/parallel/test-repl-history-perm.js
@@ -18,7 +18,7 @@ const Duplex = require('stream').Duplex;
// Invoking the REPL should create a repl history file at the specified path
// and mode 600.
-var stream = new Duplex();
+const stream = new Duplex();
stream.pause = stream.resume = function() {};
// ends immediately
stream._read = function() {
diff --git a/test/parallel/test-repl-null.js b/test/parallel/test-repl-null.js
index 337e194447d1f8..66d09b28f28b84 100644
--- a/test/parallel/test-repl-null.js
+++ b/test/parallel/test-repl-null.js
@@ -3,7 +3,7 @@ require('../common');
const repl = require('repl');
const assert = require('assert');
-var replserver = new repl.REPLServer();
+const replserver = new repl.REPLServer();
replserver._inTemplateLiteral = true;
diff --git a/test/parallel/test-repl-options.js b/test/parallel/test-repl-options.js
index 70244802dd0f45..79994c66d148c0 100644
--- a/test/parallel/test-repl-options.js
+++ b/test/parallel/test-repl-options.js
@@ -9,7 +9,7 @@ common.globalCheck = false;
const stream = new common.ArrayStream();
// 1, mostly defaults
-var r1 = repl.start({
+const r1 = repl.start({
input: stream,
output: stream,
terminal: true
@@ -37,7 +37,7 @@ assert.equal(r1.useColors, r1.rli.terminal);
// 2
function writer() {}
function evaler() {}
-var r2 = repl.start({
+const r2 = repl.start({
input: stream,
output: stream,
terminal: false,
@@ -67,7 +67,7 @@ assert.equal(r2.rli.output, r2.outputStream);
assert.equal(r2.rli.terminal, false);
// testing out "magic" replMode
-var r3 = repl.start({
+const r3 = repl.start({
input: stream,
output: stream,
writer: writer,
diff --git a/test/parallel/test-repl-persistent-history.js b/test/parallel/test-repl-persistent-history.js
index 25fdef81a8d5ab..2b0ceac530a65f 100644
--- a/test/parallel/test-repl-persistent-history.js
+++ b/test/parallel/test-repl-persistent-history.js
@@ -178,7 +178,7 @@ const tests = [
const numtests = tests.length;
-var testsNotRan = tests.length;
+let testsNotRan = tests.length;
process.on('beforeExit', () =>
assert.strictEqual(testsNotRan, 0)
diff --git a/test/parallel/test-repl-require.js b/test/parallel/test-repl-require.js
index 9dc3b51de7a88a..25aaac47a4ed36 100644
--- a/test/parallel/test-repl-require.js
+++ b/test/parallel/test-repl-require.js
@@ -18,7 +18,7 @@ const host = common.localhostIPv4;
const port = 0;
const options = { host, port };
-var answer = '';
+let answer = '';
server.listen(options, function() {
options.port = this.address().port;
const conn = net.connect(options);
diff --git a/test/parallel/test-repl-setprompt.js b/test/parallel/test-repl-setprompt.js
index 2708a3e6af5448..8dcc4fe94452da 100644
--- a/test/parallel/test-repl-setprompt.js
+++ b/test/parallel/test-repl-setprompt.js
@@ -4,18 +4,18 @@ const assert = require('assert');
const spawn = require('child_process').spawn;
const os = require('os');
-var args = [
+const args = [
'-e',
'var e = new (require("repl")).REPLServer("foo.. "); e.context.e = e;',
];
-var p = 'bar.. ';
+const p = 'bar.. ';
-var child = spawn(process.execPath, args);
+const child = spawn(process.execPath, args);
child.stdout.setEncoding('utf8');
-var data = '';
+let data = '';
child.stdout.on('data', function(d) { data += d; });
child.stdin.end(`e.setPrompt("${p}");${os.EOL}`);
@@ -23,6 +23,6 @@ child.stdin.end(`e.setPrompt("${p}");${os.EOL}`);
child.on('close', function(code, signal) {
assert.strictEqual(code, 0);
assert.ok(!signal);
- var lines = data.split(/\n/);
+ const lines = data.split(/\n/);
assert.strictEqual(lines.pop(), p);
});
diff --git a/test/parallel/test-repl-syntax-error-handling.js b/test/parallel/test-repl-syntax-error-handling.js
index 10166b4f06a692..6a65d53a029379 100644
--- a/test/parallel/test-repl-syntax-error-handling.js
+++ b/test/parallel/test-repl-syntax-error-handling.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
switch (process.argv[2]) {
case 'child':
@@ -12,8 +12,8 @@ switch (process.argv[2]) {
}
function parent() {
- var spawn = require('child_process').spawn;
- var child = spawn(process.execPath, [__filename, 'child']);
+ const spawn = require('child_process').spawn;
+ const child = spawn(process.execPath, [__filename, 'child']);
child.stderr.setEncoding('utf8');
child.stderr.on('data', function(c) {
@@ -22,7 +22,7 @@ function parent() {
});
child.stdout.setEncoding('utf8');
- var out = '';
+ let out = '';
child.stdout.on('data', function(c) {
out += c;
});
@@ -38,11 +38,12 @@ function parent() {
}
function child() {
- var vm = require('vm');
+ const vm = require('vm');
+ let caught;
try {
vm.runInThisContext('haf!@##&$!@$*!@', { displayErrors: false });
} catch (er) {
- var caught = true;
+ caught = true;
}
assert(caught);
vm.runInThisContext('console.log(10)', { displayErrors: false });
diff --git a/test/parallel/test-repl-tab-complete.js b/test/parallel/test-repl-tab-complete.js
index 58201f7446f365..2eca418acb01d9 100644
--- a/test/parallel/test-repl-tab-complete.js
+++ b/test/parallel/test-repl-tab-complete.js
@@ -17,9 +17,9 @@ function getNoResultsFunction() {
});
}
-var works = [['inner.one'], 'inner.o'];
+const works = [['inner.one'], 'inner.o'];
const putIn = new common.ArrayStream();
-var testMe = repl.start('', putIn);
+const testMe = repl.start('', putIn);
// Some errors are passed to the domain, but do not callback
testMe._domain.on('error', function(err) {
@@ -165,7 +165,7 @@ testMe.complete('str.len', common.mustCall(function(error, data) {
putIn.run(['.clear']);
// tab completion should not break on spaces
-var spaceTimeout = setTimeout(function() {
+const spaceTimeout = setTimeout(function() {
throw new Error('timeout');
}, 1000);
diff --git a/test/parallel/test-repl-tab.js b/test/parallel/test-repl-tab.js
index c075b8d4f1125f..a381d603fbeb84 100644
--- a/test/parallel/test-repl-tab.js
+++ b/test/parallel/test-repl-tab.js
@@ -1,12 +1,13 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var repl = require('repl');
-var zlib = require('zlib');
+const assert = require('assert');
+const repl = require('repl');
+const zlib = require('zlib');
// just use builtin stream inherited from Duplex
-var putIn = zlib.createGzip();
-var testMe = repl.start('', putIn, function(cmd, context, filename, callback) {
+const putIn = zlib.createGzip();
+const testMe = repl.start('', putIn, function(cmd, context,
+ filename, callback) {
callback(null, cmd);
});
diff --git a/test/parallel/test-repl-unexpected-token-recoverable.js b/test/parallel/test-repl-unexpected-token-recoverable.js
index 84668c8657c453..0f783d3dcaf27b 100644
--- a/test/parallel/test-repl-unexpected-token-recoverable.js
+++ b/test/parallel/test-repl-unexpected-token-recoverable.js
@@ -3,16 +3,16 @@
* This is a regression test for https://github.com/joyent/node/issues/8874.
*/
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var spawn = require('child_process').spawn;
+const spawn = require('child_process').spawn;
// use -i to force node into interactive mode, despite stdout not being a TTY
-var args = [ '-i' ];
-var child = spawn(process.execPath, args);
+const args = [ '-i' ];
+const child = spawn(process.execPath, args);
-var input = 'var foo = "bar\\\nbaz"';
+const input = 'var foo = "bar\\\nbaz"';
// Match '...' as well since it marks a multi-line statement
-var expectOut = /^> ... undefined\n/;
+const expectOut = /^> ... undefined\n/;
child.stderr.setEncoding('utf8');
child.stderr.on('data', function(c) {
@@ -20,7 +20,7 @@ child.stderr.on('data', function(c) {
});
child.stdout.setEncoding('utf8');
-var out = '';
+let out = '';
child.stdout.on('data', function(c) {
out += c;
});
diff --git a/test/parallel/test-require-cache.js b/test/parallel/test-require-cache.js
index 247590197d6126..437dd80e581e38 100644
--- a/test/parallel/test-require-cache.js
+++ b/test/parallel/test-require-cache.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
{
const relativePath = '../fixtures/semicolon';
diff --git a/test/parallel/test-require-extensions-same-filename-as-dir-trailing-slash.js b/test/parallel/test-require-extensions-same-filename-as-dir-trailing-slash.js
index 1837a17bab0add..0a80a860388de9 100644
--- a/test/parallel/test-require-extensions-same-filename-as-dir-trailing-slash.js
+++ b/test/parallel/test-require-extensions-same-filename-as-dir-trailing-slash.js
@@ -1,9 +1,9 @@
/* eslint-disable max-len */
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var content = require(common.fixturesDir +
+const content = require(common.fixturesDir +
'/json-with-directory-name-module/module-stub/one-trailing-slash/two/three.js');
assert.notEqual(content.rocko, 'artischocko');
diff --git a/test/parallel/test-require-process.js b/test/parallel/test-require-process.js
index 4e5821add13183..f2a3ac89a862fe 100644
--- a/test/parallel/test-require-process.js
+++ b/test/parallel/test-require-process.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var nativeProcess = require('process');
+const nativeProcess = require('process');
assert.strictEqual(nativeProcess, process,
'require("process") should return global process reference');
diff --git a/test/parallel/test-sigint-infinite-loop.js b/test/parallel/test-sigint-infinite-loop.js
index ecd64802acb627..30eb98ecb8a265 100644
--- a/test/parallel/test-sigint-infinite-loop.js
+++ b/test/parallel/test-sigint-infinite-loop.js
@@ -3,14 +3,14 @@
// Ref(http):
// groups.google.com/group/nodejs-dev/browse_thread/thread/e20f2f8df0296d3f
const common = require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
+const assert = require('assert');
+const spawn = require('child_process').spawn;
console.log('start');
-var c = spawn(process.execPath, ['-e', 'while(true) { console.log("hi"); }']);
+const c = spawn(process.execPath, ['-e', 'while(true) { console.log("hi"); }']);
-var sentKill = false;
+let sentKill = false;
c.stdout.on('data', function(s) {
// Prevent race condition:
diff --git a/test/parallel/test-signal-handler.js b/test/parallel/test-signal-handler.js
index 079c72a9e56a8a..b796ebb11d211c 100644
--- a/test/parallel/test-signal-handler.js
+++ b/test/parallel/test-signal-handler.js
@@ -18,7 +18,7 @@ process.on('SIGUSR1', common.mustCall(function() {
}, 5);
}));
-var i = 0;
+let i = 0;
setInterval(function() {
console.log('running process...' + ++i);
diff --git a/test/parallel/test-signal-safety.js b/test/parallel/test-signal-safety.js
index 7938ae04d6591b..34722b712f8889 100644
--- a/test/parallel/test-signal-safety.js
+++ b/test/parallel/test-signal-safety.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
-var Signal = process.binding('signal_wrap').Signal;
+const assert = require('assert');
+const Signal = process.binding('signal_wrap').Signal;
// Test Signal `this` safety
// https://github.com/joyent/node/issues/6690
assert.throws(function() {
- var s = new Signal();
- var nots = { start: s.start };
+ const s = new Signal();
+ const nots = { start: s.start };
nots.start(9);
}, TypeError);
diff --git a/test/parallel/test-socket-write-after-fin-error.js b/test/parallel/test-socket-write-after-fin-error.js
index 480d5d2edc321e..58ae1d62b2f172 100644
--- a/test/parallel/test-socket-write-after-fin-error.js
+++ b/test/parallel/test-socket-write-after-fin-error.js
@@ -1,20 +1,20 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// This is similar to simple/test-socket-write-after-fin, except that
// we don't set allowHalfOpen. Then we write after the client has sent
// a FIN, and this is an error. However, the standard "write after end"
// message is too vague, and doesn't actually tell you what happens.
-var net = require('net');
-var serverData = '';
-var gotServerEnd = false;
-var clientData = '';
-var gotClientEnd = false;
-var gotServerError = false;
+const net = require('net');
+let serverData = '';
+let gotServerEnd = false;
+let clientData = '';
+let gotClientEnd = false;
+let gotServerError = false;
-var server = net.createServer(function(sock) {
+const server = net.createServer(function(sock) {
sock.setEncoding('utf8');
sock.on('error', function(er) {
console.error(er.code + ': ' + er.message);
@@ -32,7 +32,7 @@ var server = net.createServer(function(sock) {
server.close();
});
server.listen(0, function() {
- var sock = net.connect(this.address().port);
+ const sock = net.connect(this.address().port);
sock.setEncoding('utf8');
sock.on('data', function(c) {
clientData += c;
diff --git a/test/parallel/test-socket-write-after-fin.js b/test/parallel/test-socket-write-after-fin.js
index 70f0d9bf843f9b..c8ff56871734af 100644
--- a/test/parallel/test-socket-write-after-fin.js
+++ b/test/parallel/test-socket-write-after-fin.js
@@ -1,13 +1,13 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const assert = require('assert');
+const net = require('net');
const expected = 'hello1hello2hello3\nTHUNDERMUSCLE!';
-var server = net.createServer({
+const server = net.createServer({
allowHalfOpen: true
}, common.mustCall(function(sock) {
- var serverData = '';
+ let serverData = '';
sock.setEncoding('utf8');
sock.on('data', function(c) {
@@ -20,8 +20,8 @@ var server = net.createServer({
}));
}));
server.listen(0, common.mustCall(function() {
- var sock = net.connect(this.address().port);
- var clientData = '';
+ const sock = net.connect(this.address().port);
+ let clientData = '';
sock.setEncoding('utf8');
sock.on('data', function(c) {
diff --git a/test/parallel/test-stdin-pipe-resume.js b/test/parallel/test-stdin-pipe-resume.js
index cb288070450a1f..06cce3edfe403f 100644
--- a/test/parallel/test-stdin-pipe-resume.js
+++ b/test/parallel/test-stdin-pipe-resume.js
@@ -1,19 +1,19 @@
'use strict';
// This tests that piping stdin will cause it to resume() as well.
require('../common');
-var assert = require('assert');
+const assert = require('assert');
if (process.argv[2] === 'child') {
process.stdin.pipe(process.stdout);
} else {
- var spawn = require('child_process').spawn;
- var buffers = [];
- var child = spawn(process.execPath, [__filename, 'child']);
+ const spawn = require('child_process').spawn;
+ const buffers = [];
+ const child = spawn(process.execPath, [__filename, 'child']);
child.stdout.on('data', function(c) {
buffers.push(c);
});
child.stdout.on('close', function() {
- var b = Buffer.concat(buffers).toString();
+ const b = Buffer.concat(buffers).toString();
assert.equal(b, 'Hello, world\n');
console.log('ok');
});
diff --git a/test/parallel/test-stdin-script-child.js b/test/parallel/test-stdin-script-child.js
index 091c5cb29ad296..a8a161686eeeef 100644
--- a/test/parallel/test-stdin-script-child.js
+++ b/test/parallel/test-stdin-script-child.js
@@ -9,7 +9,7 @@ const child = spawn(process.execPath, [], {
})
});
const wanted = child.pid + '\n';
-var found = '';
+let found = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(c) {
diff --git a/test/parallel/test-stdio-readable-writable.js b/test/parallel/test-stdio-readable-writable.js
index 7b9b69d309aec5..0bc7fe269b3303 100644
--- a/test/parallel/test-stdio-readable-writable.js
+++ b/test/parallel/test-stdio-readable-writable.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
assert(process.stdout.writable);
assert(!process.stdout.readable);
diff --git a/test/parallel/test-stdout-cannot-be-closed-child-process-pipe.js b/test/parallel/test-stdout-cannot-be-closed-child-process-pipe.js
index a138108fae7e01..aa1939ebe2c334 100644
--- a/test/parallel/test-stdout-cannot-be-closed-child-process-pipe.js
+++ b/test/parallel/test-stdout-cannot-be-closed-child-process-pipe.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
if (process.argv[2] === 'child')
process.stdout.end('foo');
@@ -8,10 +8,10 @@ else
parent();
function parent() {
- var spawn = require('child_process').spawn;
- var child = spawn(process.execPath, [__filename, 'child']);
- var out = '';
- var err = '';
+ const spawn = require('child_process').spawn;
+ const child = spawn(process.execPath, [__filename, 'child']);
+ let out = '';
+ let err = '';
child.stdout.setEncoding('utf8');
child.stderr.setEncoding('utf8');
diff --git a/test/parallel/test-stdout-stderr-reading.js b/test/parallel/test-stdout-stderr-reading.js
index e154d41b6bb8d1..6aa961301349fc 100644
--- a/test/parallel/test-stdout-stderr-reading.js
+++ b/test/parallel/test-stdout-stderr-reading.js
@@ -1,10 +1,10 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
// verify that stdout is never read from.
-var net = require('net');
-var read = net.Socket.prototype.read;
+const net = require('net');
+const read = net.Socket.prototype.read;
net.Socket.prototype.read = function() {
if (this.fd === 1)
@@ -20,11 +20,11 @@ else
parent();
function parent() {
- var spawn = require('child_process').spawn;
- var node = process.execPath;
+ const spawn = require('child_process').spawn;
+ const node = process.execPath;
- var c1 = spawn(node, [__filename, 'child']);
- var c1out = '';
+ const c1 = spawn(node, [__filename, 'child']);
+ let c1out = '';
c1.stdout.setEncoding('utf8');
c1.stdout.on('data', function(chunk) {
c1out += chunk;
@@ -40,8 +40,8 @@ function parent() {
console.log('ok');
}));
- var c2 = spawn(node, ['-e', 'console.log("ok")']);
- var c2out = '';
+ const c2 = spawn(node, ['-e', 'console.log("ok")']);
+ let c2out = '';
c2.stdout.setEncoding('utf8');
c2.stdout.on('data', function(chunk) {
c2out += chunk;
diff --git a/test/parallel/test-stdout-to-file.js b/test/parallel/test-stdout-to-file.js
index 10391c481a826d..870d77eadf41f3 100644
--- a/test/parallel/test-stdout-to-file.js
+++ b/test/parallel/test-stdout-to-file.js
@@ -13,13 +13,13 @@ const tmpFile = path.join(common.tmpDir, 'stdout.txt');
common.refreshTmpDir();
function test(size, useBuffer, cb) {
- var cmd = '"' + process.argv[0] + '"' +
- ' ' +
- '"' + (useBuffer ? scriptBuffer : scriptString) + '"' +
- ' ' +
- size +
- ' > ' +
- '"' + tmpFile + '"';
+ const cmd = '"' + process.argv[0] + '"' +
+ ' ' +
+ '"' + (useBuffer ? scriptBuffer : scriptString) + '"' +
+ ' ' +
+ size +
+ ' > ' +
+ '"' + tmpFile + '"';
try {
fs.unlinkSync(tmpFile);
@@ -32,7 +32,7 @@ function test(size, useBuffer, cb) {
console.log('done!');
- var stat = fs.statSync(tmpFile);
+ const stat = fs.statSync(tmpFile);
console.log(`${tmpFile} has ${stat.size} bytes`);
diff --git a/test/parallel/test-stream-base-no-abort.js b/test/parallel/test-stream-base-no-abort.js
index 85840c4c1c3b42..87c8f963485ab8 100644
--- a/test/parallel/test-stream-base-no-abort.js
+++ b/test/parallel/test-stream-base-no-abort.js
@@ -9,7 +9,7 @@ const fs = require('fs');
const net = require('net');
const tls = require('tls');
const providers = Object.keys(async_wrap.Providers);
-var flags = 0;
+let flags = 0;
// Make sure all asserts have run at least once.
process.on('exit', () => assert.equal(flags, 0b111));
diff --git a/test/parallel/test-stream-big-push.js b/test/parallel/test-stream-big-push.js
index 27feef35ef536d..9083820d42b546 100644
--- a/test/parallel/test-stream-big-push.js
+++ b/test/parallel/test-stream-big-push.js
@@ -18,7 +18,7 @@ function _read() {
}, 1);
reads++;
} else if (reads === 1) {
- var ret = r.push(str);
+ const ret = r.push(str);
assert.strictEqual(ret, false);
reads++;
} else {
@@ -32,10 +32,10 @@ r.on('end', common.mustCall(function() {}));
// push some data in to start.
// we've never gotten any read event at this point.
-var ret = r.push(str);
+const ret = r.push(str);
// should be false. > hwm
assert(!ret);
-var chunk = r.read();
+let chunk = r.read();
assert.strictEqual(chunk, str);
chunk = r.read();
assert.strictEqual(chunk, null);
diff --git a/test/parallel/test-stream-pipe-event.js b/test/parallel/test-stream-pipe-event.js
index d8601dd04a4d8e..1b5447eaa21ff9 100644
--- a/test/parallel/test-stream-pipe-event.js
+++ b/test/parallel/test-stream-pipe-event.js
@@ -1,8 +1,8 @@
'use strict';
require('../common');
-var stream = require('stream');
-var assert = require('assert');
-var util = require('util');
+const stream = require('stream');
+const assert = require('assert');
+const util = require('util');
function Writable() {
this.writable = true;
@@ -16,14 +16,14 @@ function Readable() {
}
util.inherits(Readable, stream.Stream);
-var passed = false;
+let passed = false;
-var w = new Writable();
+const w = new Writable();
w.on('pipe', function(src) {
passed = true;
});
-var r = new Readable();
+const r = new Readable();
r.pipe(w);
assert.ok(passed);
diff --git a/test/parallel/test-stream-push-order.js b/test/parallel/test-stream-push-order.js
index 22a3156f62f502..5fc1f5e89cf156 100644
--- a/test/parallel/test-stream-push-order.js
+++ b/test/parallel/test-stream-push-order.js
@@ -1,21 +1,21 @@
'use strict';
require('../common');
-var Readable = require('stream').Readable;
-var assert = require('assert');
+const Readable = require('stream').Readable;
+const assert = require('assert');
-var s = new Readable({
+const s = new Readable({
highWaterMark: 20,
encoding: 'ascii'
});
-var list = ['1', '2', '3', '4', '5', '6'];
+const list = ['1', '2', '3', '4', '5', '6'];
s._read = function(n) {
- var one = list.shift();
+ const one = list.shift();
if (!one) {
s.push(null);
} else {
- var two = list.shift();
+ const two = list.shift();
s.push(one);
s.push(two);
}
diff --git a/test/parallel/test-stream-push-strings.js b/test/parallel/test-stream-push-strings.js
index a5ebe4d3e917f6..7bce493bbd33ce 100644
--- a/test/parallel/test-stream-push-strings.js
+++ b/test/parallel/test-stream-push-strings.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var Readable = require('stream').Readable;
-var util = require('util');
+const Readable = require('stream').Readable;
+const util = require('util');
util.inherits(MyStream, Readable);
function MyStream(options) {
@@ -30,15 +30,15 @@ MyStream.prototype._read = function(n) {
}
};
-var ms = new MyStream();
-var results = [];
+const ms = new MyStream();
+const results = [];
ms.on('readable', function() {
- var chunk;
+ let chunk;
while (null !== (chunk = ms.read()))
results.push(chunk + '');
});
-var expect = [ 'first chunksecond to last chunk', 'last chunk' ];
+const expect = [ 'first chunksecond to last chunk', 'last chunk' ];
process.on('exit', function() {
assert.equal(ms._chunks, -1);
assert.deepStrictEqual(results, expect);
diff --git a/test/parallel/test-stream-readable-constructor-set-methods.js b/test/parallel/test-stream-readable-constructor-set-methods.js
index fb2114f44dad19..a5d7e48bfb3fa9 100644
--- a/test/parallel/test-stream-readable-constructor-set-methods.js
+++ b/test/parallel/test-stream-readable-constructor-set-methods.js
@@ -1,16 +1,16 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var Readable = require('stream').Readable;
+const Readable = require('stream').Readable;
-var _readCalled = false;
+let _readCalled = false;
function _read(n) {
_readCalled = true;
this.push(null);
}
-var r = new Readable({ read: _read });
+const r = new Readable({ read: _read });
r.resume();
process.on('exit', function() {
diff --git a/test/parallel/test-stream-readable-flow-recursion.js b/test/parallel/test-stream-readable-flow-recursion.js
index 0c0b16e8f5ca7e..b1e421a71fd15b 100644
--- a/test/parallel/test-stream-readable-flow-recursion.js
+++ b/test/parallel/test-stream-readable-flow-recursion.js
@@ -1,20 +1,20 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// this test verifies that passing a huge number to read(size)
// will push up the highWaterMark, and cause the stream to read
// more data continuously, but without triggering a nextTick
// warning or RangeError.
-var Readable = require('stream').Readable;
+const Readable = require('stream').Readable;
// throw an error if we trigger a nextTick warning.
process.throwDeprecation = true;
-var stream = new Readable({ highWaterMark: 2 });
-var reads = 0;
-var total = 5000;
+const stream = new Readable({ highWaterMark: 2 });
+let reads = 0;
+let total = 5000;
stream._read = function(size) {
reads++;
size = Math.min(size, total);
@@ -25,11 +25,11 @@ stream._read = function(size) {
stream.push(Buffer.allocUnsafe(size));
};
-var depth = 0;
+let depth = 0;
function flow(stream, size, callback) {
depth += 1;
- var chunk = stream.read(size);
+ const chunk = stream.read(size);
if (!chunk)
stream.once('readable', flow.bind(null, stream, size, callback));
diff --git a/test/parallel/test-stream-transform-constructor-set-methods.js b/test/parallel/test-stream-transform-constructor-set-methods.js
index 720357a01b9839..7be673c517b30b 100644
--- a/test/parallel/test-stream-transform-constructor-set-methods.js
+++ b/test/parallel/test-stream-transform-constructor-set-methods.js
@@ -1,22 +1,22 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var Transform = require('stream').Transform;
+const Transform = require('stream').Transform;
-var _transformCalled = false;
+let _transformCalled = false;
function _transform(d, e, n) {
_transformCalled = true;
n();
}
-var _flushCalled = false;
+let _flushCalled = false;
function _flush(n) {
_flushCalled = true;
n();
}
-var t = new Transform({
+const t = new Transform({
transform: _transform,
flush: _flush
});
diff --git a/test/parallel/test-stream-transform-objectmode-falsey-value.js b/test/parallel/test-stream-transform-objectmode-falsey-value.js
index 5291a4b7fe89a0..4107bc1675421e 100644
--- a/test/parallel/test-stream-transform-objectmode-falsey-value.js
+++ b/test/parallel/test-stream-transform-objectmode-falsey-value.js
@@ -1,16 +1,16 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var stream = require('stream');
-var PassThrough = stream.PassThrough;
+const stream = require('stream');
+const PassThrough = stream.PassThrough;
-var src = new PassThrough({ objectMode: true });
-var tx = new PassThrough({ objectMode: true });
-var dest = new PassThrough({ objectMode: true });
+const src = new PassThrough({ objectMode: true });
+const tx = new PassThrough({ objectMode: true });
+const dest = new PassThrough({ objectMode: true });
-var expect = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
-var results = [];
+const expect = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
+const results = [];
process.on('exit', function() {
assert.deepStrictEqual(results, expect);
console.log('ok');
@@ -22,8 +22,8 @@ dest.on('data', function(x) {
src.pipe(tx).pipe(dest);
-var i = -1;
-var int = setInterval(function() {
+let i = -1;
+const int = setInterval(function() {
if (i > 10) {
src.end();
clearInterval(int);
diff --git a/test/parallel/test-stream-transform-split-objectmode.js b/test/parallel/test-stream-transform-split-objectmode.js
index 610f234bead901..52185e18711090 100644
--- a/test/parallel/test-stream-transform-split-objectmode.js
+++ b/test/parallel/test-stream-transform-split-objectmode.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var Transform = require('stream').Transform;
+const Transform = require('stream').Transform;
-var parser = new Transform({ readableObjectMode: true });
+const parser = new Transform({ readableObjectMode: true });
assert(parser._readableState.objectMode);
assert(!parser._writableState.objectMode);
@@ -15,7 +15,7 @@ parser._transform = function(chunk, enc, callback) {
callback(null, { val: chunk[0] });
};
-var parsed;
+let parsed;
parser.on('data', function(obj) {
parsed = obj;
@@ -28,7 +28,7 @@ process.on('exit', function() {
});
-var serializer = new Transform({ writableObjectMode: true });
+const serializer = new Transform({ writableObjectMode: true });
assert(!serializer._readableState.objectMode);
assert(serializer._writableState.objectMode);
@@ -39,7 +39,7 @@ serializer._transform = function(obj, _, callback) {
callback(null, Buffer.from([obj.val]));
};
-var serialized;
+let serialized;
serializer.on('data', function(chunk) {
serialized = chunk;
diff --git a/test/parallel/test-stream-unshift-empty-chunk.js b/test/parallel/test-stream-unshift-empty-chunk.js
index 477f5c4be56bac..d555fd7cae2330 100644
--- a/test/parallel/test-stream-unshift-empty-chunk.js
+++ b/test/parallel/test-stream-unshift-empty-chunk.js
@@ -1,14 +1,14 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// This test verifies that stream.unshift(Buffer.alloc(0)) or
// stream.unshift('') does not set state.reading=false.
-var Readable = require('stream').Readable;
+const Readable = require('stream').Readable;
-var r = new Readable();
-var nChunks = 10;
-var chunk = Buffer.alloc(10, 'x');
+const r = new Readable();
+let nChunks = 10;
+const chunk = Buffer.alloc(10, 'x');
r._read = function(n) {
setImmediate(function() {
@@ -16,10 +16,10 @@ r._read = function(n) {
});
};
-var readAll = false;
-var seen = [];
+let readAll = false;
+const seen = [];
r.on('readable', function() {
- var chunk;
+ let chunk;
while (chunk = r.read()) {
seen.push(chunk.toString());
// simulate only reading a certain amount of the data,
@@ -27,13 +27,13 @@ r.on('readable', function() {
// stream, like a parser might do. We just fill it with
// 'y' so that it's easy to see which bits were touched,
// and which were not.
- var putBack = Buffer.alloc(readAll ? 0 : 5, 'y');
+ const putBack = Buffer.alloc(readAll ? 0 : 5, 'y');
readAll = !readAll;
r.unshift(putBack);
}
});
-var expect =
+const expect =
[ 'xxxxxxxxxx',
'yyyyy',
'xxxxxxxxxx',
diff --git a/test/parallel/test-stream-wrap.js b/test/parallel/test-stream-wrap.js
index 69e4dee89d3b13..dbcb58a98cd8b2 100644
--- a/test/parallel/test-stream-wrap.js
+++ b/test/parallel/test-stream-wrap.js
@@ -7,16 +7,16 @@ const Duplex = require('stream').Duplex;
const ShutdownWrap = process.binding('stream_wrap').ShutdownWrap;
function testShutdown(callback) {
- var stream = new Duplex({
+ const stream = new Duplex({
read: function() {
},
write: function() {
}
});
- var wrap = new StreamWrap(stream);
+ const wrap = new StreamWrap(stream);
- var req = new ShutdownWrap();
+ const req = new ShutdownWrap();
req.oncomplete = function(code) {
assert(code < 0);
callback();
diff --git a/test/parallel/test-stream-writable-change-default-encoding.js b/test/parallel/test-stream-writable-change-default-encoding.js
index d1d4af5b824baf..9eac52bc1aea44 100644
--- a/test/parallel/test-stream-writable-change-default-encoding.js
+++ b/test/parallel/test-stream-writable-change-default-encoding.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var stream = require('stream');
-var util = require('util');
+const stream = require('stream');
+const util = require('util');
function MyWritable(fn, options) {
stream.Writable.call(this, options);
@@ -18,7 +18,7 @@ MyWritable.prototype._write = function(chunk, encoding, callback) {
};
(function defaultCondingIsUtf8() {
- var m = new MyWritable(function(isBuffer, type, enc) {
+ const m = new MyWritable(function(isBuffer, type, enc) {
assert.equal(enc, 'utf8');
}, { decodeStrings: false });
m.write('foo');
@@ -26,7 +26,7 @@ MyWritable.prototype._write = function(chunk, encoding, callback) {
}());
(function changeDefaultEncodingToAscii() {
- var m = new MyWritable(function(isBuffer, type, enc) {
+ const m = new MyWritable(function(isBuffer, type, enc) {
assert.equal(enc, 'ascii');
}, { decodeStrings: false });
m.setDefaultEncoding('ascii');
@@ -35,7 +35,7 @@ MyWritable.prototype._write = function(chunk, encoding, callback) {
}());
assert.throws(function changeDefaultEncodingToInvalidValue() {
- var m = new MyWritable(function(isBuffer, type, enc) {
+ const m = new MyWritable(function(isBuffer, type, enc) {
}, { decodeStrings: false });
m.setDefaultEncoding({});
m.write('bar');
@@ -43,7 +43,7 @@ assert.throws(function changeDefaultEncodingToInvalidValue() {
}, TypeError);
(function checkVairableCaseEncoding() {
- var m = new MyWritable(function(isBuffer, type, enc) {
+ const m = new MyWritable(function(isBuffer, type, enc) {
assert.equal(enc, 'ascii');
}, { decodeStrings: false });
m.setDefaultEncoding('AsCii');
diff --git a/test/parallel/test-stream-writable-constructor-set-methods.js b/test/parallel/test-stream-writable-constructor-set-methods.js
index 7d7dfb5f1ccfa0..9b344487f61580 100644
--- a/test/parallel/test-stream-writable-constructor-set-methods.js
+++ b/test/parallel/test-stream-writable-constructor-set-methods.js
@@ -1,25 +1,25 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var Writable = require('stream').Writable;
+const Writable = require('stream').Writable;
-var _writeCalled = false;
+let _writeCalled = false;
function _write(d, e, n) {
_writeCalled = true;
}
-var w = new Writable({ write: _write });
+const w = new Writable({ write: _write });
w.end(Buffer.from('blerg'));
-var _writevCalled = false;
-var dLength = 0;
+let _writevCalled = false;
+let dLength = 0;
function _writev(d, n) {
dLength = d.length;
_writevCalled = true;
}
-var w2 = new Writable({ writev: _writev });
+const w2 = new Writable({ writev: _writev });
w2.cork();
w2.write(Buffer.from('blerg'));
diff --git a/test/parallel/test-stream-writable-decoded-encoding.js b/test/parallel/test-stream-writable-decoded-encoding.js
index 621e342a3c2d74..4c903a0b012e3e 100644
--- a/test/parallel/test-stream-writable-decoded-encoding.js
+++ b/test/parallel/test-stream-writable-decoded-encoding.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var stream = require('stream');
-var util = require('util');
+const stream = require('stream');
+const util = require('util');
function MyWritable(fn, options) {
stream.Writable.call(this, options);
diff --git a/test/parallel/test-stream-writable-null.js b/test/parallel/test-stream-writable-null.js
index 2cc396bd916a3e..438f250a17dde6 100644
--- a/test/parallel/test-stream-writable-null.js
+++ b/test/parallel/test-stream-writable-null.js
@@ -17,11 +17,11 @@ MyWritable.prototype._write = function(chunk, encoding, callback) {
};
assert.throws(() => {
- var m = new MyWritable({objectMode: true});
+ const m = new MyWritable({objectMode: true});
m.write(null, (err) => assert.ok(err));
}, TypeError, 'May not write null values to stream');
assert.doesNotThrow(() => {
- var m = new MyWritable({objectMode: true}).on('error', (e) => {
+ const m = new MyWritable({objectMode: true}).on('error', (e) => {
assert.ok(e);
});
m.write(null, (err) => {
@@ -30,11 +30,11 @@ assert.doesNotThrow(() => {
});
assert.throws(() => {
- var m = new MyWritable();
+ const m = new MyWritable();
m.write(false, (err) => assert.ok(err));
}, TypeError, 'Invalid non-string/buffer chunk');
assert.doesNotThrow(() => {
- var m = new MyWritable().on('error', (e) => {
+ const m = new MyWritable().on('error', (e) => {
assert.ok(e);
});
m.write(false, (err) => {
@@ -43,11 +43,11 @@ assert.doesNotThrow(() => {
});
assert.doesNotThrow(() => {
- var m = new MyWritable({objectMode: true});
+ const m = new MyWritable({objectMode: true});
m.write(false, (err) => assert.ifError(err));
});
assert.doesNotThrow(() => {
- var m = new MyWritable({objectMode: true}).on('error', (e) => {
+ const m = new MyWritable({objectMode: true}).on('error', (e) => {
assert.ifError(e || new Error('should not get here'));
});
m.write(false, (err) => {
diff --git a/test/parallel/test-stream-writev.js b/test/parallel/test-stream-writev.js
index 92479fc88f2958..91c064c102b490 100644
--- a/test/parallel/test-stream-writev.js
+++ b/test/parallel/test-stream-writev.js
@@ -1,13 +1,13 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var stream = require('stream');
+const stream = require('stream');
-var queue = [];
-for (var decode = 0; decode < 2; decode++) {
- for (var uncork = 0; uncork < 2; uncork++) {
- for (var multi = 0; multi < 2; multi++) {
+const queue = [];
+for (let decode = 0; decode < 2; decode++) {
+ for (let uncork = 0; uncork < 2; uncork++) {
+ for (let multi = 0; multi < 2; multi++) {
queue.push([!!decode, !!uncork, !!multi]);
}
}
@@ -16,7 +16,7 @@ for (var decode = 0; decode < 2; decode++) {
run();
function run() {
- var t = queue.pop();
+ const t = queue.pop();
if (t)
test(t[0], t[1], t[2], run);
else
@@ -25,11 +25,11 @@ function run() {
function test(decode, uncork, multi, next) {
console.log('# decode=%j uncork=%j multi=%j', decode, uncork, multi);
- var counter = 0;
- var expectCount = 0;
+ let counter = 0;
+ let expectCount = 0;
function cnt(msg) {
expectCount++;
- var expect = expectCount;
+ const expect = expectCount;
return function(er) {
if (er)
throw er;
@@ -38,12 +38,12 @@ function test(decode, uncork, multi, next) {
};
}
- var w = new stream.Writable({ decodeStrings: decode });
+ const w = new stream.Writable({ decodeStrings: decode });
w._write = function(chunk, e, cb) {
assert(false, 'Should not call _write');
};
- var expectChunks = decode ? [
+ const expectChunks = decode ? [
{ encoding: 'buffer',
chunk: [104, 101, 108, 108, 111, 44, 32] },
{ encoding: 'buffer',
@@ -62,7 +62,7 @@ function test(decode, uncork, multi, next) {
{ encoding: 'hex', chunk: 'facebea7deadbeefdecafbad' }
];
- var actualChunks;
+ let actualChunks;
w._writev = function(chunks, cb) {
actualChunks = chunks.map(function(chunk) {
return {
diff --git a/test/parallel/test-stream2-base64-single-char-read-end.js b/test/parallel/test-stream2-base64-single-char-read-end.js
index 50bafc3737385d..1b14b7f6b4517c 100644
--- a/test/parallel/test-stream2-base64-single-char-read-end.js
+++ b/test/parallel/test-stream2-base64-single-char-read-end.js
@@ -1,14 +1,14 @@
'use strict';
const common = require('../common');
-var R = require('_stream_readable');
-var W = require('_stream_writable');
-var assert = require('assert');
+const R = require('_stream_readable');
+const W = require('_stream_writable');
+const assert = require('assert');
-var src = new R({encoding: 'base64'});
-var dst = new W();
-var hasRead = false;
-var accum = [];
-var timeout;
+const src = new R({encoding: 'base64'});
+const dst = new W();
+let hasRead = false;
+const accum = [];
+let timeout;
src._read = function(n) {
if (!hasRead) {
diff --git a/test/parallel/test-stream2-compatibility.js b/test/parallel/test-stream2-compatibility.js
index 77312456590b25..f7c980791311da 100644
--- a/test/parallel/test-stream2-compatibility.js
+++ b/test/parallel/test-stream2-compatibility.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var R = require('_stream_readable');
-var W = require('_stream_writable');
-var assert = require('assert');
+const R = require('_stream_readable');
+const W = require('_stream_writable');
+const assert = require('assert');
-var util = require('util');
+const util = require('util');
-var ondataCalled = 0;
+let ondataCalled = 0;
function TestReader() {
R.apply(this);
@@ -24,7 +24,7 @@ TestReader.prototype._read = function(n) {
this._buffer = Buffer.alloc(0);
};
-var reader = new TestReader();
+const reader = new TestReader();
setImmediate(function() {
assert.equal(ondataCalled, 1);
console.log('ok');
@@ -43,7 +43,7 @@ TestWriter.prototype._write = function(chunk, enc, cb) {
cb();
};
-var writer = new TestWriter();
+const writer = new TestWriter();
process.on('exit', function() {
assert.strictEqual(reader.readable, false);
diff --git a/test/parallel/test-stream2-decode-partial.js b/test/parallel/test-stream2-decode-partial.js
index b58e192b9c33bb..b43101dbc84c3a 100644
--- a/test/parallel/test-stream2-decode-partial.js
+++ b/test/parallel/test-stream2-decode-partial.js
@@ -3,7 +3,7 @@ require('../common');
const Readable = require('_stream_readable');
const assert = require('assert');
-var buf = '';
+let buf = '';
const euro = new Buffer([0xE2, 0x82, 0xAC]);
const cent = new Buffer([0xC2, 0xA2]);
const source = Buffer.concat([euro, cent]);
diff --git a/test/parallel/test-stream2-finish-pipe.js b/test/parallel/test-stream2-finish-pipe.js
index fb489978f498ad..87edf5a5fa6437 100644
--- a/test/parallel/test-stream2-finish-pipe.js
+++ b/test/parallel/test-stream2-finish-pipe.js
@@ -1,14 +1,14 @@
'use strict';
require('../common');
-var stream = require('stream');
-var Buffer = require('buffer').Buffer;
+const stream = require('stream');
+const Buffer = require('buffer').Buffer;
-var r = new stream.Readable();
+const r = new stream.Readable();
r._read = function(size) {
r.push(Buffer.allocUnsafe(size));
};
-var w = new stream.Writable();
+const w = new stream.Writable();
w._write = function(data, encoding, cb) {
cb(null);
};
diff --git a/test/parallel/test-stream2-httpclient-response-end.js b/test/parallel/test-stream2-httpclient-response-end.js
index d674086055e431..6d3da191b06cb9 100644
--- a/test/parallel/test-stream2-httpclient-response-end.js
+++ b/test/parallel/test-stream2-httpclient-response-end.js
@@ -1,14 +1,14 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var msg = 'Hello';
-var server = http.createServer(function(req, res) {
+const assert = require('assert');
+const http = require('http');
+const msg = 'Hello';
+const server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(msg);
}).listen(0, function() {
http.get({port: this.address().port}, function(res) {
- var data = '';
+ let data = '';
res.on('readable', common.mustCall(function() {
console.log('readable event');
data += res.read();
diff --git a/test/parallel/test-stream2-large-read-stall.js b/test/parallel/test-stream2-large-read-stall.js
index 91eb716cfa8e2a..2422747f820bc1 100644
--- a/test/parallel/test-stream2-large-read-stall.js
+++ b/test/parallel/test-stream2-large-read-stall.js
@@ -1,28 +1,29 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
// If everything aligns so that you do a read(n) of exactly the
// remaining buffer, then make sure that 'end' still emits.
-var READSIZE = 100;
-var PUSHSIZE = 20;
-var PUSHCOUNT = 1000;
-var HWM = 50;
+const READSIZE = 100;
+const PUSHSIZE = 20;
+const PUSHCOUNT = 1000;
+const HWM = 50;
-var Readable = require('stream').Readable;
-var r = new Readable({
+const Readable = require('stream').Readable;
+const r = new Readable({
highWaterMark: HWM
});
-var rs = r._readableState;
+const rs = r._readableState;
r._read = push;
r.on('readable', function() {
console.error('>> readable');
+ let ret;
do {
console.error(' > read(%d)', READSIZE);
- var ret = r.read(READSIZE);
+ ret = r.read(READSIZE);
console.error(' < %j (%d remain)', ret && ret.length, rs.length);
} while (ret && ret.length === READSIZE);
@@ -36,7 +37,7 @@ r.on('end', common.mustCall(function() {
assert.strictEqual(pushes, PUSHCOUNT + 1);
}));
-var pushes = 0;
+let pushes = 0;
function push() {
if (pushes > PUSHCOUNT)
return;
diff --git a/test/parallel/test-stream2-objects.js b/test/parallel/test-stream2-objects.js
index b18be26dc530fb..6c00f1b8691364 100644
--- a/test/parallel/test-stream2-objects.js
+++ b/test/parallel/test-stream2-objects.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var Readable = require('_stream_readable');
-var Writable = require('_stream_writable');
-var assert = require('assert');
+const Readable = require('_stream_readable');
+const Writable = require('_stream_writable');
+const assert = require('assert');
// tiny node-tap lookalike.
-var tests = [];
-var count = 0;
+const tests = [];
+let count = 0;
function test(name, fn) {
count++;
@@ -14,12 +14,12 @@ function test(name, fn) {
}
function run() {
- var next = tests.shift();
+ const next = tests.shift();
if (!next)
return console.error('ok');
- var name = next[0];
- var fn = next[1];
+ const name = next[0];
+ const fn = next[1];
console.log('# %s', name);
fn({
same: assert.deepStrictEqual,
@@ -39,8 +39,8 @@ process.on('exit', function() {
process.nextTick(run);
function toArray(callback) {
- var stream = new Writable({ objectMode: true });
- var list = [];
+ const stream = new Writable({ objectMode: true });
+ const list = [];
stream.write = function(chunk) {
list.push(chunk);
};
@@ -53,7 +53,7 @@ function toArray(callback) {
}
function fromArray(list) {
- var r = new Readable({ objectMode: true });
+ const r = new Readable({ objectMode: true });
r._read = noop;
list.forEach(function(chunk) {
r.push(chunk);
@@ -66,11 +66,11 @@ function fromArray(list) {
function noop() {}
test('can read objects from stream', function(t) {
- var r = fromArray([{ one: '1'}, { two: '2' }]);
+ const r = fromArray([{ one: '1'}, { two: '2' }]);
- var v1 = r.read();
- var v2 = r.read();
- var v3 = r.read();
+ const v1 = r.read();
+ const v2 = r.read();
+ const v3 = r.read();
assert.deepStrictEqual(v1, { one: '1' });
assert.deepStrictEqual(v2, { two: '2' });
@@ -80,7 +80,7 @@ test('can read objects from stream', function(t) {
});
test('can pipe objects into stream', function(t) {
- var r = fromArray([{ one: '1'}, { two: '2' }]);
+ const r = fromArray([{ one: '1'}, { two: '2' }]);
r.pipe(toArray(function(list) {
assert.deepStrictEqual(list, [
@@ -93,9 +93,9 @@ test('can pipe objects into stream', function(t) {
});
test('read(n) is ignored', function(t) {
- var r = fromArray([{ one: '1'}, { two: '2' }]);
+ const r = fromArray([{ one: '1'}, { two: '2' }]);
- var value = r.read(2);
+ const value = r.read(2);
assert.deepStrictEqual(value, { one: '1' });
@@ -103,10 +103,10 @@ test('read(n) is ignored', function(t) {
});
test('can read objects from _read (sync)', function(t) {
- var r = new Readable({ objectMode: true });
- var list = [{ one: '1'}, { two: '2' }];
+ const r = new Readable({ objectMode: true });
+ const list = [{ one: '1'}, { two: '2' }];
r._read = function(n) {
- var item = list.shift();
+ const item = list.shift();
r.push(item || null);
};
@@ -121,10 +121,10 @@ test('can read objects from _read (sync)', function(t) {
});
test('can read objects from _read (async)', function(t) {
- var r = new Readable({ objectMode: true });
- var list = [{ one: '1'}, { two: '2' }];
+ const r = new Readable({ objectMode: true });
+ const list = [{ one: '1'}, { two: '2' }];
r._read = function(n) {
- var item = list.shift();
+ const item = list.shift();
process.nextTick(function() {
r.push(item || null);
});
@@ -141,11 +141,11 @@ test('can read objects from _read (async)', function(t) {
});
test('can read strings as objects', function(t) {
- var r = new Readable({
+ const r = new Readable({
objectMode: true
});
r._read = noop;
- var list = ['one', 'two', 'three'];
+ const list = ['one', 'two', 'three'];
list.forEach(function(str) {
r.push(str);
});
@@ -159,7 +159,7 @@ test('can read strings as objects', function(t) {
});
test('read(0) for object streams', function(t) {
- var r = new Readable({
+ const r = new Readable({
objectMode: true
});
r._read = noop;
@@ -175,7 +175,7 @@ test('read(0) for object streams', function(t) {
});
test('falsey values', function(t) {
- var r = new Readable({
+ const r = new Readable({
objectMode: true
});
r._read = noop;
@@ -193,12 +193,12 @@ test('falsey values', function(t) {
});
test('high watermark _read', function(t) {
- var r = new Readable({
+ const r = new Readable({
highWaterMark: 6,
objectMode: true
});
- var calls = 0;
- var list = ['1', '2', '3', '4', '5', '6', '7', '8'];
+ let calls = 0;
+ const list = ['1', '2', '3', '4', '5', '6', '7', '8'];
r._read = function(n) {
calls++;
@@ -208,15 +208,15 @@ test('high watermark _read', function(t) {
r.push(c);
});
- var v = r.read();
+ const v = r.read();
assert.strictEqual(calls, 0);
assert.strictEqual(v, '1');
- var v2 = r.read();
+ const v2 = r.read();
assert.strictEqual(v2, '2');
- var v3 = r.read();
+ const v3 = r.read();
assert.strictEqual(v3, '3');
assert.strictEqual(calls, 1);
@@ -225,13 +225,13 @@ test('high watermark _read', function(t) {
});
test('high watermark push', function(t) {
- var r = new Readable({
+ const r = new Readable({
highWaterMark: 6,
objectMode: true
});
r._read = function(n) {};
- for (var i = 0; i < 6; i++) {
- var bool = r.push(i);
+ for (let i = 0; i < 6; i++) {
+ const bool = r.push(i);
assert.strictEqual(bool, i !== 5);
}
@@ -239,7 +239,7 @@ test('high watermark push', function(t) {
});
test('can write objects to stream', function(t) {
- var w = new Writable({ objectMode: true });
+ const w = new Writable({ objectMode: true });
w._write = function(chunk, encoding, cb) {
assert.deepStrictEqual(chunk, { foo: 'bar' });
@@ -255,8 +255,8 @@ test('can write objects to stream', function(t) {
});
test('can write multiple objects to stream', function(t) {
- var w = new Writable({ objectMode: true });
- var list = [];
+ const w = new Writable({ objectMode: true });
+ const list = [];
w._write = function(chunk, encoding, cb) {
list.push(chunk);
@@ -278,10 +278,10 @@ test('can write multiple objects to stream', function(t) {
});
test('can write strings as objects', function(t) {
- var w = new Writable({
+ const w = new Writable({
objectMode: true
});
- var list = [];
+ const list = [];
w._write = function(chunk, encoding, cb) {
list.push(chunk);
@@ -303,10 +303,10 @@ test('can write strings as objects', function(t) {
});
test('buffers finish until cb is called', function(t) {
- var w = new Writable({
+ const w = new Writable({
objectMode: true
});
- var called = false;
+ let called = false;
w._write = function(chunk, encoding, cb) {
assert.strictEqual(chunk, 'foo');
diff --git a/test/parallel/test-stream2-pipe-error-handling.js b/test/parallel/test-stream2-pipe-error-handling.js
index bdf7a4a9a33a77..cdd1b1a364e183 100644
--- a/test/parallel/test-stream2-pipe-error-handling.js
+++ b/test/parallel/test-stream2-pipe-error-handling.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var stream = require('stream');
+const assert = require('assert');
+const stream = require('stream');
{
let count = 1000;
diff --git a/test/parallel/test-stream2-pipe-error-once-listener.js b/test/parallel/test-stream2-pipe-error-once-listener.js
index c9cfd1d1c80c19..908ac1bdb8e4ab 100644
--- a/test/parallel/test-stream2-pipe-error-once-listener.js
+++ b/test/parallel/test-stream2-pipe-error-once-listener.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var util = require('util');
-var stream = require('stream');
+const util = require('util');
+const stream = require('stream');
-var Read = function() {
+const Read = function() {
stream.Readable.call(this);
};
util.inherits(Read, stream.Readable);
@@ -16,7 +16,7 @@ Read.prototype._read = function(size) {
};
-var Write = function() {
+const Write = function() {
stream.Writable.call(this);
};
util.inherits(Write, stream.Writable);
@@ -26,8 +26,8 @@ Write.prototype._write = function(buffer, encoding, cb) {
this.emit('alldone');
};
-var read = new Read();
-var write = new Write();
+const read = new Read();
+const write = new Write();
write.once('error', function(err) {});
write.once('alldone', function(err) {
diff --git a/test/parallel/test-stream2-push.js b/test/parallel/test-stream2-push.js
index 445a186715b659..80315f2fb3f0cb 100644
--- a/test/parallel/test-stream2-push.js
+++ b/test/parallel/test-stream2-push.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var stream = require('stream');
-var Readable = stream.Readable;
-var Writable = stream.Writable;
-var assert = require('assert');
+let stream = require('stream');
+const Readable = stream.Readable;
+const Writable = stream.Writable;
+const assert = require('assert');
-var EE = require('events').EventEmitter;
+const EE = require('events').EventEmitter;
// a mock thing a bit like the net.Socket/tcp_wrap.handle interaction
@@ -15,20 +15,20 @@ stream = new Readable({
encoding: 'utf8'
});
-var source = new EE();
+const source = new EE();
stream._read = function() {
console.error('stream._read');
readStart();
};
-var ended = false;
+let ended = false;
stream.on('end', function() {
ended = true;
});
source.on('data', function(chunk) {
- var ret = stream.push(chunk);
+ const ret = stream.push(chunk);
console.error('data', stream._readableState.length);
if (!ret)
readStop();
@@ -38,7 +38,7 @@ source.on('end', function() {
stream.push(null);
});
-var reading = false;
+let reading = false;
function readStart() {
console.error('readStart');
@@ -49,19 +49,19 @@ function readStop() {
console.error('readStop');
reading = false;
process.nextTick(function() {
- var r = stream.read();
+ const r = stream.read();
if (r !== null)
writer.write(r);
});
}
-var writer = new Writable({
+let writer = new Writable({
decodeStrings: false
});
-var written = [];
+const written = [];
-var expectWritten =
+const expectWritten =
[ 'asdfgasdfgasdfgasdfg',
'asdfgasdfgasdfgasdfg',
'asdfgasdfgasdfgasdfg',
@@ -80,9 +80,9 @@ writer.on('finish', finish);
// now emit some chunks.
-var chunk = 'asdfg';
+const chunk = 'asdfg';
-var set = 0;
+let set = 0;
readStart();
data();
function data() {
diff --git a/test/parallel/test-stream2-read-sync-stack.js b/test/parallel/test-stream2-read-sync-stack.js
index b2cfd05f872e30..d4e11af3b8f7c1 100644
--- a/test/parallel/test-stream2-read-sync-stack.js
+++ b/test/parallel/test-stream2-read-sync-stack.js
@@ -1,16 +1,16 @@
'use strict';
const common = require('../common');
-var Readable = require('stream').Readable;
-var r = new Readable();
-var N = 256 * 1024;
+const Readable = require('stream').Readable;
+const r = new Readable();
+const N = 256 * 1024;
// Go ahead and allow the pathological case for this test.
// Yes, it's an infinite loop, that's the point.
process.maxTickDepth = N + 2;
-var reads = 0;
+let reads = 0;
r._read = function(n) {
- var chunk = reads++ === N ? null : Buffer.allocUnsafe(1);
+ const chunk = reads++ === N ? null : Buffer.allocUnsafe(1);
r.push(chunk);
};
diff --git a/test/parallel/test-stream2-readable-empty-buffer-no-eof.js b/test/parallel/test-stream2-readable-empty-buffer-no-eof.js
index ccbf087df00bf5..71d6f1e7236db2 100644
--- a/test/parallel/test-stream2-readable-empty-buffer-no-eof.js
+++ b/test/parallel/test-stream2-readable-empty-buffer-no-eof.js
@@ -69,8 +69,8 @@ function test1() {
}
function test2() {
- var r = new Readable({ encoding: 'base64' });
- var reads = 5;
+ const r = new Readable({ encoding: 'base64' });
+ let reads = 5;
r._read = function(n) {
if (!reads--)
return r.push(null); // EOF
@@ -78,9 +78,9 @@ function test2() {
return r.push(Buffer.from('x'));
};
- var results = [];
+ const results = [];
function flow() {
- var chunk;
+ let chunk;
while (null !== (chunk = r.read()))
results.push(chunk + '');
}
diff --git a/test/parallel/test-stream2-readable-from-list.js b/test/parallel/test-stream2-readable-from-list.js
index 2aa0725f734117..f3f39507e89dab 100644
--- a/test/parallel/test-stream2-readable-from-list.js
+++ b/test/parallel/test-stream2-readable-from-list.js
@@ -1,13 +1,13 @@
// Flags: --expose_internals
'use strict';
require('../common');
-var assert = require('assert');
-var fromList = require('_stream_readable')._fromList;
-var BufferList = require('internal/streams/BufferList');
+const assert = require('assert');
+const fromList = require('_stream_readable')._fromList;
+const BufferList = require('internal/streams/BufferList');
// tiny node-tap lookalike.
-var tests = [];
-var count = 0;
+const tests = [];
+let count = 0;
function test(name, fn) {
count++;
@@ -15,12 +15,12 @@ function test(name, fn) {
}
function run() {
- var next = tests.shift();
+ const next = tests.shift();
if (!next)
return console.error('ok');
- var name = next[0];
- var fn = next[1];
+ const name = next[0];
+ const fn = next[1];
console.log('# %s', name);
fn({
same: assert.deepStrictEqual,
@@ -34,7 +34,7 @@ function run() {
function bufferListFromArray(arr) {
const bl = new BufferList();
- for (var i = 0; i < arr.length; ++i)
+ for (let i = 0; i < arr.length; ++i)
bl.push(arr[i]);
return bl;
}
@@ -48,14 +48,14 @@ process.nextTick(run);
test('buffers', function(t) {
- var list = [ Buffer.from('foog'),
+ let list = [ Buffer.from('foog'),
Buffer.from('bark'),
Buffer.from('bazy'),
Buffer.from('kuel') ];
list = bufferListFromArray(list);
// read more than the first element.
- var ret = fromList(6, { buffer: list, length: 16 });
+ let ret = fromList(6, { buffer: list, length: 16 });
t.equal(ret.toString(), 'foogba');
// read exactly the first element.
@@ -77,14 +77,14 @@ test('buffers', function(t) {
});
test('strings', function(t) {
- var list = [ 'foog',
+ let list = [ 'foog',
'bark',
'bazy',
'kuel' ];
list = bufferListFromArray(list);
// read more than the first element.
- var ret = fromList(6, { buffer: list, length: 16, decoder: true });
+ let ret = fromList(6, { buffer: list, length: 16, decoder: true });
t.equal(ret, 'foogba');
// read exactly the first element.
diff --git a/test/parallel/test-stream2-readable-legacy-drain.js b/test/parallel/test-stream2-readable-legacy-drain.js
index 8a0687a6ebd90c..d6db6ba232c693 100644
--- a/test/parallel/test-stream2-readable-legacy-drain.js
+++ b/test/parallel/test-stream2-readable-legacy-drain.js
@@ -1,22 +1,22 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var Stream = require('stream');
-var Readable = Stream.Readable;
+const Stream = require('stream');
+const Readable = Stream.Readable;
-var r = new Readable();
-var N = 256;
-var reads = 0;
+const r = new Readable();
+const N = 256;
+let reads = 0;
r._read = function(n) {
return r.push(++reads === N ? null : Buffer.allocUnsafe(1));
};
r.on('end', common.mustCall(function() {}));
-var w = new Stream();
+const w = new Stream();
w.writable = true;
-var buffered = 0;
+let buffered = 0;
w.write = function(c) {
buffered += c.length;
process.nextTick(drain);
diff --git a/test/parallel/test-stream2-readable-non-empty-end.js b/test/parallel/test-stream2-readable-non-empty-end.js
index dd2cb8d51055c7..66fae8274ecf3c 100644
--- a/test/parallel/test-stream2-readable-non-empty-end.js
+++ b/test/parallel/test-stream2-readable-non-empty-end.js
@@ -1,19 +1,19 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var Readable = require('_stream_readable');
+const assert = require('assert');
+const Readable = require('_stream_readable');
-var len = 0;
-var chunks = new Array(10);
-for (var i = 1; i <= 10; i++) {
+let len = 0;
+const chunks = new Array(10);
+for (let i = 1; i <= 10; i++) {
chunks[i - 1] = Buffer.allocUnsafe(i);
len += i;
}
-var test = new Readable();
-var n = 0;
+const test = new Readable();
+let n = 0;
test._read = function(size) {
- var chunk = chunks[n++];
+ const chunk = chunks[n++];
setTimeout(function() {
test.push(chunk === undefined ? null : chunk);
}, 1);
@@ -24,10 +24,10 @@ function thrower() {
throw new Error('this should not happen!');
}
-var bytesread = 0;
+let bytesread = 0;
test.on('readable', function() {
- var b = len - bytesread - 1;
- var res = test.read(b);
+ const b = len - bytesread - 1;
+ const res = test.read(b);
if (res) {
bytesread += res.length;
console.error('br=%d len=%d', bytesread, len);
@@ -43,7 +43,7 @@ function next() {
test.on('end', common.mustCall(function() {}));
// one to get the last byte
- var r = test.read();
+ let r = test.read();
assert(r);
assert.equal(r.length, 1);
r = test.read();
diff --git a/test/parallel/test-stream2-readable-wrap-empty.js b/test/parallel/test-stream2-readable-wrap-empty.js
index 02de3cf5b4cb23..5b2dae3c5327fa 100644
--- a/test/parallel/test-stream2-readable-wrap-empty.js
+++ b/test/parallel/test-stream2-readable-wrap-empty.js
@@ -1,14 +1,14 @@
'use strict';
const common = require('../common');
-var Readable = require('_stream_readable');
-var EE = require('events').EventEmitter;
+const Readable = require('_stream_readable');
+const EE = require('events').EventEmitter;
-var oldStream = new EE();
+const oldStream = new EE();
oldStream.pause = function() {};
oldStream.resume = function() {};
-var newStream = new Readable().wrap(oldStream);
+const newStream = new Readable().wrap(oldStream);
newStream
.on('readable', function() {})
diff --git a/test/parallel/test-stream2-readable-wrap.js b/test/parallel/test-stream2-readable-wrap.js
index 3bbd5ef0809dcd..4c736c6f369514 100644
--- a/test/parallel/test-stream2-readable-wrap.js
+++ b/test/parallel/test-stream2-readable-wrap.js
@@ -1,21 +1,21 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var Readable = require('_stream_readable');
-var Writable = require('_stream_writable');
-var EE = require('events').EventEmitter;
+const Readable = require('_stream_readable');
+const Writable = require('_stream_writable');
+const EE = require('events').EventEmitter;
-var testRuns = 0, completedRuns = 0;
+let testRuns = 0, completedRuns = 0;
function runTest(highWaterMark, objectMode, produce) {
testRuns++;
- var old = new EE();
- var r = new Readable({ highWaterMark: highWaterMark,
- objectMode: objectMode });
+ const old = new EE();
+ const r = new Readable({ highWaterMark: highWaterMark,
+ objectMode: objectMode });
assert.equal(r, r.wrap(old));
- var ended = false;
+ let ended = false;
r.on('end', function() {
ended = true;
});
@@ -32,14 +32,14 @@ function runTest(highWaterMark, objectMode, produce) {
flow();
};
- var flowing;
- var chunks = 10;
- var oldEnded = false;
- var expected = [];
+ let flowing;
+ let chunks = 10;
+ let oldEnded = false;
+ const expected = [];
function flow() {
flowing = true;
while (flowing && chunks-- > 0) {
- var item = produce();
+ const item = produce();
expected.push(item);
console.log('old.emit', chunks, flowing);
old.emit('data', item);
@@ -52,9 +52,9 @@ function runTest(highWaterMark, objectMode, produce) {
}
}
- var w = new Writable({ highWaterMark: highWaterMark * 2,
- objectMode: objectMode });
- var written = [];
+ const w = new Writable({ highWaterMark: highWaterMark * 2,
+ objectMode: objectMode });
+ const written = [];
w._write = function(chunk, encoding, cb) {
console.log('_write', chunk);
written.push(chunk);
@@ -81,7 +81,7 @@ runTest(100, false, function() { return Buffer.allocUnsafe(100); });
runTest(10, false, function() { return Buffer.from('xxxxxxxxxx'); });
runTest(1, true, function() { return { foo: 'bar' }; });
-var objectChunks = [ 5, 'a', false, 0, '', 'xyz', { x: 4 }, 7, [], 555 ];
+const objectChunks = [ 5, 'a', false, 0, '', 'xyz', { x: 4 }, 7, [], 555 ];
runTest(1, true, function() { return objectChunks.shift(); });
process.on('exit', function() {
diff --git a/test/parallel/test-stream2-set-encoding.js b/test/parallel/test-stream2-set-encoding.js
index 3deb67d48e7156..fdbd81e61332b1 100644
--- a/test/parallel/test-stream2-set-encoding.js
+++ b/test/parallel/test-stream2-set-encoding.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
-var R = require('_stream_readable');
-var util = require('util');
+const assert = require('assert');
+const R = require('_stream_readable');
+const util = require('util');
// tiny node-tap lookalike.
-var tests = [];
-var count = 0;
+const tests = [];
+let count = 0;
function test(name, fn) {
count++;
@@ -14,12 +14,12 @@ function test(name, fn) {
}
function run() {
- var next = tests.shift();
+ const next = tests.shift();
if (!next)
return console.error('ok');
- var name = next[0];
- var fn = next[1];
+ const name = next[0];
+ const fn = next[1];
console.log('# %s', name);
fn({
same: assert.deepStrictEqual,
@@ -66,7 +66,7 @@ TestReader.prototype._read = function(n) {
}
this.pos += n;
- var ret = Buffer.alloc(n, 'a');
+ const ret = Buffer.alloc(n, 'a');
console.log('this.push(ret)', ret);
@@ -75,10 +75,10 @@ TestReader.prototype._read = function(n) {
};
test('setEncoding utf8', function(t) {
- var tr = new TestReader(100);
+ const tr = new TestReader(100);
tr.setEncoding('utf8');
- var out = [];
- var expect =
+ const out = [];
+ const expect =
[ 'aaaaaaaaaa',
'aaaaaaaaaa',
'aaaaaaaaaa',
@@ -91,7 +91,7 @@ test('setEncoding utf8', function(t) {
'aaaaaaaaaa' ];
tr.on('readable', function flow() {
- var chunk;
+ let chunk;
while (null !== (chunk = tr.read(10)))
out.push(chunk);
});
@@ -104,10 +104,10 @@ test('setEncoding utf8', function(t) {
test('setEncoding hex', function(t) {
- var tr = new TestReader(100);
+ const tr = new TestReader(100);
tr.setEncoding('hex');
- var out = [];
- var expect =
+ const out = [];
+ const expect =
[ '6161616161',
'6161616161',
'6161616161',
@@ -130,7 +130,7 @@ test('setEncoding hex', function(t) {
'6161616161' ];
tr.on('readable', function flow() {
- var chunk;
+ let chunk;
while (null !== (chunk = tr.read(10)))
out.push(chunk);
});
@@ -142,10 +142,10 @@ test('setEncoding hex', function(t) {
});
test('setEncoding hex with read(13)', function(t) {
- var tr = new TestReader(100);
+ const tr = new TestReader(100);
tr.setEncoding('hex');
- var out = [];
- var expect =
+ const out = [];
+ const expect =
[ '6161616161616',
'1616161616161',
'6161616161616',
@@ -165,7 +165,7 @@ test('setEncoding hex with read(13)', function(t) {
tr.on('readable', function flow() {
console.log('readable once');
- var chunk;
+ let chunk;
while (null !== (chunk = tr.read(13)))
out.push(chunk);
});
@@ -178,10 +178,10 @@ test('setEncoding hex with read(13)', function(t) {
});
test('setEncoding base64', function(t) {
- var tr = new TestReader(100);
+ const tr = new TestReader(100);
tr.setEncoding('base64');
- var out = [];
- var expect =
+ const out = [];
+ const expect =
[ 'YWFhYWFhYW',
'FhYWFhYWFh',
'YWFhYWFhYW',
@@ -198,7 +198,7 @@ test('setEncoding base64', function(t) {
'FhYQ==' ];
tr.on('readable', function flow() {
- var chunk;
+ let chunk;
while (null !== (chunk = tr.read(10)))
out.push(chunk);
});
@@ -210,9 +210,9 @@ test('setEncoding base64', function(t) {
});
test('encoding: utf8', function(t) {
- var tr = new TestReader(100, { encoding: 'utf8' });
- var out = [];
- var expect =
+ const tr = new TestReader(100, { encoding: 'utf8' });
+ const out = [];
+ const expect =
[ 'aaaaaaaaaa',
'aaaaaaaaaa',
'aaaaaaaaaa',
@@ -225,7 +225,7 @@ test('encoding: utf8', function(t) {
'aaaaaaaaaa' ];
tr.on('readable', function flow() {
- var chunk;
+ let chunk;
while (null !== (chunk = tr.read(10)))
out.push(chunk);
});
@@ -238,9 +238,9 @@ test('encoding: utf8', function(t) {
test('encoding: hex', function(t) {
- var tr = new TestReader(100, { encoding: 'hex' });
- var out = [];
- var expect =
+ const tr = new TestReader(100, { encoding: 'hex' });
+ const out = [];
+ const expect =
[ '6161616161',
'6161616161',
'6161616161',
@@ -263,7 +263,7 @@ test('encoding: hex', function(t) {
'6161616161' ];
tr.on('readable', function flow() {
- var chunk;
+ let chunk;
while (null !== (chunk = tr.read(10)))
out.push(chunk);
});
@@ -275,9 +275,9 @@ test('encoding: hex', function(t) {
});
test('encoding: hex with read(13)', function(t) {
- var tr = new TestReader(100, { encoding: 'hex' });
- var out = [];
- var expect =
+ const tr = new TestReader(100, { encoding: 'hex' });
+ const out = [];
+ const expect =
[ '6161616161616',
'1616161616161',
'6161616161616',
@@ -296,7 +296,7 @@ test('encoding: hex with read(13)', function(t) {
'16161' ];
tr.on('readable', function flow() {
- var chunk;
+ let chunk;
while (null !== (chunk = tr.read(13)))
out.push(chunk);
});
@@ -308,9 +308,9 @@ test('encoding: hex with read(13)', function(t) {
});
test('encoding: base64', function(t) {
- var tr = new TestReader(100, { encoding: 'base64' });
- var out = [];
- var expect =
+ const tr = new TestReader(100, { encoding: 'base64' });
+ const out = [];
+ const expect =
[ 'YWFhYWFhYW',
'FhYWFhYWFh',
'YWFhYWFhYW',
@@ -327,7 +327,7 @@ test('encoding: base64', function(t) {
'FhYQ==' ];
tr.on('readable', function flow() {
- var chunk;
+ let chunk;
while (null !== (chunk = tr.read(10)))
out.push(chunk);
});
@@ -339,7 +339,7 @@ test('encoding: base64', function(t) {
});
test('chainable', function(t) {
- var tr = new TestReader(100);
+ const tr = new TestReader(100);
t.equal(tr.setEncoding('utf8'), tr);
t.end();
});
diff --git a/test/parallel/test-stream2-transform.js b/test/parallel/test-stream2-transform.js
index 6a4036681f90b7..d66f1f064375e4 100644
--- a/test/parallel/test-stream2-transform.js
+++ b/test/parallel/test-stream2-transform.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
-var PassThrough = require('_stream_passthrough');
-var Transform = require('_stream_transform');
+const assert = require('assert');
+const PassThrough = require('_stream_passthrough');
+const Transform = require('_stream_transform');
// tiny node-tap lookalike.
-var tests = [];
-var count = 0;
+const tests = [];
+let count = 0;
function test(name, fn) {
count++;
@@ -14,12 +14,12 @@ function test(name, fn) {
}
function run() {
- var next = tests.shift();
+ const next = tests.shift();
if (!next)
return console.error('ok');
- var name = next[0];
- var fn = next[1];
+ const name = next[0];
+ const fn = next[1];
console.log('# %s', name);
fn({
same: assert.deepStrictEqual,
@@ -42,18 +42,18 @@ process.nextTick(run);
/////
test('writable side consumption', function(t) {
- var tx = new Transform({
+ const tx = new Transform({
highWaterMark: 10
});
- var transformed = 0;
+ let transformed = 0;
tx._transform = function(chunk, encoding, cb) {
transformed += chunk.length;
tx.push(chunk);
cb();
};
- for (var i = 1; i <= 10; i++) {
+ for (let i = 1; i <= 10; i++) {
tx.write(Buffer.allocUnsafe(i));
}
tx.end();
@@ -69,7 +69,7 @@ test('writable side consumption', function(t) {
});
test('passthrough', function(t) {
- var pt = new PassThrough();
+ const pt = new PassThrough();
pt.write(Buffer.from('foog'));
pt.write(Buffer.from('bark'));
@@ -85,7 +85,7 @@ test('passthrough', function(t) {
});
test('object passthrough', function(t) {
- var pt = new PassThrough({ objectMode: true });
+ const pt = new PassThrough({ objectMode: true });
pt.write(1);
pt.write(true);
@@ -115,9 +115,9 @@ test('passthrough constructor', function(t) {
});
test('simple transform', function(t) {
- var pt = new Transform();
+ const pt = new Transform();
pt._transform = function(c, e, cb) {
- var ret = Buffer.alloc(c.length, 'x');
+ const ret = Buffer.alloc(c.length, 'x');
pt.push(ret);
cb();
};
@@ -136,7 +136,7 @@ test('simple transform', function(t) {
});
test('simple object transform', function(t) {
- var pt = new Transform({ objectMode: true });
+ const pt = new Transform({ objectMode: true });
pt._transform = function(c, e, cb) {
pt.push(JSON.stringify(c));
cb();
@@ -162,7 +162,7 @@ test('simple object transform', function(t) {
});
test('async passthrough', function(t) {
- var pt = new Transform();
+ const pt = new Transform();
pt._transform = function(chunk, encoding, cb) {
setTimeout(function() {
pt.push(chunk);
@@ -186,7 +186,7 @@ test('async passthrough', function(t) {
});
test('assymetric transform (expand)', function(t) {
- var pt = new Transform();
+ const pt = new Transform();
// emit each chunk 2 times.
pt._transform = function(chunk, encoding, cb) {
@@ -218,7 +218,7 @@ test('assymetric transform (expand)', function(t) {
});
test('assymetric transform (compress)', function(t) {
- var pt = new Transform();
+ const pt = new Transform();
// each output is the first char of 3 consecutive chunks,
// or whatever's left.
@@ -227,7 +227,7 @@ test('assymetric transform (compress)', function(t) {
pt._transform = function(chunk, encoding, cb) {
if (!chunk)
chunk = '';
- var s = chunk.toString();
+ const s = chunk.toString();
setTimeout(function() {
this.state += s.charAt(0);
if (this.state.length === 3) {
@@ -273,9 +273,9 @@ test('assymetric transform (compress)', function(t) {
// this tests for a stall when data is written to a full stream
// that has empty transforms.
test('complex transform', function(t) {
- var count = 0;
- var saved = null;
- var pt = new Transform({highWaterMark: 3});
+ let count = 0;
+ let saved = null;
+ const pt = new Transform({highWaterMark: 3});
pt._transform = function(c, e, cb) {
if (count++ === 1)
saved = c;
@@ -307,8 +307,8 @@ test('complex transform', function(t) {
test('passthrough event emission', function(t) {
- var pt = new PassThrough();
- var emits = 0;
+ const pt = new PassThrough();
+ let emits = 0;
pt.on('readable', function() {
console.error('>>> emit readable %d', emits);
emits++;
@@ -353,8 +353,8 @@ test('passthrough event emission', function(t) {
});
test('passthrough event emission reordered', function(t) {
- var pt = new PassThrough();
- var emits = 0;
+ const pt = new PassThrough();
+ let emits = 0;
pt.on('readable', function() {
console.error('emit readable', emits);
emits++;
@@ -395,8 +395,8 @@ test('passthrough event emission reordered', function(t) {
test('passthrough facaded', function(t) {
console.error('passthrough facaded');
- var pt = new PassThrough();
- var datas = [];
+ const pt = new PassThrough();
+ const datas = [];
pt.on('data', function(chunk) {
datas.push(chunk.toString());
});
@@ -423,7 +423,7 @@ test('passthrough facaded', function(t) {
test('object transform (json parse)', function(t) {
console.error('json parse stream');
- var jp = new Transform({ objectMode: true });
+ const jp = new Transform({ objectMode: true });
jp._transform = function(data, encoding, cb) {
try {
jp.push(JSON.parse(data));
@@ -435,21 +435,21 @@ test('object transform (json parse)', function(t) {
// anything except null/undefined is fine.
// those are "magic" in the stream API, because they signal EOF.
- var objects = [
+ const objects = [
{ foo: 'bar' },
100,
'string',
{ nested: { things: [ { foo: 'bar' }, 100, 'string' ] } }
];
- var ended = false;
+ let ended = false;
jp.on('end', function() {
ended = true;
});
objects.forEach(function(obj) {
jp.write(JSON.stringify(obj));
- var res = jp.read();
+ const res = jp.read();
t.same(res, obj);
});
@@ -465,7 +465,7 @@ test('object transform (json parse)', function(t) {
test('object transform (json stringify)', function(t) {
console.error('json parse stream');
- var js = new Transform({ objectMode: true });
+ const js = new Transform({ objectMode: true });
js._transform = function(data, encoding, cb) {
try {
js.push(JSON.stringify(data));
@@ -477,21 +477,21 @@ test('object transform (json stringify)', function(t) {
// anything except null/undefined is fine.
// those are "magic" in the stream API, because they signal EOF.
- var objects = [
+ const objects = [
{ foo: 'bar' },
100,
'string',
{ nested: { things: [ { foo: 'bar' }, 100, 'string' ] } }
];
- var ended = false;
+ let ended = false;
js.on('end', function() {
ended = true;
});
objects.forEach(function(obj) {
js.write(obj);
- var res = js.read();
+ const res = js.read();
t.equal(res, JSON.stringify(obj));
});
diff --git a/test/parallel/test-stream2-unpipe-leak.js b/test/parallel/test-stream2-unpipe-leak.js
index d94e39f7667df4..1a1599ca32b4c7 100644
--- a/test/parallel/test-stream2-unpipe-leak.js
+++ b/test/parallel/test-stream2-unpipe-leak.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
-var stream = require('stream');
+const assert = require('assert');
+const stream = require('stream');
-var chunk = Buffer.from('hallo');
+const chunk = Buffer.from('hallo');
-var util = require('util');
+const util = require('util');
function TestWriter() {
stream.Writable.call(this);
@@ -16,7 +16,7 @@ TestWriter.prototype._write = function(buffer, encoding, callback) {
callback(null);
};
-var dest = new TestWriter();
+const dest = new TestWriter();
// Set this high so that we'd trigger a nextTick warning
// and/or RangeError if we do maybeReadMore wrong.
@@ -29,9 +29,9 @@ TestReader.prototype._read = function(size) {
this.push(chunk);
};
-var src = new TestReader();
+const src = new TestReader();
-for (var i = 0; i < 10; i++) {
+for (let i = 0; i < 10; i++) {
src.pipe(dest);
src.unpipe(dest);
}
diff --git a/test/parallel/test-stream2-writable.js b/test/parallel/test-stream2-writable.js
index 5ecdd0f76ecb5a..c377ce9a510caa 100644
--- a/test/parallel/test-stream2-writable.js
+++ b/test/parallel/test-stream2-writable.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var W = require('_stream_writable');
-var D = require('_stream_duplex');
-var assert = require('assert');
+const W = require('_stream_writable');
+const D = require('_stream_duplex');
+const assert = require('assert');
-var util = require('util');
+const util = require('util');
util.inherits(TestWriter, W);
function TestWriter() {
@@ -22,14 +22,14 @@ TestWriter.prototype._write = function(chunk, encoding, cb) {
}.bind(this), Math.floor(Math.random() * 10));
};
-var chunks = new Array(50);
-for (var i = 0; i < chunks.length; i++) {
+const chunks = new Array(50);
+for (let i = 0; i < chunks.length; i++) {
chunks[i] = new Array(i + 1).join('x');
}
// tiny node-tap lookalike.
-var tests = [];
-var count = 0;
+const tests = [];
+let count = 0;
function test(name, fn) {
count++;
@@ -37,12 +37,12 @@ function test(name, fn) {
}
function run() {
- var next = tests.shift();
+ const next = tests.shift();
if (!next)
return console.error('ok');
- var name = next[0];
- var fn = next[1];
+ const name = next[0];
+ const fn = next[1];
console.log('# %s', name);
fn({
same: assert.deepStrictEqual,
@@ -62,7 +62,7 @@ process.on('exit', function() {
process.nextTick(run);
test('write fast', function(t) {
- var tw = new TestWriter({
+ const tw = new TestWriter({
highWaterMark: 100
});
@@ -79,7 +79,7 @@ test('write fast', function(t) {
});
test('write slow', function(t) {
- var tw = new TestWriter({
+ const tw = new TestWriter({
highWaterMark: 100
});
@@ -88,7 +88,7 @@ test('write slow', function(t) {
t.end();
});
- var i = 0;
+ let i = 0;
(function W() {
tw.write(chunks[i++]);
if (i < chunks.length)
@@ -99,11 +99,11 @@ test('write slow', function(t) {
});
test('write backpressure', function(t) {
- var tw = new TestWriter({
+ const tw = new TestWriter({
highWaterMark: 50
});
- var drains = 0;
+ let drains = 0;
tw.on('finish', function() {
t.same(tw.buffer, chunks, 'got chunks in the right order');
@@ -115,10 +115,11 @@ test('write backpressure', function(t) {
drains++;
});
- var i = 0;
+ let i = 0;
(function W() {
+ let ret;
do {
- var ret = tw.write(chunks[i++]);
+ ret = tw.write(chunks[i++]);
} while (ret !== false && i < chunks.length);
if (i < chunks.length) {
@@ -131,11 +132,11 @@ test('write backpressure', function(t) {
});
test('write bufferize', function(t) {
- var tw = new TestWriter({
+ const tw = new TestWriter({
highWaterMark: 100
});
- var encodings =
+ const encodings =
[ 'hex',
'utf8',
'utf-8',
@@ -154,7 +155,7 @@ test('write bufferize', function(t) {
});
chunks.forEach(function(chunk, i) {
- var enc = encodings[i % encodings.length];
+ const enc = encodings[i % encodings.length];
chunk = Buffer.from(chunk);
tw.write(chunk.toString(enc), enc);
});
@@ -162,7 +163,7 @@ test('write bufferize', function(t) {
});
test('write no bufferize', function(t) {
- var tw = new TestWriter({
+ const tw = new TestWriter({
highWaterMark: 100,
decodeStrings: false
});
@@ -173,7 +174,7 @@ test('write no bufferize', function(t) {
return TestWriter.prototype._write.call(this, chunk, encoding, cb);
};
- var encodings =
+ const encodings =
[ 'hex',
'utf8',
'utf-8',
@@ -192,7 +193,7 @@ test('write no bufferize', function(t) {
});
chunks.forEach(function(chunk, i) {
- var enc = encodings[i % encodings.length];
+ const enc = encodings[i % encodings.length];
chunk = Buffer.from(chunk);
tw.write(chunk.toString(enc), enc);
});
@@ -200,7 +201,7 @@ test('write no bufferize', function(t) {
});
test('write callbacks', function(t) {
- var callbacks = chunks.map(function(chunk, i) {
+ const callbacks = chunks.map(function(chunk, i) {
return [i, function() {
callbacks._called[i] = chunk;
}];
@@ -210,7 +211,7 @@ test('write callbacks', function(t) {
}, {});
callbacks._called = [];
- var tw = new TestWriter({
+ const tw = new TestWriter({
highWaterMark: 100
});
@@ -229,28 +230,28 @@ test('write callbacks', function(t) {
});
test('end callback', function(t) {
- var tw = new TestWriter();
+ const tw = new TestWriter();
tw.end(function() {
t.end();
});
});
test('end callback with chunk', function(t) {
- var tw = new TestWriter();
+ const tw = new TestWriter();
tw.end(Buffer.from('hello world'), function() {
t.end();
});
});
test('end callback with chunk and encoding', function(t) {
- var tw = new TestWriter();
+ const tw = new TestWriter();
tw.end('hello world', 'ascii', function() {
t.end();
});
});
test('end callback after .write() call', function(t) {
- var tw = new TestWriter();
+ const tw = new TestWriter();
tw.write(Buffer.from('hello world'));
tw.end(function() {
t.end();
@@ -258,8 +259,8 @@ test('end callback after .write() call', function(t) {
});
test('end callback called after write callback', function(t) {
- var tw = new TestWriter();
- var writeCalledback = false;
+ const tw = new TestWriter();
+ let writeCalledback = false;
tw.write(Buffer.from('hello world'), function() {
writeCalledback = true;
});
@@ -270,20 +271,20 @@ test('end callback called after write callback', function(t) {
});
test('encoding should be ignored for buffers', function(t) {
- var tw = new W();
- var hex = '018b5e9a8f6236ffe30e31baf80d2cf6eb';
+ const tw = new W();
+ const hex = '018b5e9a8f6236ffe30e31baf80d2cf6eb';
tw._write = function(chunk) {
t.equal(chunk.toString('hex'), hex);
t.end();
};
- var buf = Buffer.from(hex, 'hex');
+ const buf = Buffer.from(hex, 'hex');
tw.write(buf, 'latin1');
});
test('writables are not pipable', function(t) {
- var w = new W();
+ const w = new W();
w._write = function() {};
- var gotError = false;
+ let gotError = false;
w.on('error', function() {
gotError = true;
});
@@ -293,10 +294,10 @@ test('writables are not pipable', function(t) {
});
test('duplexes are pipable', function(t) {
- var d = new D();
+ const d = new D();
d._read = function() {};
d._write = function() {};
- var gotError = false;
+ let gotError = false;
d.on('error', function() {
gotError = true;
});
@@ -306,9 +307,9 @@ test('duplexes are pipable', function(t) {
});
test('end(chunk) two times is an error', function(t) {
- var w = new W();
+ const w = new W();
w._write = function() {};
- var gotError = false;
+ let gotError = false;
w.on('error', function(er) {
gotError = true;
t.equal(er.message, 'write after end');
@@ -322,8 +323,8 @@ test('end(chunk) two times is an error', function(t) {
});
test('dont end while writing', function(t) {
- var w = new W();
- var wrote = false;
+ const w = new W();
+ let wrote = false;
w._write = function(chunk, e, cb) {
assert(!this.writing);
wrote = true;
@@ -342,8 +343,8 @@ test('dont end while writing', function(t) {
});
test('finish does not come before write cb', function(t) {
- var w = new W();
- var writeCb = false;
+ const w = new W();
+ let writeCb = false;
w._write = function(chunk, e, cb) {
setTimeout(function() {
writeCb = true;
@@ -359,8 +360,8 @@ test('finish does not come before write cb', function(t) {
});
test('finish does not come before sync _write cb', function(t) {
- var w = new W();
- var writeCb = false;
+ const w = new W();
+ let writeCb = false;
w._write = function(chunk, e, cb) {
cb();
};
@@ -375,7 +376,7 @@ test('finish does not come before sync _write cb', function(t) {
});
test('finish is emitted if last chunk is empty', function(t) {
- var w = new W();
+ const w = new W();
w._write = function(chunk, e, cb) {
process.nextTick(cb);
};
diff --git a/test/parallel/test-stream3-cork-end.js b/test/parallel/test-stream3-cork-end.js
index a0b611d0da1b66..230227e0b13ddb 100644
--- a/test/parallel/test-stream3-cork-end.js
+++ b/test/parallel/test-stream3-cork-end.js
@@ -12,11 +12,11 @@ const Writable = stream.Writable;
// node version target: 0.12
const expectedChunks = ['please', 'buffer', 'me', 'kindly'];
-var inputChunks = expectedChunks.slice(0);
-var seenChunks = [];
-var seenEnd = false;
+const inputChunks = expectedChunks.slice(0);
+let seenChunks = [];
+let seenEnd = false;
-var w = new Writable();
+const w = new Writable();
// lets arrange to store the chunks
w._write = function(chunk, encoding, cb) {
// stream end event is not seen before the last write
@@ -33,8 +33,8 @@ w.on('finish', () => {
});
function writeChunks(remainingChunks, callback) {
- var writeChunk = remainingChunks.shift();
- var writeState;
+ const writeChunk = remainingChunks.shift();
+ let writeState;
if (writeChunk) {
setImmediate(() => {
@@ -74,12 +74,12 @@ writeChunks(inputChunks, () => {
assert.equal(seenChunks.length, 4);
// did the chunks match
- for (var i = 0, l = expectedChunks.length; i < l; i++) {
- var seen = seenChunks[i];
+ for (let i = 0, l = expectedChunks.length; i < l; i++) {
+ const seen = seenChunks[i];
// there was a chunk
assert.ok(seen);
- var expected = new Buffer(expectedChunks[i]);
+ const expected = new Buffer(expectedChunks[i]);
// it was what we expected
assert.ok(seen.equals(expected));
}
diff --git a/test/parallel/test-stream3-cork-uncork.js b/test/parallel/test-stream3-cork-uncork.js
index cd86e8cf809bac..821fd22bf8b8a3 100644
--- a/test/parallel/test-stream3-cork-uncork.js
+++ b/test/parallel/test-stream3-cork-uncork.js
@@ -12,11 +12,11 @@ const Writable = stream.Writable;
// node version target: 0.12
const expectedChunks = ['please', 'buffer', 'me', 'kindly'];
-var inputChunks = expectedChunks.slice(0);
-var seenChunks = [];
-var seenEnd = false;
+const inputChunks = expectedChunks.slice(0);
+let seenChunks = [];
+let seenEnd = false;
-var w = new Writable();
+const w = new Writable();
// lets arrange to store the chunks
w._write = function(chunk, encoding, cb) {
// default encoding given none was specified
@@ -31,8 +31,8 @@ w.on('finish', () => {
});
function writeChunks(remainingChunks, callback) {
- var writeChunk = remainingChunks.shift();
- var writeState;
+ const writeChunk = remainingChunks.shift();
+ let writeState;
if (writeChunk) {
setImmediate(() => {
@@ -69,12 +69,12 @@ writeChunks(inputChunks, () => {
assert.equal(seenChunks.length, 4);
// did the chunks match
- for (var i = 0, l = expectedChunks.length; i < l; i++) {
- var seen = seenChunks[i];
+ for (let i = 0, l = expectedChunks.length; i < l; i++) {
+ const seen = seenChunks[i];
// there was a chunk
assert.ok(seen);
- var expected = new Buffer(expectedChunks[i]);
+ const expected = new Buffer(expectedChunks[i]);
// it was what we expected
assert.ok(seen.equals(expected));
}
diff --git a/test/parallel/test-stream3-pause-then-read.js b/test/parallel/test-stream3-pause-then-read.js
index 64d25fefc94c86..5a9550bcd41d7f 100644
--- a/test/parallel/test-stream3-pause-then-read.js
+++ b/test/parallel/test-stream3-pause-then-read.js
@@ -1,18 +1,18 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var stream = require('stream');
-var Readable = stream.Readable;
-var Writable = stream.Writable;
+const stream = require('stream');
+const Readable = stream.Readable;
+const Writable = stream.Writable;
-var totalChunks = 100;
-var chunkSize = 99;
-var expectTotalData = totalChunks * chunkSize;
-var expectEndingData = expectTotalData;
+const totalChunks = 100;
+const chunkSize = 99;
+const expectTotalData = totalChunks * chunkSize;
+let expectEndingData = expectTotalData;
-var r = new Readable({ highWaterMark: 1000 });
-var chunks = totalChunks;
+const r = new Readable({ highWaterMark: 1000 });
+let chunks = totalChunks;
r._read = function(n) {
if (!(chunks % 2))
setImmediate(push);
@@ -22,9 +22,9 @@ r._read = function(n) {
push();
};
-var totalPushed = 0;
+let totalPushed = 0;
function push() {
- var chunk = chunks-- > 0 ? Buffer.alloc(chunkSize, 'x') : null;
+ const chunk = chunks-- > 0 ? Buffer.alloc(chunkSize, 'x') : null;
if (chunk) {
totalPushed += chunk.length;
}
@@ -42,7 +42,7 @@ function readn(n, then) {
console.error('read %d', n);
expectEndingData -= n;
(function read() {
- var c = r.read(n);
+ const c = r.read(n);
if (!c)
r.once('readable', read);
else {
@@ -57,7 +57,7 @@ function readn(n, then) {
function onData() {
expectEndingData -= 100;
console.error('onData');
- var seen = 0;
+ let seen = 0;
r.on('data', function od(c) {
seen += c.length;
if (seen >= 100) {
@@ -67,7 +67,7 @@ function onData() {
if (seen > 100) {
// oh no, seen too much!
// put the extra back.
- var diff = seen - 100;
+ const diff = seen - 100;
r.unshift(c.slice(c.length - diff));
console.error('seen too much', seen, diff);
}
@@ -82,8 +82,8 @@ function onData() {
function pipeLittle() {
expectEndingData -= 200;
console.error('pipe a little');
- var w = new Writable();
- var written = 0;
+ const w = new Writable();
+ let written = 0;
w.on('finish', function() {
assert.equal(written, 200);
setImmediate(read1234);
@@ -95,7 +95,7 @@ function pipeLittle() {
w.end();
cb();
if (written > 200) {
- var diff = written - 200;
+ const diff = written - 200;
written -= diff;
r.unshift(chunk.slice(chunk.length - diff));
}
@@ -130,8 +130,8 @@ function resumePause() {
function pipe() {
console.error('pipe the rest');
- var w = new Writable();
- var written = 0;
+ const w = new Writable();
+ let written = 0;
w._write = function(chunk, encoding, cb) {
written += chunk.length;
cb();
diff --git a/test/parallel/test-string-decoder-end.js b/test/parallel/test-string-decoder-end.js
index 4769d880cf8d34..16f605d2dd8198 100644
--- a/test/parallel/test-string-decoder-end.js
+++ b/test/parallel/test-string-decoder-end.js
@@ -4,9 +4,9 @@
// result of the entire buffer.
require('../common');
-var assert = require('assert');
-var SD = require('string_decoder').StringDecoder;
-var encodings = ['base64', 'hex', 'utf8', 'utf16le', 'ucs2'];
+const assert = require('assert');
+const SD = require('string_decoder').StringDecoder;
+const encodings = ['base64', 'hex', 'utf8', 'utf16le', 'ucs2'];
const bufs = [ '☃💩', 'asdf' ].map((b) => Buffer.from(b));
@@ -30,21 +30,21 @@ function testBuf(encoding, buf) {
console.error('# %s', encoding, buf);
// write one byte at a time.
- var s = new SD(encoding);
- var res1 = '';
- for (var i = 0; i < buf.length; i++) {
+ let s = new SD(encoding);
+ let res1 = '';
+ for (let i = 0; i < buf.length; i++) {
res1 += s.write(buf.slice(i, i + 1));
}
res1 += s.end();
// write the whole buffer at once.
- var res2 = '';
+ let res2 = '';
s = new SD(encoding);
res2 += s.write(buf);
res2 += s.end();
// .toString() on the buffer
- var res3 = buf.toString(encoding);
+ const res3 = buf.toString(encoding);
console.log('expect=%j', res3);
console.log('res1=%j', res1);
diff --git a/test/parallel/test-string-decoder.js b/test/parallel/test-string-decoder.js
index 4cdd235fbaa191..07883a14ec8b7a 100644
--- a/test/parallel/test-string-decoder.js
+++ b/test/parallel/test-string-decoder.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
-var inspect = require('util').inspect;
-var StringDecoder = require('string_decoder').StringDecoder;
+const assert = require('assert');
+const inspect = require('util').inspect;
+const StringDecoder = require('string_decoder').StringDecoder;
// Test default encoding
-var decoder = new StringDecoder();
+let decoder = new StringDecoder();
assert.strictEqual(decoder.encoding, 'utf8');
process.stdout.write('scanning ');
@@ -121,7 +121,7 @@ assert.throws(() => {
// singleSequence allows for easy debugging of a specific sequence which is
// useful in case of test failures.
function test(encoding, input, expected, singleSequence) {
- var sequences;
+ let sequences;
if (!singleSequence) {
sequences = writeSequences(input.length);
} else {
@@ -136,7 +136,7 @@ function test(encoding, input, expected, singleSequence) {
output += decoder.end();
process.stdout.write('.');
if (output !== expected) {
- var message =
+ const message =
'Expected "' + unicodeEscape(expected) + '", ' +
'but got "' + unicodeEscape(output) + '"\n' +
'input: ' + input.toString('hex').match(/.{2}/g) + '\n' +
@@ -149,8 +149,8 @@ function test(encoding, input, expected, singleSequence) {
// unicodeEscape prints the str contents as unicode escape codes.
function unicodeEscape(str) {
- var r = '';
- for (var i = 0; i < str.length; i++) {
+ let r = '';
+ for (let i = 0; i < str.length; i++) {
r += '\\u' + str.charCodeAt(i).toString(16);
}
return r;
@@ -173,10 +173,10 @@ function writeSequences(length, start, sequence) {
} else if (start === length) {
return [sequence];
}
- var sequences = [];
- for (var end = length; end > start; end--) {
- var subSequence = sequence.concat([[start, end]]);
- var subSequences = writeSequences(length, end, subSequence, sequences);
+ let sequences = [];
+ for (let end = length; end > start; end--) {
+ const subSequence = sequence.concat([[start, end]]);
+ const subSequences = writeSequences(length, end, subSequence, sequences);
sequences = sequences.concat(subSequences);
}
return sequences;
diff --git a/test/parallel/test-stringbytes-external.js b/test/parallel/test-stringbytes-external.js
index a34612f75d71f6..a242b943c91a4d 100644
--- a/test/parallel/test-stringbytes-external.js
+++ b/test/parallel/test-stringbytes-external.js
@@ -1,18 +1,18 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// minimum string size to overflow into external string space
-var EXTERN_APEX = 0xFBEE9;
+const EXTERN_APEX = 0xFBEE9;
// manually controlled string for checking binary output
-var ucs2_control = 'a\u0000';
-var write_str = 'a';
+let ucs2_control = 'a\u0000';
+let write_str = 'a';
// first do basic checks
-var b = Buffer.from(write_str, 'ucs2');
+let b = Buffer.from(write_str, 'ucs2');
// first check latin1
-var c = b.toString('latin1');
+let c = b.toString('latin1');
assert.equal(b[0], 0x61);
assert.equal(b[1], 0);
assert.equal(ucs2_control, c);
@@ -23,7 +23,7 @@ assert.equal(b[1], 0);
assert.equal(ucs2_control, c);
// now create big strings
-var size = 1 + (1 << 20);
+const size = 1 + (1 << 20);
write_str = Array(size).join(write_str);
ucs2_control = Array(size).join(ucs2_control);
@@ -36,19 +36,19 @@ for (let i = 0; i < b.length; i += 2) {
}
// create another string to create an external string
-var b_ucs = b.toString('ucs2');
+const b_ucs = b.toString('ucs2');
// check control against external binary string
-var l_bin = b.toString('latin1');
+const l_bin = b.toString('latin1');
assert.equal(ucs2_control, l_bin);
// check control against external binary string
-var b_bin = b.toString('binary');
+const b_bin = b.toString('binary');
assert.equal(ucs2_control, b_bin);
// create buffer copy from external
-var c_bin = Buffer.from(l_bin, 'latin1');
-var c_ucs = Buffer.from(b_ucs, 'ucs2');
+const c_bin = Buffer.from(l_bin, 'latin1');
+const c_ucs = Buffer.from(b_ucs, 'ucs2');
// make sure they're the same length
assert.equal(c_bin.length, c_ucs.length);
// make sure Buffers from externals are the same
@@ -62,9 +62,9 @@ assert.equal(c_ucs.toString('latin1'), ucs2_control);
// now let's test BASE64 and HEX ecoding/decoding
-var RADIOS = 2;
-var PRE_HALF_APEX = Math.ceil(EXTERN_APEX / 2) - RADIOS;
-var PRE_3OF4_APEX = Math.ceil((EXTERN_APEX / 4) * 3) - RADIOS;
+const RADIOS = 2;
+const PRE_HALF_APEX = Math.ceil(EXTERN_APEX / 2) - RADIOS;
+const PRE_3OF4_APEX = Math.ceil((EXTERN_APEX / 4) * 3) - RADIOS;
{
for (let j = 0; j < RADIOS * 2; j += 1) {
diff --git a/test/parallel/test-sync-io-option.js b/test/parallel/test-sync-io-option.js
index fec61ef62f370e..6166bffc0bd68c 100644
--- a/test/parallel/test-sync-io-option.js
+++ b/test/parallel/test-sync-io-option.js
@@ -12,9 +12,9 @@ if (process.argv[2] === 'child') {
} else {
(function runTest(flags) {
- var execArgv = [flags.pop()];
- var args = [__filename, 'child'];
- var cntr = 0;
+ const execArgv = [flags.pop()];
+ let args = [__filename, 'child'];
+ let cntr = 0;
args = execArgv.concat(args);
if (!args[0]) args.shift();
execFile(process.execPath, args, function(err, stdout, stderr) {
diff --git a/test/parallel/test-sys.js b/test/parallel/test-sys.js
index 3e28f020333c20..234744bb118fd7 100644
--- a/test/parallel/test-sys.js
+++ b/test/parallel/test-sys.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var sys = require('sys'); // eslint-disable-line no-restricted-modules
-var util = require('util');
+const assert = require('assert');
+const sys = require('sys'); // eslint-disable-line no-restricted-modules
+const util = require('util');
assert.strictEqual(sys, util);
diff --git a/test/parallel/test-tcp-wrap-connect.js b/test/parallel/test-tcp-wrap-connect.js
index 7ce88d194cd648..77f9814db2ebe5 100644
--- a/test/parallel/test-tcp-wrap-connect.js
+++ b/test/parallel/test-tcp-wrap-connect.js
@@ -1,15 +1,15 @@
'use strict';
require('../common');
-var assert = require('assert');
-var TCP = process.binding('tcp_wrap').TCP;
-var TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap;
-var ShutdownWrap = process.binding('stream_wrap').ShutdownWrap;
+const assert = require('assert');
+const TCP = process.binding('tcp_wrap').TCP;
+const TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap;
+const ShutdownWrap = process.binding('stream_wrap').ShutdownWrap;
function makeConnection() {
- var client = new TCP();
+ const client = new TCP();
- var req = new TCPConnectWrap();
- var err = client.connect(req, '127.0.0.1', this.address().port);
+ const req = new TCPConnectWrap();
+ const err = client.connect(req, '127.0.0.1', this.address().port);
assert.strictEqual(err, 0);
req.oncomplete = function(status, client_, req_, readable, writable) {
@@ -19,8 +19,8 @@ function makeConnection() {
assert.strictEqual(true, readable);
assert.strictEqual(true, writable);
- var shutdownReq = new ShutdownWrap();
- var err = client.shutdown(shutdownReq);
+ const shutdownReq = new ShutdownWrap();
+ const err = client.shutdown(shutdownReq);
assert.strictEqual(err, 0);
shutdownReq.oncomplete = function(status, client_, req_) {
@@ -35,11 +35,11 @@ function makeConnection() {
/////
-var connectCount = 0;
-var endCount = 0;
-var shutdownCount = 0;
+let connectCount = 0;
+let endCount = 0;
+let shutdownCount = 0;
-var server = require('net').Server(function(s) {
+const server = require('net').Server(function(s) {
connectCount++;
s.resume();
s.on('end', function() {
diff --git a/test/parallel/test-tcp-wrap.js b/test/parallel/test-tcp-wrap.js
index 18b8fe401f8902..6b9dbd90a4c113 100644
--- a/test/parallel/test-tcp-wrap.js
+++ b/test/parallel/test-tcp-wrap.js
@@ -1,18 +1,18 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var TCP = process.binding('tcp_wrap').TCP;
-var uv = process.binding('uv');
+const TCP = process.binding('tcp_wrap').TCP;
+const uv = process.binding('uv');
-var handle = new TCP();
+const handle = new TCP();
// Should be able to bind to the port
-var err = handle.bind('0.0.0.0', 0);
+let err = handle.bind('0.0.0.0', 0);
assert.equal(err, 0);
// Should not be able to bind to the same port again
-var out = {};
+const out = {};
handle.getsockname(out);
err = handle.bind('0.0.0.0', out.port);
assert.equal(err, uv.UV_EINVAL);
diff --git a/test/parallel/test-timer-close.js b/test/parallel/test-timer-close.js
index f13078e5a5bed1..158b082cf3167a 100644
--- a/test/parallel/test-timer-close.js
+++ b/test/parallel/test-timer-close.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var t = new (process.binding('timer_wrap').Timer)();
-var called = 0;
+const t = new (process.binding('timer_wrap').Timer)();
+let called = 0;
function onclose() {
called++;
}
diff --git a/test/parallel/test-timers-active.js b/test/parallel/test-timers-active.js
index 8677e43971ac89..62707cf18c0ab7 100644
--- a/test/parallel/test-timers-active.js
+++ b/test/parallel/test-timers-active.js
@@ -4,7 +4,7 @@ const assert = require('assert');
const active = require('timers').active;
// active() should create timers for these
-var legitTimers = [
+const legitTimers = [
{ _idleTimeout: 0 },
{ _idleTimeout: 1 }
];
@@ -21,7 +21,7 @@ legitTimers.forEach(function(legit) {
// active() should not create a timer for these
-var bogusTimers = [
+const bogusTimers = [
{ _idleTimeout: -1 },
{ _idleTimeout: undefined },
];
diff --git a/test/parallel/test-timers-args.js b/test/parallel/test-timers-args.js
index 21eafd1bcd9ea6..1ba44d8bcf3664 100644
--- a/test/parallel/test-timers-args.js
+++ b/test/parallel/test-timers-args.js
@@ -1,13 +1,13 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
function range(n) {
return 'x'.repeat(n + 1).split('').map(function(_, i) { return i; });
}
function timeout(nargs) {
- var args = range(nargs);
+ const args = range(nargs);
setTimeout.apply(null, [callback, 1].concat(args));
function callback() {
@@ -17,8 +17,8 @@ function timeout(nargs) {
}
function interval(nargs) {
- var args = range(nargs);
- var timer = setTimeout.apply(null, [callback, 1].concat(args));
+ const args = range(nargs);
+ const timer = setTimeout.apply(null, [callback, 1].concat(args));
function callback() {
clearInterval(timer);
diff --git a/test/parallel/test-timers-clearImmediate.js b/test/parallel/test-timers-clearImmediate.js
index ab65b7bf1ce05d..c49fd7622f4ab6 100644
--- a/test/parallel/test-timers-clearImmediate.js
+++ b/test/parallel/test-timers-clearImmediate.js
@@ -3,14 +3,14 @@ require('../common');
const assert = require('assert');
const N = 3;
-var count = 0;
+let count = 0;
function next() {
const immediate = setImmediate(function() {
clearImmediate(immediate);
++count;
});
}
-for (var i = 0; i < N; ++i)
+for (let i = 0; i < N; ++i)
next();
process.on('exit', () => {
diff --git a/test/parallel/test-timers-immediate-queue.js b/test/parallel/test-timers-immediate-queue.js
index 62482d510a6608..43897f50617fd7 100644
--- a/test/parallel/test-timers-immediate-queue.js
+++ b/test/parallel/test-timers-immediate-queue.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// setImmediate should run clear its queued cbs once per event loop turn
// but immediates queued while processing the current queue should happen
@@ -11,10 +11,10 @@ var assert = require('assert');
// if we're letting things recursively add to the immediate QUEUE hit will be
// > QUEUE
-var ticked = false;
+let ticked = false;
-var hit = 0;
-var QUEUE = 1000;
+let hit = 0;
+const QUEUE = 1000;
function run() {
if (hit === 0)
@@ -26,7 +26,7 @@ function run() {
setImmediate(run);
}
-for (var i = 0; i < QUEUE; i++)
+for (let i = 0; i < QUEUE; i++)
setImmediate(run);
process.on('exit', function() {
diff --git a/test/parallel/test-timers-nested.js b/test/parallel/test-timers-nested.js
index d5d272ed2eae11..0ff228abf50311 100644
--- a/test/parallel/test-timers-nested.js
+++ b/test/parallel/test-timers-nested.js
@@ -11,7 +11,7 @@ const assert = require('assert');
const scenarios = [0, 100];
scenarios.forEach(function(delay) {
- var nestedCalled = false;
+ let nestedCalled = false;
setTimeout(function A() {
// Create the nested timer with the same delay as the outer timer so that it
diff --git a/test/parallel/test-timers-non-integer-delay.js b/test/parallel/test-timers-non-integer-delay.js
index b42053db3b1895..b062fcb6f229b0 100644
--- a/test/parallel/test-timers-non-integer-delay.js
+++ b/test/parallel/test-timers-non-integer-delay.js
@@ -17,11 +17,11 @@
require('../common');
-var TIMEOUT_DELAY = 1.1;
-var NB_TIMEOUTS_FIRED = 50;
+const TIMEOUT_DELAY = 1.1;
+const NB_TIMEOUTS_FIRED = 50;
-var nbTimeoutFired = 0;
-var interval = setInterval(function() {
+let nbTimeoutFired = 0;
+const interval = setInterval(function() {
++nbTimeoutFired;
if (nbTimeoutFired === NB_TIMEOUTS_FIRED) {
clearInterval(interval);
diff --git a/test/parallel/test-timers-ordering.js b/test/parallel/test-timers-ordering.js
index c23af9d8307e9a..55fb141cb272ce 100644
--- a/test/parallel/test-timers-ordering.js
+++ b/test/parallel/test-timers-ordering.js
@@ -1,14 +1,14 @@
'use strict';
require('../common');
-var assert = require('assert');
-var Timer = process.binding('timer_wrap').Timer;
+const assert = require('assert');
+const Timer = process.binding('timer_wrap').Timer;
-var N = 30;
+const N = 30;
-var last_i = 0;
-var last_ts = 0;
+let last_i = 0;
+let last_ts = 0;
-var f = function(i) {
+const f = function(i) {
if (i <= N) {
// check order
assert.equal(i, last_i + 1, 'order is broken: ' + i + ' != ' +
@@ -16,7 +16,7 @@ var f = function(i) {
last_i = i;
// check that this iteration is fired at least 1ms later than the previous
- var now = Timer.now();
+ const now = Timer.now();
console.log(i, now);
assert(now >= last_ts + 1,
'current ts ' + now + ' < prev ts ' + last_ts + ' + 1');
diff --git a/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js b/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js
index 8670c3c2b6e8f3..f42144360b6941 100644
--- a/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js
+++ b/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js
@@ -32,7 +32,7 @@ const server = net.createServer(function onClient(client) {
});
server.listen(0, common.localhostIPv4, function() {
- var nbClientsEnded = 0;
+ let nbClientsEnded = 0;
function addEndedClient(client) {
++nbClientsEnded;
diff --git a/test/parallel/test-timers-uncaught-exception.js b/test/parallel/test-timers-uncaught-exception.js
index 6b6dc583715849..87fd880de4bf89 100644
--- a/test/parallel/test-timers-uncaught-exception.js
+++ b/test/parallel/test-timers-uncaught-exception.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var exceptions = 0;
-var timer1 = 0;
-var timer2 = 0;
+let exceptions = 0;
+let timer1 = 0;
+let timer2 = 0;
// the first timer throws...
console.error('set first timer');
@@ -29,7 +29,7 @@ function uncaughtException(err) {
}
process.on('uncaughtException', uncaughtException);
-var exited = false;
+let exited = false;
process.on('exit', function() {
assert(!exited);
exited = true;
diff --git a/test/parallel/test-timers-unref-active.js b/test/parallel/test-timers-unref-active.js
index 69027277ea0ff2..8b1c89673bc35f 100644
--- a/test/parallel/test-timers-unref-active.js
+++ b/test/parallel/test-timers-unref-active.js
@@ -19,8 +19,8 @@ require('../common');
const timers = require('timers');
const assert = require('assert');
-var someObject = {};
-var nbTimeouts = 0;
+const someObject = {};
+let nbTimeouts = 0;
/*
* libuv 0.10.x uses GetTickCount on Windows to implement timers, which uses
diff --git a/test/parallel/test-timers-unref-call.js b/test/parallel/test-timers-unref-call.js
index edd5865e8f610b..5384441838763a 100644
--- a/test/parallel/test-timers-unref-call.js
+++ b/test/parallel/test-timers-unref-call.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var Timer = process.binding('timer_wrap').Timer;
+const Timer = process.binding('timer_wrap').Timer;
Timer.now = function() { return ++Timer.now.ticks; };
Timer.now.ticks = 0;
-var t = setInterval(function() {}, 1);
-var o = { _idleStart: 0, _idleTimeout: 1 };
+const t = setInterval(function() {}, 1);
+const o = { _idleStart: 0, _idleTimeout: 1 };
t.unref.call(o);
setTimeout(clearInterval.bind(null, t), 2);
diff --git a/test/parallel/test-timers-unref-leak.js b/test/parallel/test-timers-unref-leak.js
index a1b1265763bf1d..d970910b24abe6 100644
--- a/test/parallel/test-timers-unref-leak.js
+++ b/test/parallel/test-timers-unref-leak.js
@@ -1,17 +1,17 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var called = 0;
-var closed = 0;
+let called = 0;
+let closed = 0;
-var timeout = setTimeout(function() {
+const timeout = setTimeout(function() {
called++;
}, 10);
timeout.unref();
// Wrap `close` method to check if the handle was closed
-var close = timeout._handle.close;
+const close = timeout._handle.close;
timeout._handle.close = function() {
closed++;
return close.apply(this, arguments);
diff --git a/test/parallel/test-timers-unref-remove-other-unref-timers-only-one-fires.js b/test/parallel/test-timers-unref-remove-other-unref-timers-only-one-fires.js
index 971c485a4cf986..1dcc3e68de9eaa 100644
--- a/test/parallel/test-timers-unref-remove-other-unref-timers-only-one-fires.js
+++ b/test/parallel/test-timers-unref-remove-other-unref-timers-only-one-fires.js
@@ -14,7 +14,7 @@ require('../common');
const timers = require('timers');
const assert = require('assert');
-var nbTimersFired = 0;
+let nbTimersFired = 0;
const foo = {
_onTimeout: function() {
diff --git a/test/parallel/test-timers-unref.js b/test/parallel/test-timers-unref.js
index 801b34792a1f73..2bde08f914d790 100644
--- a/test/parallel/test-timers-unref.js
+++ b/test/parallel/test-timers-unref.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
let interval_fired = false;
let timeout_fired = false;
@@ -9,8 +9,8 @@ let unref_timer = false;
let unref_callbacks = 0;
let checks = 0;
-var LONG_TIME = 10 * 1000;
-var SHORT_TIME = 100;
+const LONG_TIME = 10 * 1000;
+const SHORT_TIME = 100;
assert.doesNotThrow(function() {
setTimeout(function() {}, 10).unref().ref().unref();
diff --git a/test/parallel/test-timers-unrefd-interval-still-fires.js b/test/parallel/test-timers-unrefd-interval-still-fires.js
index 39bb2cdb138205..bf16013f004965 100644
--- a/test/parallel/test-timers-unrefd-interval-still-fires.js
+++ b/test/parallel/test-timers-unrefd-interval-still-fires.js
@@ -6,7 +6,7 @@ const common = require('../common');
const TEST_DURATION = common.platformTimeout(1000);
const N = 3;
-var nbIntervalFired = 0;
+let nbIntervalFired = 0;
const keepOpen = setTimeout(() => {
console.error('[FAIL] Interval fired %d/%d times.', nbIntervalFired, N);
diff --git a/test/parallel/test-timers-unrefed-in-beforeexit.js b/test/parallel/test-timers-unrefed-in-beforeexit.js
index 0ac3311816fb4d..530d97674d8bf7 100644
--- a/test/parallel/test-timers-unrefed-in-beforeexit.js
+++ b/test/parallel/test-timers-unrefed-in-beforeexit.js
@@ -3,7 +3,7 @@
require('../common');
const assert = require('assert');
-var once = 0;
+let once = 0;
process.on('beforeExit', () => {
if (once > 1)
diff --git a/test/parallel/test-timers.js b/test/parallel/test-timers.js
index 87397735eebff2..df2240d2c444af 100644
--- a/test/parallel/test-timers.js
+++ b/test/parallel/test-timers.js
@@ -2,7 +2,7 @@
const common = require('../common');
const assert = require('assert');
-var inputs = [
+const inputs = [
undefined,
null,
true,
@@ -30,15 +30,15 @@ var inputs = [
12345678901234 // ditto
];
-var timeouts = [];
-var intervals = [];
+const timeouts = [];
+const intervals = [];
inputs.forEach(function(value, index) {
setTimeout(function() {
timeouts[index] = true;
}, value);
- var handle = setInterval(function() {
+ const handle = setInterval(function() {
clearInterval(handle); // disarm timer or we'll never finish
intervals[index] = true;
}, value);
diff --git a/test/parallel/test-tls-alert.js b/test/parallel/test-tls-alert.js
index db22443918453b..a8c6016f6218b7 100644
--- a/test/parallel/test-tls-alert.js
+++ b/test/parallel/test-tls-alert.js
@@ -1,6 +1,6 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.opensslCli) {
common.skip('node compiled without OpenSSL CLI.');
@@ -11,12 +11,12 @@ if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
-var spawn = require('child_process').spawn;
+const fs = require('fs');
+const spawn = require('child_process').spawn;
-var success = false;
+let success = false;
function filenamePEM(n) {
return require('path').join(common.fixturesDir, 'keys', n + '.pem');
@@ -26,20 +26,20 @@ function loadPEM(n) {
return fs.readFileSync(filenamePEM(n));
}
-var server = tls.Server({
+const server = tls.Server({
secureProtocol: 'TLSv1_2_server_method',
key: loadPEM('agent2-key'),
cert: loadPEM('agent2-cert')
}, null).listen(0, function() {
- var args = ['s_client', '-quiet', '-tls1_1',
- '-connect', `127.0.0.1:${this.address().port}`];
+ const args = ['s_client', '-quiet', '-tls1_1',
+ '-connect', `127.0.0.1:${this.address().port}`];
// for the performance and stability issue in s_client on Windows
if (common.isWindows)
args.push('-no_rand_screen');
- var client = spawn(common.opensslCli, args);
- var out = '';
+ const client = spawn(common.opensslCli, args);
+ let out = '';
client.stderr.setEncoding('utf8');
client.stderr.on('data', function(d) {
out += d;
diff --git a/test/parallel/test-tls-alpn-server-client.js b/test/parallel/test-tls-alpn-server-client.js
index 0da2086f4de506..ca5785b09ac05a 100644
--- a/test/parallel/test-tls-alpn-server-client.js
+++ b/test/parallel/test-tls-alpn-server-client.js
@@ -24,7 +24,7 @@ function loadPEM(n) {
return fs.readFileSync(filenamePEM(n));
}
-var serverIP = common.localhostIPv4;
+const serverIP = common.localhostIPv4;
function checkResults(result, expected) {
assert.strictEqual(result.server.ALPN, expected.server.ALPN);
@@ -36,9 +36,9 @@ function checkResults(result, expected) {
function runTest(clientsOptions, serverOptions, cb) {
serverOptions.key = loadPEM('agent2-key');
serverOptions.cert = loadPEM('agent2-cert');
- var results = [];
- var index = 0;
- var server = tls.createServer(serverOptions, function(c) {
+ const results = [];
+ let index = 0;
+ const server = tls.createServer(serverOptions, function(c) {
results[index].server = {ALPN: c.alpnProtocol, NPN: c.npnProtocol};
});
@@ -47,13 +47,13 @@ function runTest(clientsOptions, serverOptions, cb) {
});
function connectClient(options) {
- var opt = options.shift();
+ const opt = options.shift();
opt.port = server.address().port;
opt.host = serverIP;
opt.rejectUnauthorized = false;
results[index] = {};
- var client = tls.connect(opt, function() {
+ const client = tls.connect(opt, function() {
results[index].client = {ALPN: client.alpnProtocol,
NPN: client.npnProtocol};
client.destroy();
@@ -71,12 +71,12 @@ function runTest(clientsOptions, serverOptions, cb) {
// Server: ALPN/NPN, Client: ALPN/NPN
function Test1() {
- var serverOptions = {
+ const serverOptions = {
ALPNProtocols: ['a', 'b', 'c'],
NPNProtocols: ['a', 'b', 'c']
};
- var clientsOptions = [{
+ const clientsOptions = [{
ALPNProtocols: ['a', 'b', 'c'],
NPNProtocols: ['a', 'b', 'c']
}, {
@@ -107,12 +107,12 @@ function Test1() {
// Server: ALPN/NPN, Client: ALPN
function Test2() {
- var serverOptions = {
+ const serverOptions = {
ALPNProtocols: ['a', 'b', 'c'],
NPNProtocols: ['a', 'b', 'c']
};
- var clientsOptions = [{
+ const clientsOptions = [{
ALPNProtocols: ['a', 'b', 'c']
}, {
ALPNProtocols: ['c', 'b', 'e']
@@ -140,12 +140,12 @@ function Test2() {
// Server: ALPN/NPN, Client: NPN
function Test3() {
- var serverOptions = {
+ const serverOptions = {
ALPNProtocols: ['a', 'b', 'c'],
NPNProtocols: ['a', 'b', 'c']
};
- var clientsOptions = [{
+ const clientsOptions = [{
NPNProtocols: ['a', 'b', 'c']
}, {
NPPNProtocols: ['c', 'b', 'e']
@@ -173,12 +173,12 @@ function Test3() {
// Server: ALPN/NPN, Client: Nothing
function Test4() {
- var serverOptions = {
+ const serverOptions = {
ALPNProtocols: ['a', 'b', 'c'],
NPNProtocols: ['a', 'b', 'c']
};
- var clientsOptions = [{}, {}, {}];
+ const clientsOptions = [{}, {}, {}];
runTest(clientsOptions, serverOptions, function(results) {
// nothing is selected by ALPN
@@ -200,11 +200,11 @@ function Test4() {
// Server: ALPN, Client: ALPN/NPN
function Test5() {
- var serverOptions = {
+ const serverOptions = {
ALPNProtocols: ['a', 'b', 'c']
};
- var clientsOptions = [{
+ const clientsOptions = [{
ALPNProtocols: ['a', 'b', 'c'],
NPNProtocols: ['a', 'b', 'c']
}, {
@@ -233,11 +233,11 @@ function Test5() {
// Server: ALPN, Client: ALPN
function Test6() {
- var serverOptions = {
+ const serverOptions = {
ALPNProtocols: ['a', 'b', 'c']
};
- var clientsOptions = [{
+ const clientsOptions = [{
ALPNProtocols: ['a', 'b', 'c']
}, {
ALPNProtocols: ['c', 'b', 'e']
@@ -262,11 +262,11 @@ function Test6() {
// Server: ALPN, Client: NPN
function Test7() {
- var serverOptions = {
+ const serverOptions = {
ALPNProtocols: ['a', 'b', 'c']
};
- var clientsOptions = [{
+ const clientsOptions = [{
NPNProtocols: ['a', 'b', 'c']
}, {
NPNProtocols: ['c', 'b', 'e']
@@ -292,11 +292,11 @@ function Test7() {
// Server: ALPN, Client: Nothing
function Test8() {
- var serverOptions = {
+ const serverOptions = {
ALPNProtocols: ['a', 'b', 'c']
};
- var clientsOptions = [{}, {}, {}];
+ const clientsOptions = [{}, {}, {}];
runTest(clientsOptions, serverOptions, function(results) {
// nothing is selected by ALPN
@@ -316,11 +316,11 @@ function Test8() {
// Server: NPN, Client: ALPN/NPN
function Test9() {
- var serverOptions = {
+ const serverOptions = {
NPNProtocols: ['a', 'b', 'c']
};
- var clientsOptions = [{
+ const clientsOptions = [{
ALPNrotocols: ['a', 'b', 'c'],
NPNProtocols: ['a', 'b', 'c']
}, {
@@ -349,11 +349,11 @@ function Test9() {
// Server: NPN, Client: ALPN
function Test10() {
- var serverOptions = {
+ const serverOptions = {
NPNProtocols: ['a', 'b', 'c']
};
- var clientsOptions = [{
+ const clientsOptions = [{
ALPNProtocols: ['a', 'b', 'c']
}, {
ALPNProtocols: ['c', 'b', 'e']
@@ -378,11 +378,11 @@ function Test10() {
// Server: NPN, Client: NPN
function Test11() {
- var serverOptions = {
+ const serverOptions = {
NPNProtocols: ['a', 'b', 'c']
};
- var clientsOptions = [{
+ const clientsOptions = [{
NPNProtocols: ['a', 'b', 'c']
}, {
NPNProtocols: ['c', 'b', 'e']
@@ -408,11 +408,11 @@ function Test11() {
// Server: NPN, Client: Nothing
function Test12() {
- var serverOptions = {
+ const serverOptions = {
NPNProtocols: ['a', 'b', 'c']
};
- var clientsOptions = [{}, {}, {}];
+ const clientsOptions = [{}, {}, {}];
runTest(clientsOptions, serverOptions, function(results) {
// nothing is selected
@@ -432,9 +432,9 @@ function Test12() {
// Server: Nothing, Client: ALPN/NPN
function Test13() {
- var serverOptions = {};
+ const serverOptions = {};
- var clientsOptions = [{
+ const clientsOptions = [{
ALPNrotocols: ['a', 'b', 'c'],
NPNProtocols: ['a', 'b', 'c']
}, {
@@ -463,9 +463,9 @@ function Test13() {
// Server: Nothing, Client: ALPN
function Test14() {
- var serverOptions = {};
+ const serverOptions = {};
- var clientsOptions = [{
+ const clientsOptions = [{
ALPNrotocols: ['a', 'b', 'c']
}, {
ALPNProtocols: ['c', 'b', 'e']
@@ -491,9 +491,9 @@ function Test14() {
// Server: Nothing, Client: NPN
function Test15() {
- var serverOptions = {};
+ const serverOptions = {};
- var clientsOptions = [{
+ const clientsOptions = [{
NPNProtocols: ['a', 'b', 'c']
}, {
NPNProtocols: ['c', 'b', 'e']
@@ -519,9 +519,9 @@ function Test15() {
// Server: Nothing, Client: Nothing
function Test16() {
- var serverOptions = {};
+ const serverOptions = {};
- var clientsOptions = [{}, {}, {}];
+ const clientsOptions = [{}, {}, {}];
runTest(clientsOptions, serverOptions, function(results) {
// nothing is selected
diff --git a/test/parallel/test-tls-async-cb-after-socket-end.js b/test/parallel/test-tls-async-cb-after-socket-end.js
index c72deb133c3e35..7e24835ee689e9 100644
--- a/test/parallel/test-tls-async-cb-after-socket-end.js
+++ b/test/parallel/test-tls-async-cb-after-socket-end.js
@@ -1,9 +1,9 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
-var path = require('path');
-var fs = require('fs');
+const path = require('path');
+const fs = require('fs');
const SSL_OP_NO_TICKET = require('crypto').constants.SSL_OP_NO_TICKET;
if (!common.hasCrypto) {
@@ -11,19 +11,19 @@ if (!common.hasCrypto) {
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var options = {
+const options = {
secureOptions: SSL_OP_NO_TICKET,
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
};
-var server = tls.createServer(options, function(c) {
+const server = tls.createServer(options, function(c) {
});
-var sessionCb = null;
-var client = null;
+let sessionCb = null;
+let client = null;
server.on('newSession', function(key, session, done) {
done();
@@ -36,18 +36,18 @@ server.on('resumeSession', function(id, cb) {
});
server.listen(0, function() {
- var clientOpts = {
+ const clientOpts = {
port: this.address().port,
rejectUnauthorized: false,
session: false
};
- var s1 = tls.connect(clientOpts, function() {
+ const s1 = tls.connect(clientOpts, function() {
clientOpts.session = s1.getSession();
console.log('1st secure');
s1.destroy();
- var s2 = tls.connect(clientOpts, function(s) {
+ const s2 = tls.connect(clientOpts, function(s) {
console.log('2nd secure');
s2.destroy();
diff --git a/test/parallel/test-tls-cert-regression.js b/test/parallel/test-tls-cert-regression.js
index a26bab7c46e107..ff5827bcf844ee 100644
--- a/test/parallel/test-tls-cert-regression.js
+++ b/test/parallel/test-tls-cert-regression.js
@@ -1,14 +1,14 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var cert =
+const cert =
`-----BEGIN CERTIFICATE-----
MIIBfjCCASgCCQDmmNjAojbDQjANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
@@ -21,7 +21,7 @@ uvCyndyeB4d24FlfqEUlkfaWCZlNKRaV9YhLDiEg3BcIreFo4brtKQfZzTRs0GVm
KHg=
-----END CERTIFICATE-----`;
-var key =
+const key =
`-----BEGIN RSA PRIVATE KEY-----
MIIBPQIBAAJBAPKwlfMX6HGZIt1xm7fna72eWcOYfUfSxSugghvqYgJt2Oi3lH+w
sU1O9FzRIVmpeIjDXhbpMjsa1HtzSiccPXsCAwEAAQJBAM4uU9aJE0OfdE1p/X+K
@@ -33,7 +33,7 @@ AOaJnkQrmurlRdePX6LvN/LgGAQoxwovfjcOYNnZsIVY
-----END RSA PRIVATE KEY-----`;
function test(cert, key, cb) {
- var server = tls.createServer({
+ const server = tls.createServer({
cert: cert,
key: key
}).listen(0, function() {
diff --git a/test/parallel/test-tls-cipher-list.js b/test/parallel/test-tls-cipher-list.js
index 44ebd3d2f824ad..4acb30bc1c74bf 100644
--- a/test/parallel/test-tls-cipher-list.js
+++ b/test/parallel/test-tls-cipher-list.js
@@ -11,7 +11,7 @@ const spawn = require('child_process').spawn;
const defaultCoreList = require('crypto').constants.defaultCoreCipherList;
function doCheck(arg, check) {
- var out = '';
+ let out = '';
arg = arg.concat([
'-pe',
'require("crypto").constants.defaultCipherList'
diff --git a/test/parallel/test-tls-client-abort.js b/test/parallel/test-tls-client-abort.js
index d2fcf3e687e676..21ee41e927873b 100644
--- a/test/parallel/test-tls-client-abort.js
+++ b/test/parallel/test-tls-client-abort.js
@@ -1,20 +1,20 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
-var path = require('path');
+const fs = require('fs');
+const path = require('path');
-var cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
-var key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'));
+const cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
+const key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'));
-var conn = tls.connect({cert: cert, key: key, port: common.PORT}, function() {
+const conn = tls.connect({cert: cert, key: key, port: common.PORT}, function() {
assert.ok(false); // callback should never be executed
});
conn.on('error', function() {
diff --git a/test/parallel/test-tls-client-abort2.js b/test/parallel/test-tls-client-abort2.js
index f3295f6d854a72..3247a2899acdfb 100644
--- a/test/parallel/test-tls-client-abort2.js
+++ b/test/parallel/test-tls-client-abort2.js
@@ -1,14 +1,14 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var conn = tls.connect(common.PORT, common.fail);
+const conn = tls.connect(common.PORT, common.fail);
conn.on('error', common.mustCall(function() {
assert.doesNotThrow(function() {
conn.destroy();
diff --git a/test/parallel/test-tls-client-default-ciphers.js b/test/parallel/test-tls-client-default-ciphers.js
index 33766dfd5b13b2..618178d4a497ad 100644
--- a/test/parallel/test-tls-client-default-ciphers.js
+++ b/test/parallel/test-tls-client-default-ciphers.js
@@ -1,17 +1,17 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
function Done() {}
function test1() {
- var ciphers = '';
+ let ciphers = '';
tls.createSecureContext = function(options) {
ciphers = options.ciphers;
diff --git a/test/parallel/test-tls-client-destroy-soon.js b/test/parallel/test-tls-client-destroy-soon.js
index 171aa328142e13..016fcfa4da6a95 100644
--- a/test/parallel/test-tls-client-destroy-soon.js
+++ b/test/parallel/test-tls-client-destroy-soon.js
@@ -3,40 +3,40 @@
// Cache session and close connection. Use session on second connection.
// ASSERT resumption.
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem')
};
-var big = Buffer.alloc(2 * 1024 * 1024, 'Y');
+const big = Buffer.alloc(2 * 1024 * 1024, 'Y');
// create server
-var server = tls.createServer(options, common.mustCall(function(socket) {
+const server = tls.createServer(options, common.mustCall(function(socket) {
socket.end(big);
socket.destroySoon();
}));
// start listening
server.listen(0, common.mustCall(function() {
- var client = tls.connect({
+ const client = tls.connect({
port: this.address().port,
rejectUnauthorized: false
}, common.mustCall(function() {
- var bytesRead = 0;
+ let bytesRead = 0;
client.on('readable', function() {
- var d = client.read();
+ const d = client.read();
if (d)
bytesRead += d.length;
});
diff --git a/test/parallel/test-tls-client-getephemeralkeyinfo.js b/test/parallel/test-tls-client-getephemeralkeyinfo.js
index c1e6597245a612..fd7dca4b6b7076 100644
--- a/test/parallel/test-tls-client-getephemeralkeyinfo.js
+++ b/test/parallel/test-tls-client-getephemeralkeyinfo.js
@@ -12,27 +12,27 @@ const fs = require('fs');
const key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem');
const cert = fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem');
-var ntests = 0;
-var nsuccess = 0;
+let ntests = 0;
+let nsuccess = 0;
function loadDHParam(n) {
- var path = common.fixturesDir;
+ let path = common.fixturesDir;
if (n !== 'error') path += '/keys';
return fs.readFileSync(path + '/dh' + n + '.pem');
}
-var cipherlist = {
+const cipherlist = {
'NOT_PFS': 'AES128-SHA256',
'DH': 'DHE-RSA-AES128-GCM-SHA256',
'ECDH': 'ECDHE-RSA-AES128-GCM-SHA256'
};
function test(size, type, name, next) {
- var cipher = type ? cipherlist[type] : cipherlist['NOT_PFS'];
+ const cipher = type ? cipherlist[type] : cipherlist['NOT_PFS'];
if (name) tls.DEFAULT_ECDH_CURVE = name;
- var options = {
+ const options = {
key: key,
cert: cert,
ciphers: cipher
@@ -40,7 +40,7 @@ function test(size, type, name, next) {
if (type === 'DH') options.dhparam = loadDHParam(size);
- var server = tls.createServer(options, function(conn) {
+ const server = tls.createServer(options, function(conn) {
assert.strictEqual(conn.getEphemeralKeyInfo(), null);
conn.end();
});
@@ -51,11 +51,11 @@ function test(size, type, name, next) {
}));
server.listen(0, '127.0.0.1', common.mustCall(function() {
- var client = tls.connect({
+ const client = tls.connect({
port: this.address().port,
rejectUnauthorized: false
}, function() {
- var ekeyinfo = client.getEphemeralKeyInfo();
+ const ekeyinfo = client.getEphemeralKeyInfo();
assert.strictEqual(ekeyinfo.type, type);
assert.strictEqual(ekeyinfo.size, size);
assert.strictEqual(ekeyinfo.name, name);
diff --git a/test/parallel/test-tls-client-mindhsize.js b/test/parallel/test-tls-client-mindhsize.js
index 1d812a72093ba9..76e1034621f031 100644
--- a/test/parallel/test-tls-client-mindhsize.js
+++ b/test/parallel/test-tls-client-mindhsize.js
@@ -1,35 +1,35 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
process.exit();
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
-var key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem');
-var cert = fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem');
+const fs = require('fs');
+const key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem');
+const cert = fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem');
-var nsuccess = 0;
-var nerror = 0;
+let nsuccess = 0;
+let nerror = 0;
function loadDHParam(n) {
- var path = common.fixturesDir;
+ let path = common.fixturesDir;
if (n !== 'error') path += '/keys';
return fs.readFileSync(path + '/dh' + n + '.pem');
}
function test(size, err, next) {
- var options = {
+ const options = {
key: key,
cert: cert,
dhparam: loadDHParam(size),
ciphers: 'DHE-RSA-AES128-GCM-SHA256'
};
- var server = tls.createServer(options, function(conn) {
+ const server = tls.createServer(options, function(conn) {
conn.end();
});
@@ -42,7 +42,7 @@ function test(size, err, next) {
// client set minimum DH parameter size to 2048 bits so that
// it fails when it make a connection to the tls server where
// dhparams is 1024 bits
- var client = tls.connect({
+ const client = tls.connect({
minDHSize: 2048,
port: this.address().port,
rejectUnauthorized: false
diff --git a/test/parallel/test-tls-client-resume.js b/test/parallel/test-tls-client-resume.js
index 75524a3a189b3e..96109d7656dd19 100644
--- a/test/parallel/test-tls-client-resume.js
+++ b/test/parallel/test-tls-client-resume.js
@@ -3,32 +3,32 @@
// Cache session and close connection. Use session on second connection.
// ASSERT resumption.
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem')
};
// create server
-var server = tls.Server(options, common.mustCall(function(socket) {
+const server = tls.Server(options, common.mustCall(function(socket) {
socket.end('Goodbye');
}, 2));
// start listening
server.listen(0, function() {
- var session1 = null;
- var client1 = tls.connect({
+ let session1 = null;
+ const client1 = tls.connect({
port: this.address().port,
rejectUnauthorized: false
}, function() {
@@ -40,13 +40,13 @@ server.listen(0, function() {
client1.on('close', function() {
console.log('close1');
- var opts = {
+ const opts = {
port: server.address().port,
rejectUnauthorized: false,
session: session1
};
- var client2 = tls.connect(opts, function() {
+ const client2 = tls.connect(opts, function() {
console.log('connect2');
assert.ok(client2.isSessionReused(), 'Session *should* be reused.');
});
diff --git a/test/parallel/test-tls-client-verify.js b/test/parallel/test-tls-client-verify.js
index a1fa35acf3c124..70d96ef1545ede 100644
--- a/test/parallel/test-tls-client-verify.js
+++ b/test/parallel/test-tls-client-verify.js
@@ -106,7 +106,7 @@ function testServers(index, servers, clientOptions, cb) {
function runTest(testIndex) {
- var tcase = testCases[testIndex];
+ const tcase = testCases[testIndex];
if (!tcase) return;
const clientOptions = {
diff --git a/test/parallel/test-tls-close-error.js b/test/parallel/test-tls-close-error.js
index 2da7a192c30ebc..6172be813e97ce 100644
--- a/test/parallel/test-tls-close-error.js
+++ b/test/parallel/test-tls-close-error.js
@@ -1,22 +1,22 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var server = tls.createServer({
+const server = tls.createServer({
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
}, function(c) {
}).listen(0, common.mustCall(function() {
- var c = tls.connect(this.address().port, function() {
+ const c = tls.connect(this.address().port, function() {
assert(false, 'should not be called');
});
diff --git a/test/parallel/test-tls-close-notify.js b/test/parallel/test-tls-close-notify.js
index 51b16746e30533..5d5bc1007749a7 100644
--- a/test/parallel/test-tls-close-notify.js
+++ b/test/parallel/test-tls-close-notify.js
@@ -1,15 +1,15 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var server = tls.createServer({
+const server = tls.createServer({
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
}, function(c) {
@@ -17,7 +17,7 @@ var server = tls.createServer({
if (c._handle.shutdownSSL() !== 1)
c._handle.shutdownSSL();
}).listen(0, common.mustCall(function() {
- var c = tls.connect(this.address().port, {
+ const c = tls.connect(this.address().port, {
rejectUnauthorized: false
}, common.mustCall(function() {
// Ensure that we receive 'end' event anyway
diff --git a/test/parallel/test-tls-connect-no-host.js b/test/parallel/test-tls-connect-no-host.js
index e2e0238ff8d0ad..2e4bcfbc6d4787 100644
--- a/test/parallel/test-tls-connect-no-host.js
+++ b/test/parallel/test-tls-connect-no-host.js
@@ -1,18 +1,18 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var assert = require('assert');
-var fs = require('fs');
-var path = require('path');
+const assert = require('assert');
+const fs = require('fs');
+const path = require('path');
-var cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
-var key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'));
+const cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
+const key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'));
// https://github.com/nodejs/node/issues/1489
// tls.connect(options) with no options.host should accept a cert with
@@ -21,7 +21,7 @@ tls.createServer({
key: key,
cert: cert
}).listen(0, function() {
- var socket = tls.connect({
+ const socket = tls.connect({
port: this.address().port,
ca: cert,
// No host set here. 'localhost' is the default,
diff --git a/test/parallel/test-tls-connect-pipe.js b/test/parallel/test-tls-connect-pipe.js
index 6ec218e00366f6..de60ae084624cf 100644
--- a/test/parallel/test-tls-connect-pipe.js
+++ b/test/parallel/test-tls-connect-pipe.js
@@ -1,27 +1,27 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
common.refreshTmpDir();
-var server = tls.Server(options, common.mustCall(function(socket) {
+const server = tls.Server(options, common.mustCall(function(socket) {
server.close();
}));
server.listen(common.PIPE, common.mustCall(function() {
- var options = { rejectUnauthorized: false };
- var client = tls.connect(common.PIPE, options, common.mustCall(function() {
+ const options = { rejectUnauthorized: false };
+ const client = tls.connect(common.PIPE, options, common.mustCall(function() {
client.end();
}));
}));
diff --git a/test/parallel/test-tls-connect-stream-writes.js b/test/parallel/test-tls-connect-stream-writes.js
index 8631ec575aae9b..2db130bc4b749e 100644
--- a/test/parallel/test-tls-connect-stream-writes.js
+++ b/test/parallel/test-tls-connect-stream-writes.js
@@ -6,34 +6,33 @@ const tls = require('tls');
const stream = require('stream');
const net = require('net');
-var server;
-var cert_dir = common.fixturesDir;
-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' };
-var content = 'hello world';
-var recv_bufs = [];
-var send_data = '';
-server = tls.createServer(options, function(s) {
+const cert_dir = common.fixturesDir;
+const 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' };
+const content = 'hello world';
+const recv_bufs = [];
+let send_data = '';
+const server = tls.createServer(options, function(s) {
s.on('data', function(c) {
recv_bufs.push(c);
});
});
server.listen(0, function() {
- var raw = net.connect(this.address().port);
+ const raw = net.connect(this.address().port);
- var pending = false;
+ let pending = false;
raw.on('readable', function() {
if (pending)
p._read();
});
- var p = new stream.Duplex({
+ let p = new stream.Duplex({
read: function read() {
pending = false;
- var chunk = raw.read();
+ const chunk = raw.read();
if (chunk) {
this.push(chunk);
} else {
@@ -45,11 +44,11 @@ server.listen(0, function() {
}
});
- var socket = tls.connect({
+ const socket = tls.connect({
socket: p,
rejectUnauthorized: false
}, function() {
- for (var i = 0; i < 50; ++i) {
+ for (let i = 0; i < 50; ++i) {
socket.write(content);
send_data += content;
}
@@ -59,6 +58,6 @@ server.listen(0, function() {
});
process.on('exit', function() {
- var recv_data = (Buffer.concat(recv_bufs)).toString();
+ const recv_data = (Buffer.concat(recv_bufs)).toString();
assert.strictEqual(send_data, recv_data);
});
diff --git a/test/parallel/test-tls-connect.js b/test/parallel/test-tls-connect.js
index cd4edd89f7b483..082e2e48a9dcc0 100644
--- a/test/parallel/test-tls-connect.js
+++ b/test/parallel/test-tls-connect.js
@@ -1,15 +1,15 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
-var path = require('path');
+const fs = require('fs');
+const path = require('path');
// https://github.com/joyent/node/issues/1218
// uncatchable exception on TLS connection error
diff --git a/test/parallel/test-tls-delayed-attach-error.js b/test/parallel/test-tls-delayed-attach-error.js
index a5fa91383d7d75..47be3f201b463e 100644
--- a/test/parallel/test-tls-delayed-attach-error.js
+++ b/test/parallel/test-tls-delayed-attach-error.js
@@ -1,24 +1,24 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
-var fs = require('fs');
-var net = require('net');
+const tls = require('tls');
+const fs = require('fs');
+const net = require('net');
-var bonkers = Buffer.alloc(1024, 42);
+const bonkers = Buffer.alloc(1024, 42);
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var server = net.createServer(common.mustCall(function(c) {
+const server = net.createServer(common.mustCall(function(c) {
setTimeout(common.mustCall(function() {
- var s = new tls.TLSSocket(c, {
+ const s = new tls.TLSSocket(c, {
isServer: true,
secureContext: tls.createSecureContext(options)
});
@@ -31,7 +31,7 @@ var server = net.createServer(common.mustCall(function(c) {
});
}), 200);
})).listen(0, function() {
- var c = net.connect({port: this.address().port}, function() {
+ const c = net.connect({port: this.address().port}, function() {
c.write(bonkers);
});
});
diff --git a/test/parallel/test-tls-delayed-attach.js b/test/parallel/test-tls-delayed-attach.js
index b1e4beb2313c9a..d757ca756c3a09 100644
--- a/test/parallel/test-tls-delayed-attach.js
+++ b/test/parallel/test-tls-delayed-attach.js
@@ -1,27 +1,27 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
-var net = require('net');
+const fs = require('fs');
+const net = require('net');
-var sent = 'hello world';
-var received = '';
+const sent = 'hello world';
+let received = '';
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var server = net.createServer(function(c) {
+const server = net.createServer(function(c) {
setTimeout(function() {
- var s = new tls.TLSSocket(c, {
+ const s = new tls.TLSSocket(c, {
isServer: true,
secureContext: tls.createSecureContext(options)
});
@@ -36,7 +36,7 @@ var server = net.createServer(function(c) {
});
}, 200);
}).listen(0, function() {
- var c = tls.connect(this.address().port, {
+ const c = tls.connect(this.address().port, {
rejectUnauthorized: false
}, function() {
c.end(sent);
diff --git a/test/parallel/test-tls-dhe.js b/test/parallel/test-tls-dhe.js
index 92ab415e3ba0a6..34f403ffed3254 100644
--- a/test/parallel/test-tls-dhe.js
+++ b/test/parallel/test-tls-dhe.js
@@ -1,37 +1,37 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var spawn = require('child_process').spawn;
-var fs = require('fs');
-var key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem');
-var cert = fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem');
-var nsuccess = 0;
-var ntests = 0;
-var ciphers = 'DHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
+const spawn = require('child_process').spawn;
+const fs = require('fs');
+const key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem');
+const cert = fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem');
+let nsuccess = 0;
+let ntests = 0;
+const ciphers = 'DHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
function loadDHParam(n) {
- var path = common.fixturesDir;
+ let path = common.fixturesDir;
if (n !== 'error') path += '/keys';
return fs.readFileSync(path + '/dh' + n + '.pem');
}
function test(keylen, expectedCipher, cb) {
- var options = {
+ const options = {
key: key,
cert: cert,
ciphers: ciphers,
dhparam: loadDHParam(keylen)
};
- var server = tls.createServer(options, function(conn) {
+ const server = tls.createServer(options, function(conn) {
conn.end();
});
@@ -41,15 +41,15 @@ function test(keylen, expectedCipher, cb) {
});
server.listen(0, '127.0.0.1', function() {
- var args = ['s_client', '-connect', `127.0.0.1:${this.address().port}`,
- '-cipher', ciphers];
+ const args = ['s_client', '-connect', `127.0.0.1:${this.address().port}`,
+ '-cipher', ciphers];
// for the performance and stability issue in s_client on Windows
if (common.isWindows)
args.push('-no_rand_screen');
- var client = spawn(common.opensslCli, args);
- var out = '';
+ const client = spawn(common.opensslCli, args);
+ let out = '';
client.stdout.setEncoding('utf8');
client.stdout.on('data', function(d) {
out += d;
@@ -57,7 +57,7 @@ function test(keylen, expectedCipher, cb) {
client.stdout.on('end', function() {
// DHE key length can be checked -brief option in s_client but it
// is only supported in openssl 1.0.2 so we cannot check it.
- var reg = new RegExp('Cipher : ' + expectedCipher);
+ const reg = new RegExp('Cipher : ' + expectedCipher);
if (reg.test(out)) {
nsuccess++;
server.close();
diff --git a/test/parallel/test-tls-ecdh-disable.js b/test/parallel/test-tls-ecdh-disable.js
index c2a7440a686a10..a0555e87781f59 100644
--- a/test/parallel/test-tls-ecdh-disable.js
+++ b/test/parallel/test-tls-ecdh-disable.js
@@ -1,27 +1,27 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var exec = require('child_process').exec;
-var fs = require('fs');
+const exec = require('child_process').exec;
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'),
ciphers: 'ECDHE-RSA-RC4-SHA',
ecdhCurve: false
};
-var server = tls.createServer(options, common.fail);
+const server = tls.createServer(options, common.fail);
server.listen(0, '127.0.0.1', common.mustCall(function() {
- var cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers +
+ let cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers +
` -connect 127.0.0.1:${this.address().port}`;
// for the performance and stability issue in s_client on Windows
diff --git a/test/parallel/test-tls-econnreset.js b/test/parallel/test-tls-econnreset.js
index d9f6fffd326409..0ec7264c4147e4 100644
--- a/test/parallel/test-tls-econnreset.js
+++ b/test/parallel/test-tls-econnreset.js
@@ -1,14 +1,14 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var cacert =
+const cacert =
`-----BEGIN CERTIFICATE-----
MIIBxTCCAX8CAnXnMA0GCSqGSIb3DQEBBQUAMH0xCzAJBgNVBAYTAlVTMQswCQYD
VQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQU3Ryb25n
@@ -22,7 +22,7 @@ AVkCAwEAATANBgkqhkiG9w0BAQUFAAMxALA1uS4CqQXRSAyYTfio5oyLGz71a+NM
+0AFLBwh5AQjhGd0FcenU4OfHxyDEOJT/Q==
-----END CERTIFICATE-----`;
-var cert =
+const cert =
`-----BEGIN CERTIFICATE-----
MIIBfDCCATYCAgQaMA0GCSqGSIb3DQEBBQUAMH0xCzAJBgNVBAYTAlVTMQswCQYD
VQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQU3Ryb25n
@@ -34,7 +34,7 @@ AQABoxkwFzAVBgNVHREEDjAMhwQAAAAAhwR/AAABMA0GCSqGSIb3DQEBBQUAAzEA
cGpYrhkrb7mIh9DNhV0qp7pGjqBzlHqB7KQXw2luLDp//6dyHBMexDCQznkhZKRU
-----END CERTIFICATE-----`;
-var key =
+const key =
`-----BEGIN RSA PRIVATE KEY-----
MIH0AgEAAjEAx+QjQtZTXmk9TAhA0ydFWGE6JuLRNCYBq7wUG2DAR8YrTVal8ZRo
mvVrjUrxSrvHAgMBAAECMBCGccvSwC2r8Z9Zh1JtirQVxaL1WWpAQfmVwLe0bAgg
@@ -44,30 +44,31 @@ pQIZAMMwxuS3XiO7two2sQF6W+JTYyX1DPCwAQIZAOYg1TvEGT38k8e8jygv8E8w
YqrWTeQFNQ==
-----END RSA PRIVATE KEY-----`;
-var ca = [ cert, cacert ];
+const ca = [ cert, cacert ];
-var clientError = null;
-var connectError = null;
+let clientError = null;
+let connectError = null;
-var server = tls.createServer({ ca: ca, cert: cert, key: key }, function(conn) {
- throw 'unreachable';
-}).on('tlsClientError', function(err, conn) {
- assert(!clientError && conn);
- clientError = err;
-}).listen(0, function() {
- var options = {
+const server =
+ tls.createServer({ ca: ca, cert: cert, key: key }, function(conn) {
+ throw 'unreachable';
+ }).on('tlsClientError', function(err, conn) {
+ assert(!clientError && conn);
+ clientError = err;
+ }).listen(0, function() {
+ const options = {
ciphers: 'AES128-GCM-SHA256',
port: this.address().port,
ca: ca
- };
- tls.connect(options).on('error', function(err) {
- assert(!connectError);
+ };
+ tls.connect(options).on('error', function(err) {
+ assert(!connectError);
- connectError = err;
- this.destroy();
- server.close();
- }).write('123');
-});
+ connectError = err;
+ this.destroy();
+ server.close();
+ }).write('123');
+ });
process.on('exit', function() {
assert(clientError);
diff --git a/test/parallel/test-tls-env-bad-extra-ca.js b/test/parallel/test-tls-env-bad-extra-ca.js
index 1862366e013af0..cb6c4ba489fcd6 100644
--- a/test/parallel/test-tls-env-bad-extra-ca.js
+++ b/test/parallel/test-tls-env-bad-extra-ca.js
@@ -22,11 +22,11 @@ const env = {
NODE_EXTRA_CA_CERTS: common.fixturesDir + '/no-such-file-exists',
};
-var opts = {
+const opts = {
env: env,
silent: true,
};
-var stderr = '';
+let stderr = '';
fork(__filename, opts)
.on('exit', common.mustCall(function(status) {
diff --git a/test/parallel/test-tls-fast-writing.js b/test/parallel/test-tls-fast-writing.js
index 034a6296659bdd..b2d6fe6eee88a3 100644
--- a/test/parallel/test-tls-fast-writing.js
+++ b/test/parallel/test-tls-fast-writing.js
@@ -1,23 +1,23 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var dir = common.fixturesDir;
-var options = { key: fs.readFileSync(dir + '/test_key.pem'),
- cert: fs.readFileSync(dir + '/test_cert.pem'),
- ca: [ fs.readFileSync(dir + '/test_ca.pem') ] };
+const dir = common.fixturesDir;
+const options = { key: fs.readFileSync(dir + '/test_key.pem'),
+ cert: fs.readFileSync(dir + '/test_cert.pem'),
+ ca: [ fs.readFileSync(dir + '/test_ca.pem') ] };
-var server = tls.createServer(options, onconnection);
-var gotChunk = false;
-var gotDrain = false;
+const server = tls.createServer(options, onconnection);
+let gotChunk = false;
+let gotDrain = false;
setTimeout(function() {
console.log('not ok - timed out');
@@ -41,9 +41,9 @@ function onconnection(conn) {
}
server.listen(0, function() {
- var chunk = Buffer.alloc(1024, 'x');
- var opt = { port: this.address().port, rejectUnauthorized: false };
- var conn = tls.connect(opt, function() {
+ const chunk = Buffer.alloc(1024, 'x');
+ const opt = { port: this.address().port, rejectUnauthorized: false };
+ const conn = tls.connect(opt, function() {
conn.on('drain', ondrain);
write();
});
diff --git a/test/parallel/test-tls-friendly-error-message.js b/test/parallel/test-tls-friendly-error-message.js
index 9ae69f4016e319..3f3bfe9133fcd6 100644
--- a/test/parallel/test-tls-friendly-error-message.js
+++ b/test/parallel/test-tls-friendly-error-message.js
@@ -17,7 +17,7 @@ tls.createServer({ key: key, cert: cert }, common.mustCall(function(conn) {
conn.end();
this.close();
})).listen(0, common.mustCall(function() {
- var options = { port: this.address().port, rejectUnauthorized: true };
+ const options = { port: this.address().port, rejectUnauthorized: true };
tls.connect(options).on('error', common.mustCall(function(err) {
assert.strictEqual(err.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE');
assert.strictEqual(err.message, 'unable to verify the first certificate');
diff --git a/test/parallel/test-tls-handshake-error.js b/test/parallel/test-tls-handshake-error.js
index e76a0961fb7ad6..39ea3a517247a0 100644
--- a/test/parallel/test-tls-handshake-error.js
+++ b/test/parallel/test-tls-handshake-error.js
@@ -1,23 +1,23 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var server = tls.createServer({
+const server = tls.createServer({
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'),
rejectUnauthorized: true
}, function(c) {
}).listen(0, common.mustCall(function() {
- var c = tls.connect({
+ const c = tls.connect({
port: this.address().port,
ciphers: 'RC4'
}, function() {
diff --git a/test/parallel/test-tls-handshake-nohang.js b/test/parallel/test-tls-handshake-nohang.js
index 052833a50e3462..039c55b486d6a2 100644
--- a/test/parallel/test-tls-handshake-nohang.js
+++ b/test/parallel/test-tls-handshake-nohang.js
@@ -1,11 +1,11 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
// neither should hang
tls.createSecurePair(null, false, false, false);
diff --git a/test/parallel/test-tls-honorcipherorder.js b/test/parallel/test-tls-honorcipherorder.js
index 81c2440fe26d23..f7894e46706da9 100644
--- a/test/parallel/test-tls-honorcipherorder.js
+++ b/test/parallel/test-tls-honorcipherorder.js
@@ -1,27 +1,27 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
-var nconns = 0;
+const fs = require('fs');
+let nconns = 0;
// We explicitly set TLS version to 1.2 so as to be safe when the
// default method is updated in the future
-var SSL_Method = 'TLSv1_2_method';
-var localhost = '127.0.0.1';
+const SSL_Method = 'TLSv1_2_method';
+const localhost = '127.0.0.1';
process.on('exit', function() {
assert.equal(nconns, 6);
});
function test(honorCipherOrder, clientCipher, expectedCipher, cb) {
- var soptions = {
+ const soptions = {
secureProtocol: SSL_Method,
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'),
@@ -30,7 +30,7 @@ function test(honorCipherOrder, clientCipher, expectedCipher, cb) {
honorCipherOrder: !!honorCipherOrder
};
- var server = tls.createServer(soptions, function(cleartextStream) {
+ const server = tls.createServer(soptions, function(cleartextStream) {
nconns++;
// End socket to send CLOSE_NOTIFY and TCP FIN packet, otherwise
@@ -38,7 +38,7 @@ function test(honorCipherOrder, clientCipher, expectedCipher, cb) {
cleartextStream.end();
});
server.listen(0, localhost, function() {
- var coptions = {
+ const coptions = {
rejectUnauthorized: false,
secureProtocol: SSL_Method
};
@@ -46,8 +46,8 @@ function test(honorCipherOrder, clientCipher, expectedCipher, cb) {
coptions.ciphers = clientCipher;
}
const port = this.address().port;
- var client = tls.connect(port, localhost, coptions, function() {
- var cipher = client.getCipher();
+ const client = tls.connect(port, localhost, coptions, function() {
+ const cipher = client.getCipher();
client.end();
server.close();
assert.equal(cipher.name, expectedCipher);
diff --git a/test/parallel/test-tls-inception.js b/test/parallel/test-tls-inception.js
index 760887d9f25264..183fbe587b366c 100644
--- a/test/parallel/test-tls-inception.js
+++ b/test/parallel/test-tls-inception.js
@@ -54,7 +54,7 @@ a.listen(0, function() {
rejectUnauthorized: false
});
ssl.setEncoding('utf8');
- var buf = '';
+ let buf = '';
ssl.on('data', function(data) {
buf += data;
});
diff --git a/test/parallel/test-tls-invoke-queued.js b/test/parallel/test-tls-invoke-queued.js
index 4008e5f099e4bc..bd3ad43fe653e5 100644
--- a/test/parallel/test-tls-invoke-queued.js
+++ b/test/parallel/test-tls-invoke-queued.js
@@ -1,19 +1,19 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var received = '';
+let received = '';
-var server = tls.createServer({
+const server = tls.createServer({
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
}, function(c) {
@@ -26,7 +26,7 @@ var server = tls.createServer({
server.close();
}).listen(0, common.mustCall(function() {
- var c = tls.connect(this.address().port, {
+ const c = tls.connect(this.address().port, {
rejectUnauthorized: false
}, common.mustCall(function() {
c.on('data', function(chunk) {
diff --git a/test/parallel/test-tls-js-stream.js b/test/parallel/test-tls-js-stream.js
index 08095fa99538cf..b8e14cb30ed8e6 100644
--- a/test/parallel/test-tls-js-stream.js
+++ b/test/parallel/test-tls-js-stream.js
@@ -1,23 +1,23 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var stream = require('stream');
-var fs = require('fs');
-var net = require('net');
+const stream = require('stream');
+const fs = require('fs');
+const net = require('net');
-var connected = {
+const connected = {
client: 0,
server: 0
};
-var server = tls.createServer({
+const server = tls.createServer({
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
}, function(c) {
@@ -25,19 +25,19 @@ var server = tls.createServer({
connected.server++;
c.end('ohai');
}).listen(0, function() {
- var raw = net.connect(this.address().port);
+ const raw = net.connect(this.address().port);
- var pending = false;
+ let pending = false;
raw.on('readable', function() {
if (pending)
p._read();
});
- var p = new stream.Duplex({
+ let p = new stream.Duplex({
read: function read() {
pending = false;
- var chunk = raw.read();
+ const chunk = raw.read();
if (chunk) {
console.log('read', chunk);
this.push(chunk);
@@ -51,7 +51,7 @@ var server = tls.createServer({
}
});
- var socket = tls.connect({
+ const socket = tls.connect({
socket: p,
rejectUnauthorized: false
}, function() {
diff --git a/test/parallel/test-tls-legacy-onselect.js b/test/parallel/test-tls-legacy-onselect.js
index 72c748248e448d..9af65c43a0661c 100644
--- a/test/parallel/test-tls-legacy-onselect.js
+++ b/test/parallel/test-tls-legacy-onselect.js
@@ -1,15 +1,15 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
-var net = require('net');
+const tls = require('tls');
+const net = require('net');
-var server = net.Server(common.mustCall(function(raw) {
- var pair = tls.createSecurePair(null, true, false, false);
+const server = net.Server(common.mustCall(function(raw) {
+ const pair = tls.createSecurePair(null, true, false, false);
pair.on('error', function() {});
pair.ssl.setSNICallback(common.mustCall(function() {
raw.destroy();
diff --git a/test/parallel/test-tls-max-send-fragment.js b/test/parallel/test-tls-max-send-fragment.js
index 64dd14698916c8..4b81be35e34522 100644
--- a/test/parallel/test-tls-max-send-fragment.js
+++ b/test/parallel/test-tls-max-send-fragment.js
@@ -1,20 +1,20 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var buf = Buffer.allocUnsafe(10000);
-var received = 0;
-var maxChunk = 768;
+const buf = Buffer.allocUnsafe(10000);
+let received = 0;
+const maxChunk = 768;
-var server = tls.createServer({
+const server = tls.createServer({
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
}, function(c) {
@@ -27,7 +27,7 @@ var server = tls.createServer({
c.end(buf);
}).listen(0, common.mustCall(function() {
- var c = tls.connect(this.address().port, {
+ const c = tls.connect(this.address().port, {
rejectUnauthorized: false
}, common.mustCall(function() {
c.on('data', function(chunk) {
diff --git a/test/parallel/test-tls-multi-key.js b/test/parallel/test-tls-multi-key.js
index e29f5ee522829e..e3d5d661a799a7 100644
--- a/test/parallel/test-tls-multi-key.js
+++ b/test/parallel/test-tls-multi-key.js
@@ -1,15 +1,15 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
-var fs = require('fs');
+const tls = require('tls');
+const fs = require('fs');
-var options = {
+const options = {
key: [
fs.readFileSync(common.fixturesDir + '/keys/ec-key.pem'),
fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
@@ -20,17 +20,17 @@ var options = {
]
};
-var ciphers = [];
+const ciphers = [];
-var server = tls.createServer(options, function(conn) {
+const server = tls.createServer(options, function(conn) {
conn.end('ok');
}).listen(0, function() {
- var ecdsa = tls.connect(this.address().port, {
+ const ecdsa = tls.connect(this.address().port, {
ciphers: 'ECDHE-ECDSA-AES256-GCM-SHA384',
rejectUnauthorized: false
}, function() {
ciphers.push(ecdsa.getCipher());
- var rsa = tls.connect(server.address().port, {
+ const rsa = tls.connect(server.address().port, {
ciphers: 'ECDHE-RSA-AES256-GCM-SHA384',
rejectUnauthorized: false
}, function() {
diff --git a/test/parallel/test-tls-no-rsa-key.js b/test/parallel/test-tls-no-rsa-key.js
index cc04534bf91973..233d8453db1318 100644
--- a/test/parallel/test-tls-no-rsa-key.js
+++ b/test/parallel/test-tls-no-rsa-key.js
@@ -1,24 +1,24 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/ec-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/ec-cert.pem')
};
-var server = tls.createServer(options, function(conn) {
+const server = tls.createServer(options, function(conn) {
conn.end('ok');
}).listen(0, common.mustCall(function() {
- var c = tls.connect(this.address().port, {
+ const c = tls.connect(this.address().port, {
rejectUnauthorized: false
}, common.mustCall(function() {
c.on('end', common.mustCall(function() {
diff --git a/test/parallel/test-tls-no-sslv23.js b/test/parallel/test-tls-no-sslv23.js
index 0db61afe0e97ec..ff1214d167e6a0 100644
--- a/test/parallel/test-tls-no-sslv23.js
+++ b/test/parallel/test-tls-no-sslv23.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
assert.throws(function() {
tls.createSecureContext({ secureProtocol: 'blargh' });
diff --git a/test/parallel/test-tls-npn-server-client.js b/test/parallel/test-tls-npn-server-client.js
index c203d950051112..54d20cec6e78b8 100644
--- a/test/parallel/test-tls-npn-server-client.js
+++ b/test/parallel/test-tls-npn-server-client.js
@@ -13,7 +13,7 @@ if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
function filenamePEM(n) {
@@ -24,7 +24,7 @@ function loadPEM(n) {
return fs.readFileSync(filenamePEM(n));
}
-var serverOptions = {
+const serverOptions = {
key: loadPEM('agent2-key'),
cert: loadPEM('agent2-cert'),
crl: loadPEM('ca2-crl'),
@@ -38,7 +38,7 @@ var serverOptions = {
NPNProtocols: ['a', 'b', 'c']
};
-var clientsOptions = [{
+const clientsOptions = [{
port: undefined,
key: serverOptions.key,
cert: serverOptions.cert,
@@ -70,7 +70,7 @@ var clientsOptions = [{
const serverResults = [];
const clientsResults = [];
-var server = tls.createServer(serverOptions, function(c) {
+const server = tls.createServer(serverOptions, function(c) {
serverResults.push(c.npnProtocol);
});
server.listen(0, startTest);
@@ -78,7 +78,7 @@ server.listen(0, startTest);
function startTest() {
function connectClient(options, callback) {
options.port = server.address().port;
- var client = tls.connect(options, function() {
+ const client = tls.connect(options, function() {
clientsResults.push(client.npnProtocol);
client.destroy();
diff --git a/test/parallel/test-tls-over-http-tunnel.js b/test/parallel/test-tls-over-http-tunnel.js
index c030c7482ff6dd..4e03bcaf537f26 100644
--- a/test/parallel/test-tls-over-http-tunnel.js
+++ b/test/parallel/test-tls-over-http-tunnel.js
@@ -1,28 +1,28 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var fs = require('fs');
-var net = require('net');
-var http = require('http');
+const fs = require('fs');
+const net = require('net');
+const http = require('http');
-var gotRequest = false;
+let gotRequest = false;
-var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
-var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');
+const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
+const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');
-var options = {
+const options = {
key: key,
cert: cert
};
-var server = https.createServer(options, function(req, res) {
+const server = https.createServer(options, function(req, res) {
console.log('SERVER: got request');
res.writeHead(200, {
'content-type': 'text/plain'
@@ -31,10 +31,10 @@ var server = https.createServer(options, function(req, res) {
res.end('hello world\n');
});
-var proxy = net.createServer(function(clientSocket) {
+const proxy = net.createServer(function(clientSocket) {
console.log('PROXY: got a client connection');
- var serverSocket = null;
+ let serverSocket = null;
clientSocket.on('data', function(chunk) {
if (!serverSocket) {
@@ -80,7 +80,7 @@ server.listen(0);
proxy.listen(0, function() {
console.log('CLIENT: Making CONNECT request');
- var req = http.request({
+ const req = http.request({
port: this.address().port,
method: 'CONNECT',
path: `localhost:${server.address().port}`,
diff --git a/test/parallel/test-tls-pause.js b/test/parallel/test-tls-pause.js
index 7f4e02a1bfa96d..911ea7097b1e70 100644
--- a/test/parallel/test-tls-pause.js
+++ b/test/parallel/test-tls-pause.js
@@ -1,26 +1,26 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
-var path = require('path');
+const fs = require('fs');
+const path = require('path');
-var options = {
+const options = {
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
};
-var bufSize = 1024 * 1024;
-var sent = 0;
-var received = 0;
+const bufSize = 1024 * 1024;
+let sent = 0;
+let received = 0;
-var server = tls.Server(options, function(socket) {
+const server = tls.Server(options, function(socket) {
socket.pipe(socket);
socket.on('data', function(c) {
console.error('data', c.length);
@@ -28,8 +28,8 @@ var server = tls.Server(options, function(socket) {
});
server.listen(0, function() {
- var resumed = false;
- var client = tls.connect({
+ let resumed = false;
+ const client = tls.connect({
port: this.address().port,
rejectUnauthorized: false
}, function() {
@@ -39,7 +39,7 @@ server.listen(0, function() {
send();
function send() {
console.error('sending');
- var ret = client.write(Buffer.allocUnsafe(bufSize));
+ const ret = client.write(Buffer.allocUnsafe(bufSize));
console.error('write => %j', ret);
if (false !== ret) {
console.error('write again');
diff --git a/test/parallel/test-tls-peer-certificate-encoding.js b/test/parallel/test-tls-peer-certificate-encoding.js
index b59d10faa78bc1..545caf403e103c 100644
--- a/test/parallel/test-tls-peer-certificate-encoding.js
+++ b/test/parallel/test-tls-peer-certificate-encoding.js
@@ -1,32 +1,32 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
-var util = require('util');
-var join = require('path').join;
+const fs = require('fs');
+const util = require('util');
+const join = require('path').join;
-var options = {
+const options = {
key: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent5-key.pem')),
cert: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent5-cert.pem')),
ca: [ fs.readFileSync(join(common.fixturesDir, 'keys', 'ca2-cert.pem')) ]
};
-var server = tls.createServer(options, function(cleartext) {
+const server = tls.createServer(options, function(cleartext) {
cleartext.end('World');
});
server.listen(0, common.mustCall(function() {
- var socket = tls.connect({
+ const socket = tls.connect({
port: this.address().port,
rejectUnauthorized: false
}, common.mustCall(function() {
- var peerCert = socket.getPeerCertificate();
+ const peerCert = socket.getPeerCertificate();
console.error(util.inspect(peerCert));
assert.equal(peerCert.subject.CN, 'Ádám Lippai');
diff --git a/test/parallel/test-tls-peer-certificate-multi-keys.js b/test/parallel/test-tls-peer-certificate-multi-keys.js
index 55bc9f40d3a240..693bb4cb3fa812 100644
--- a/test/parallel/test-tls-peer-certificate-multi-keys.js
+++ b/test/parallel/test-tls-peer-certificate-multi-keys.js
@@ -1,31 +1,31 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
-var util = require('util');
-var join = require('path').join;
+const fs = require('fs');
+const util = require('util');
+const join = require('path').join;
-var options = {
+const options = {
key: fs.readFileSync(join(common.fixturesDir, 'agent.key')),
cert: fs.readFileSync(join(common.fixturesDir, 'multi-alice.crt'))
};
-var server = tls.createServer(options, function(cleartext) {
+const server = tls.createServer(options, function(cleartext) {
cleartext.end('World');
});
server.listen(0, common.mustCall(function() {
- var socket = tls.connect({
+ const socket = tls.connect({
port: this.address().port,
rejectUnauthorized: false
}, common.mustCall(function() {
- var peerCert = socket.getPeerCertificate();
+ const peerCert = socket.getPeerCertificate();
console.error(util.inspect(peerCert));
assert.deepStrictEqual(
peerCert.subject.OU,
diff --git a/test/parallel/test-tls-pfx-gh-5100-regr.js b/test/parallel/test-tls-pfx-gh-5100-regr.js
index 4670d9ea3da740..142a7de10b841a 100644
--- a/test/parallel/test-tls-pfx-gh-5100-regr.js
+++ b/test/parallel/test-tls-pfx-gh-5100-regr.js
@@ -28,7 +28,7 @@ const server = tls.createServer({
);
c.end();
})).listen(0, function() {
- var client = tls.connect({
+ const client = tls.connect({
port: this.address().port,
pfx: pfx,
passphrase: 'sample',
diff --git a/test/parallel/test-tls-request-timeout.js b/test/parallel/test-tls-request-timeout.js
index fc793def177f3a..4873a3c696458f 100644
--- a/test/parallel/test-tls-request-timeout.js
+++ b/test/parallel/test-tls-request-timeout.js
@@ -1,22 +1,22 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var server = tls.Server(options, common.mustCall(function(socket) {
- var s = socket.setTimeout(100);
+const server = tls.Server(options, common.mustCall(function(socket) {
+ const s = socket.setTimeout(100);
assert.ok(s instanceof tls.TLSSocket);
socket.on('timeout', common.mustCall(function(err) {
diff --git a/test/parallel/test-tls-securepair-fiftharg.js b/test/parallel/test-tls-securepair-fiftharg.js
index b4610117889cc2..06b29b8736826d 100644
--- a/test/parallel/test-tls-securepair-fiftharg.js
+++ b/test/parallel/test-tls-securepair-fiftharg.js
@@ -10,7 +10,7 @@ const sslcontext = tls.createSecureContext({
key: fs.readFileSync(common.fixturesDir + '/test_key.pem')
});
-var catchedServername;
+let catchedServername;
const pair = tls.createSecurePair(sslcontext, true, false, false, {
SNICallback: common.mustCall(function(servername, cb) {
catchedServername = servername;
diff --git a/test/parallel/test-tls-securepair-server.js b/test/parallel/test-tls-securepair-server.js
index 24ac2177c54536..65a7d91a0ca606 100644
--- a/test/parallel/test-tls-securepair-server.js
+++ b/test/parallel/test-tls-securepair-server.js
@@ -1,31 +1,31 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var join = require('path').join;
-var net = require('net');
-var fs = require('fs');
-var spawn = require('child_process').spawn;
+const join = require('path').join;
+const net = require('net');
+const fs = require('fs');
+const spawn = require('child_process').spawn;
-var key = fs.readFileSync(join(common.fixturesDir, 'agent.key')).toString();
-var cert = fs.readFileSync(join(common.fixturesDir, 'agent.crt')).toString();
+const key = fs.readFileSync(join(common.fixturesDir, 'agent.key')).toString();
+const cert = fs.readFileSync(join(common.fixturesDir, 'agent.crt')).toString();
function log(a) {
console.error('***server*** ' + a);
}
-var server = net.createServer(common.mustCall(function(socket) {
+const server = net.createServer(common.mustCall(function(socket) {
log('connection fd=' + socket.fd);
- var sslcontext = tls.createSecureContext({key: key, cert: cert});
+ const sslcontext = tls.createSecureContext({key: key, cert: cert});
sslcontext.context.setCiphers('RC4-SHA:AES128-SHA:AES256-SHA');
- var pair = tls.createSecurePair(sslcontext, true);
+ const pair = tls.createSecurePair(sslcontext, true);
assert.ok(pair.encrypted.writable);
assert.ok(pair.cleartext.writable);
@@ -84,23 +84,23 @@ var server = net.createServer(common.mustCall(function(socket) {
});
}));
-var gotHello = false;
-var sentWorld = false;
-var gotWorld = false;
+let gotHello = false;
+let sentWorld = false;
+let gotWorld = false;
server.listen(0, common.mustCall(function() {
// To test use: openssl s_client -connect localhost:8000
- var args = ['s_client', '-connect', `127.0.0.1:${this.address().port}`];
+ const args = ['s_client', '-connect', `127.0.0.1:${this.address().port}`];
// for the performance and stability issue in s_client on Windows
if (common.isWindows)
args.push('-no_rand_screen');
- var client = spawn(common.opensslCli, args);
+ const client = spawn(common.opensslCli, args);
- var out = '';
+ let out = '';
client.stdout.setEncoding('utf8');
client.stdout.on('data', function(d) {
diff --git a/test/parallel/test-tls-session-cache.js b/test/parallel/test-tls-session-cache.js
index 60a85701796d72..5e3ae5128ecfaf 100644
--- a/test/parallel/test-tls-session-cache.js
+++ b/test/parallel/test-tls-session-cache.js
@@ -34,9 +34,9 @@ function doTest(testOptions, callback) {
ca: [cert],
requestCert: true
};
- var requestCount = 0;
- var resumeCount = 0;
- var session;
+ let requestCount = 0;
+ let resumeCount = 0;
+ let session;
const server = tls.createServer(options, function(cleartext) {
cleartext.on('error', function(er) {
@@ -90,7 +90,7 @@ function doTest(testOptions, callback) {
const client = spawn(common.opensslCli, args, {
stdio: [ 0, 1, 'pipe' ]
});
- var err = '';
+ let err = '';
client.stderr.setEncoding('utf8');
client.stderr.on('data', function(chunk) {
err += chunk;
diff --git a/test/parallel/test-tls-set-ciphers.js b/test/parallel/test-tls-set-ciphers.js
index 5a85e3b22e4c62..91eb1bea6e2f2f 100644
--- a/test/parallel/test-tls-set-ciphers.js
+++ b/test/parallel/test-tls-set-ciphers.js
@@ -34,7 +34,7 @@ const server = tls.createServer(options, common.mustCall(function(conn) {
}));
server.listen(0, '127.0.0.1', function() {
- var cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers +
+ let cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers +
` -connect 127.0.0.1:${this.address().port}`;
// for the performance and stability issue in s_client on Windows
diff --git a/test/parallel/test-tls-sni-option.js b/test/parallel/test-tls-sni-option.js
index 42d6a9068b00d5..f1613d2e9fbdce 100644
--- a/test/parallel/test-tls-sni-option.js
+++ b/test/parallel/test-tls-sni-option.js
@@ -13,7 +13,7 @@ if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
function filenamePEM(n) {
return require('path').join(common.fixturesDir, 'keys', n + '.pem');
@@ -23,13 +23,13 @@ function loadPEM(n) {
return fs.readFileSync(filenamePEM(n));
}
-var serverOptions = {
+const serverOptions = {
key: loadPEM('agent2-key'),
cert: loadPEM('agent2-cert'),
requestCert: true,
rejectUnauthorized: false,
SNICallback: function(servername, callback) {
- var context = SNIContexts[servername];
+ const context = SNIContexts[servername];
// Just to test asynchronous callback
setTimeout(function() {
@@ -45,7 +45,7 @@ var serverOptions = {
}
};
-var SNIContexts = {
+let SNIContexts = {
'a.example.com': {
key: loadPEM('agent1-key'),
cert: loadPEM('agent1-cert'),
@@ -60,7 +60,7 @@ var SNIContexts = {
}
};
-var clientsOptions = [{
+const clientsOptions = [{
port: undefined,
key: loadPEM('agent1-key'),
cert: loadPEM('agent1-cert'),
@@ -104,7 +104,7 @@ const clientErrors = [];
let serverError;
let clientError;
-var server = tls.createServer(serverOptions, function(c) {
+const server = tls.createServer(serverOptions, function(c) {
serverResults.push({ sni: c.servername, authorized: c.authorized });
});
@@ -117,12 +117,12 @@ server.listen(0, startTest);
function startTest() {
function connectClient(i, callback) {
- var options = clientsOptions[i];
+ const options = clientsOptions[i];
clientError = null;
serverError = null;
options.port = server.address().port;
- var client = tls.connect(options, function() {
+ const client = tls.connect(options, function() {
clientResults.push(
/Hostname\/IP doesn't/.test(client.authorizationError || ''));
client.destroy();
diff --git a/test/parallel/test-tls-sni-server-client.js b/test/parallel/test-tls-sni-server-client.js
index e743078bca789e..dad4ef20619cc7 100644
--- a/test/parallel/test-tls-sni-server-client.js
+++ b/test/parallel/test-tls-sni-server-client.js
@@ -13,7 +13,7 @@ if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
function filenamePEM(n) {
return require('path').join(common.fixturesDir, 'keys', n + '.pem');
@@ -23,12 +23,12 @@ function loadPEM(n) {
return fs.readFileSync(filenamePEM(n));
}
-var serverOptions = {
+const serverOptions = {
key: loadPEM('agent2-key'),
cert: loadPEM('agent2-cert')
};
-var SNIContexts = {
+const SNIContexts = {
'a.example.com': {
key: loadPEM('agent1-key'),
cert: loadPEM('agent1-cert')
@@ -44,7 +44,7 @@ var SNIContexts = {
}
};
-var clientsOptions = [{
+const clientsOptions = [{
port: undefined,
ca: [loadPEM('ca1-cert')],
servername: 'a.example.com',
@@ -74,7 +74,7 @@ var clientsOptions = [{
const serverResults = [];
const clientResults = [];
-var server = tls.createServer(serverOptions, function(c) {
+const server = tls.createServer(serverOptions, function(c) {
serverResults.push(c.servername);
});
@@ -85,15 +85,15 @@ server.addContext('chain.example.com', SNIContexts['chain.example.com']);
server.listen(0, startTest);
function startTest() {
- var i = 0;
+ let i = 0;
function start() {
// No options left
if (i === clientsOptions.length)
return server.close();
- var options = clientsOptions[i++];
+ const options = clientsOptions[i++];
options.port = server.address().port;
- var client = tls.connect(options, function() {
+ const client = tls.connect(options, function() {
clientResults.push(
client.authorizationError &&
/Hostname\/IP doesn't/.test(client.authorizationError));
diff --git a/test/parallel/test-tls-wrap-timeout.js b/test/parallel/test-tls-wrap-timeout.js
index 0454242d92ecb6..d66e1f2d680f77 100644
--- a/test/parallel/test-tls-wrap-timeout.js
+++ b/test/parallel/test-tls-wrap-timeout.js
@@ -27,8 +27,8 @@ const server = tls.createServer(options, common.mustCall((c) => {
});
}));
-var socket;
-var lastIdleStart;
+let socket;
+let lastIdleStart;
server.listen(0, () => {
socket = net.connect(server.address().port, function() {
diff --git a/test/parallel/test-umask.js b/test/parallel/test-umask.js
index 62f9d82b3312ef..1c870893a3bced 100644
--- a/test/parallel/test-umask.js
+++ b/test/parallel/test-umask.js
@@ -1,16 +1,16 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
// Note in Windows one can only set the "user" bits.
-var mask;
+let mask;
if (common.isWindows) {
mask = '0600';
} else {
mask = '0664';
}
-var old = process.umask(mask);
+const old = process.umask(mask);
assert.equal(parseInt(mask, 8), process.umask(old));
diff --git a/test/parallel/test-url.js b/test/parallel/test-url.js
index 5a5fd476ebfb05..d8ee2127f946d3 100644
--- a/test/parallel/test-url.js
+++ b/test/parallel/test-url.js
@@ -1,13 +1,13 @@
/* eslint-disable max-len */
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var url = require('url');
+const url = require('url');
// URLs to parse, and expected data
// { url : parsed }
-var parseTests = {
+const parseTests = {
'//some_path': {
href: '//some_path',
pathname: '//some_path',
@@ -944,7 +944,7 @@ function check(actual, expected) {
});
}
-var parseTestsWithQueryString = {
+const parseTestsWithQueryString = {
'/foo/bar?baz=quux#frag': {
href: '/foo/bar?baz=quux#frag',
hash: '#frag',
@@ -1015,7 +1015,7 @@ for (const u in parseTestsWithQueryString) {
// some extra formatting tests, just to verify
// that it'll format slightly wonky content to a valid url.
-var formatTests = {
+const formatTests = {
'http://example.com?': {
href: 'http://example.com/?',
protocol: 'http:',
@@ -1244,7 +1244,7 @@ for (const u in formatTests) {
/*
[from, path, expected]
*/
-var relativeTests = [
+const relativeTests = [
['/foo/bar/baz', 'quux', '/foo/bar/quux'],
['/foo/bar/baz', 'quux/asdf', '/foo/bar/quux/asdf'],
['/foo/bar/baz', 'quux/baz', '/foo/bar/quux/baz'],
@@ -1323,7 +1323,7 @@ relativeTests.forEach(function(relativeTest) {
//
// Changes marked with @isaacs
-var bases = [
+const bases = [
'http://a/b/c/d;p?q',
'http://a/b/c/d;p?q=1/2',
'http://a/b/c/d;p=1/2?q',
@@ -1332,7 +1332,7 @@ var bases = [
];
//[to, from, result]
-var relativeTests2 = [
+const relativeTests2 = [
// http://lists.w3.org/Archives/Public/uri/2004Feb/0114.html
['../c', 'foo:a/b', 'foo:c'],
['foo:.', 'foo:a', 'foo:'],
@@ -1635,8 +1635,8 @@ relativeTests2.forEach(function(relativeTest) {
//format: [from, path, expected]
relativeTests.forEach(function(relativeTest) {
- var actual = url.resolveObject(url.parse(relativeTest[0]), relativeTest[1]);
- var expected = url.parse(relativeTest[2]);
+ let actual = url.resolveObject(url.parse(relativeTest[0]), relativeTest[1]);
+ let expected = url.parse(relativeTest[2]);
assert.deepStrictEqual(actual, expected);
@@ -1663,8 +1663,8 @@ if (relativeTests2[181][0] === './/g' &&
relativeTests2.splice(181, 1);
}
relativeTests2.forEach(function(relativeTest) {
- var actual = url.resolveObject(url.parse(relativeTest[1]), relativeTest[0]);
- var expected = url.parse(relativeTest[2]);
+ let actual = url.resolveObject(url.parse(relativeTest[1]), relativeTest[0]);
+ let expected = url.parse(relativeTest[2]);
assert.deepStrictEqual(actual, expected);
@@ -1678,7 +1678,7 @@ relativeTests2.forEach(function(relativeTest) {
// https://github.com/nodejs/node/pull/1036
-var throws = [
+const throws = [
undefined,
null,
true,
diff --git a/test/parallel/test-utf8-scripts.js b/test/parallel/test-utf8-scripts.js
index 98c26594bb6540..484d3bdefe5eda 100644
--- a/test/parallel/test-utf8-scripts.js
+++ b/test/parallel/test-utf8-scripts.js
@@ -1,6 +1,6 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
// üäö
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js
index b0f89333d25a9b..af1f0fe9c3d6d0 100644
--- a/test/parallel/test-util-inspect.js
+++ b/test/parallel/test-util-inspect.js
@@ -233,7 +233,7 @@ assert.strictEqual(util.inspect({get readwrite() {}, set readwrite(val) {}}),
assert.strictEqual(util.inspect({set writeonly(val) {}}),
'{ writeonly: [Setter] }');
-var value = {};
+let value = {};
value['a'] = value;
assert.strictEqual(util.inspect(value), '{ a: [Circular] }');
@@ -271,11 +271,11 @@ assert.strictEqual(util.inspect(value), '{ 2010-02-14T11:48:40.000Z aprop: 42 }'
);
// test the internal isDate implementation
-var Date2 = require('vm').runInNewContext('Date');
-var d = new Date2();
-var orig = util.inspect(d);
+const Date2 = require('vm').runInNewContext('Date');
+const d = new Date2();
+const orig = util.inspect(d);
Date2.prototype.foo = 'bar';
-var after = util.inspect(d);
+const after = util.inspect(d);
assert.strictEqual(orig, after);
// test positive/negative zero
@@ -283,7 +283,7 @@ assert.strictEqual(util.inspect(0), '0');
assert.strictEqual(util.inspect(-0), '-0');
// test for sparse array
-var a = ['foo', 'bar', 'baz'];
+const a = ['foo', 'bar', 'baz'];
assert.strictEqual(util.inspect(a), '[ \'foo\', \'bar\', \'baz\' ]');
delete a[1];
assert.strictEqual(util.inspect(a), '[ \'foo\', , \'baz\' ]');
@@ -309,27 +309,27 @@ assert.strictEqual(util.inspect(new Array(5)), '[ , , , , ]');
}
// test for other constructors in different context
-var obj = require('vm').runInNewContext('(function(){return {}})()', {});
+let obj = require('vm').runInNewContext('(function(){return {}})()', {});
assert.strictEqual(util.inspect(obj), '{}');
-obj = require('vm').runInNewContext('var m=new Map();m.set(1,2);m', {});
+obj = require('vm').runInNewContext('let m=new Map();m.set(1,2);m', {});
assert.strictEqual(util.inspect(obj), 'Map { 1 => 2 }');
-obj = require('vm').runInNewContext('var s=new Set();s.add(1);s.add(2);s', {});
+obj = require('vm').runInNewContext('let s=new Set();s.add(1);s.add(2);s', {});
assert.strictEqual(util.inspect(obj), 'Set { 1, 2 }');
obj = require('vm').runInNewContext('fn=function(){};new Promise(fn,fn)', {});
assert.strictEqual(util.inspect(obj), 'Promise { }');
// test for property descriptors
-var getter = Object.create(null, {
+const getter = Object.create(null, {
a: {
get: function() { return 'aaa'; }
}
});
-var setter = Object.create(null, {
+const setter = Object.create(null, {
b: {
set: function() {}
}
});
-var getterAndSetter = Object.create(null, {
+const getterAndSetter = Object.create(null, {
c: {
get: function() { return 'ccc'; },
set: function() {}
@@ -356,7 +356,7 @@ try {
} catch (e) {
assert.strictEqual(util.inspect(e), e.stack);
}
-var ex = util.inspect(new Error('FAIL'), true);
+const ex = util.inspect(new Error('FAIL'), true);
assert(ex.includes('Error: FAIL'));
assert(ex.includes('[stack]'));
assert(ex.includes('[message]'));
@@ -380,19 +380,19 @@ assert.strictEqual(util.inspect(Object.create(Date.prototype)), 'Date {}');
// GH-1944
assert.doesNotThrow(function() {
- var d = new Date();
+ const d = new Date();
d.toUTCString = null;
util.inspect(d);
});
assert.doesNotThrow(function() {
- var d = new Date();
+ const d = new Date();
d.toISOString = null;
util.inspect(d);
});
assert.doesNotThrow(function() {
- var r = /regexp/;
+ const r = /regexp/;
r.toString = null;
util.inspect(r);
});
@@ -411,14 +411,14 @@ assert.doesNotThrow(function() {
}
// util.inspect should not display the escaped value of a key.
-var w = {
+const w = {
'\\': 1,
'\\\\': 2,
'\\\\\\': 3,
'\\\\\\\\': 4,
};
-var y = ['a', 'b', 'c'];
+const y = ['a', 'b', 'c'];
y['\\\\\\'] = 'd';
assert.strictEqual(
@@ -432,15 +432,15 @@ assert.strictEqual(
// util.inspect.styles and util.inspect.colors
function test_color_style(style, input, implicit) {
- var color_name = util.inspect.styles[style];
- var color = ['', ''];
+ const color_name = util.inspect.styles[style];
+ let color = ['', ''];
if (util.inspect.colors[color_name])
color = util.inspect.colors[color_name];
- var without_color = util.inspect(input, false, 0, false);
- var with_color = util.inspect(input, false, 0, true);
- var expect = '\u001b[' + color[0] + 'm' + without_color +
- '\u001b[' + color[1] + 'm';
+ const without_color = util.inspect(input, false, 0, false);
+ const with_color = util.inspect(input, false, 0, true);
+ const expect = '\u001b[' + color[0] + 'm' + without_color +
+ '\u001b[' + color[1] + 'm';
assert.strictEqual(
with_color,
expect,
@@ -593,19 +593,19 @@ assert.doesNotThrow(function() {
// util.inspect with "colors" option should produce as many lines as without it
function test_lines(input) {
- var count_lines = function(str) {
+ const count_lines = function(str) {
return (str.match(/\n/g) || []).length;
};
- var without_color = util.inspect(input);
- var with_color = util.inspect(input, {colors: true});
+ const without_color = util.inspect(input);
+ const with_color = util.inspect(input, {colors: true});
assert.strictEqual(count_lines(without_color), count_lines(with_color));
}
test_lines([1, 2, 3, 4, 5, 6, 7]);
test_lines(function() {
- var big_array = [];
- for (var i = 0; i < 100; i++) {
+ const big_array = [];
+ for (let i = 0; i < 100; i++) {
big_array.push(i);
}
return big_array;
@@ -633,15 +633,15 @@ assert.strictEqual(util.inspect(new Number(-1.1)), '[Number: -1.1]');
assert.strictEqual(util.inspect(new Number(13.37)), '[Number: 13.37]');
// test boxed primitives with own properties
-var str = new String('baz');
+const str = new String('baz');
str.foo = 'bar';
assert.strictEqual(util.inspect(str), '{ [String: \'baz\'] foo: \'bar\' }');
-var bool = new Boolean(true);
+const bool = new Boolean(true);
bool.foo = 'bar';
assert.strictEqual(util.inspect(bool), '{ [Boolean: true] foo: \'bar\' }');
-var num = new Number(13.37);
+const num = new Number(13.37);
num.foo = 'bar';
assert.strictEqual(util.inspect(num), '{ [Number: 13.37] foo: \'bar\' }');
@@ -675,7 +675,7 @@ if (typeof Symbol !== 'undefined') {
// test Set
assert.strictEqual(util.inspect(new Set()), 'Set {}');
assert.strictEqual(util.inspect(new Set([1, 2, 3])), 'Set { 1, 2, 3 }');
-var set = new Set(['foo']);
+const set = new Set(['foo']);
set.bar = 42;
assert.strictEqual(
util.inspect(set, true),
@@ -707,30 +707,30 @@ assert.strictEqual(
util.inspect(new Promise(function() {})),
'Promise { }'
);
-var promise = Promise.resolve('foo');
+const promise = Promise.resolve('foo');
promise.bar = 42;
assert.strictEqual(util.inspect(promise), 'Promise { \'foo\', bar: 42 }');
// Make sure it doesn't choke on polyfills. Unlike Set/Map, there is no standard
// interface to synchronously inspect a Promise, so our techniques only work on
// a bonafide native Promise.
-var oldPromise = Promise;
+const oldPromise = Promise;
global.Promise = function() { this.bar = 42; };
assert.strictEqual(util.inspect(new Promise()), '{ bar: 42 }');
global.Promise = oldPromise;
// Map/Set Iterators
-var m = new Map([['foo', 'bar']]);
+const m = new Map([['foo', 'bar']]);
assert.strictEqual(util.inspect(m.keys()), 'MapIterator { \'foo\' }');
assert.strictEqual(util.inspect(m.values()), 'MapIterator { \'bar\' }');
assert.strictEqual(util.inspect(m.entries()),
'MapIterator { [ \'foo\', \'bar\' ] }');
// make sure the iterator doesn't get consumed
-var keys = m.keys();
+let keys = m.keys();
assert.strictEqual(util.inspect(keys), 'MapIterator { \'foo\' }');
assert.strictEqual(util.inspect(keys), 'MapIterator { \'foo\' }');
-var s = new Set([1, 3]);
+const s = new Set([1, 3]);
assert.strictEqual(util.inspect(s.keys()), 'SetIterator { 1, 3 }');
assert.strictEqual(util.inspect(s.values()), 'SetIterator { 1, 3 }');
assert.strictEqual(util.inspect(s.entries()),
@@ -744,10 +744,10 @@ assert.strictEqual(util.inspect(keys), 'SetIterator { 1, 3 }');
// Assumes that the first numeric character is the start of an item.
function checkAlignment(container) {
- var lines = util.inspect(container).split('\n');
- var pos;
+ const lines = util.inspect(container).split('\n');
+ let pos;
lines.forEach(function(line) {
- var npos = line.search(/\d/);
+ const npos = line.search(/\d/);
if (npos !== -1) {
if (pos !== undefined)
assert.strictEqual(pos, npos, 'container items not aligned');
@@ -756,14 +756,14 @@ function checkAlignment(container) {
});
}
-var big_array = [];
-for (var i = 0; i < 100; i++) {
+const big_array = [];
+for (let i = 0; i < 100; i++) {
big_array.push(i);
}
checkAlignment(big_array);
checkAlignment(function() {
- var obj = {};
+ const obj = {};
big_array.forEach(function(v) {
obj[v] = null;
});
diff --git a/test/parallel/test-util-log.js b/test/parallel/test-util-log.js
index 91f77d994da847..d45ebf2fc0b729 100644
--- a/test/parallel/test-util-log.js
+++ b/test/parallel/test-util-log.js
@@ -1,19 +1,19 @@
'use strict';
require('../common');
-var assert = require('assert');
-var util = require('util');
+const assert = require('assert');
+const util = require('util');
assert.ok(process.stdout.writable);
assert.ok(process.stderr.writable);
-var stdout_write = global.process.stdout.write;
-var strings = [];
+const stdout_write = global.process.stdout.write;
+const strings = [];
global.process.stdout.write = function(string) {
strings.push(string);
};
console._stderr = process.stdout;
-var tests = [
+const tests = [
{input: 'foo', output: 'foo'},
{input: undefined, output: 'undefined'},
{input: null, output: 'null'},
diff --git a/test/parallel/test-v8-flag-type-check.js b/test/parallel/test-v8-flag-type-check.js
index 986f37314d605f..b5d4d7c2f12665 100644
--- a/test/parallel/test-v8-flag-type-check.js
+++ b/test/parallel/test-v8-flag-type-check.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var v8 = require('v8');
+const assert = require('assert');
+const v8 = require('v8');
assert.throws(function() { v8.setFlagsFromString(1); }, TypeError);
assert.throws(function() { v8.setFlagsFromString(); }, TypeError);
diff --git a/test/parallel/test-v8-flags.js b/test/parallel/test-v8-flags.js
index 50cff9ecefceac..99384080516bb2 100644
--- a/test/parallel/test-v8-flags.js
+++ b/test/parallel/test-v8-flags.js
@@ -1,8 +1,8 @@
'use strict';
require('../common');
-var assert = require('assert');
-var v8 = require('v8');
-var vm = require('vm');
+const assert = require('assert');
+const v8 = require('v8');
+const vm = require('vm');
// Note: changing V8 flags after an isolate started is not guaranteed to work.
// Specifically here, V8 may cache compiled scripts between the flip of the
diff --git a/test/parallel/test-v8-stats.js b/test/parallel/test-v8-stats.js
index b4e16ad90009a8..5187432484846b 100644
--- a/test/parallel/test-v8-stats.js
+++ b/test/parallel/test-v8-stats.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
-var v8 = require('v8');
+const assert = require('assert');
+const v8 = require('v8');
-var s = v8.getHeapStatistics();
-var keys = [
+const s = v8.getHeapStatistics();
+const keys = [
'heap_size_limit',
'total_available_size',
'total_heap_size',
diff --git a/test/parallel/test-vm-basic.js b/test/parallel/test-vm-basic.js
index b2b280c21bd173..2d57cc0d4ba328 100644
--- a/test/parallel/test-vm-basic.js
+++ b/test/parallel/test-vm-basic.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
-var vm = require('vm');
+const assert = require('assert');
+const vm = require('vm');
// Test 1: vm.runInNewContext
-var sandbox = {};
-var result = vm.runInNewContext(
+const sandbox = {};
+let result = vm.runInNewContext(
'foo = "bar"; this.typeofProcess = typeof process; typeof Object;',
sandbox
);
@@ -16,8 +16,8 @@ assert.deepStrictEqual(sandbox, {
assert.strictEqual(result, 'function');
// Test 2: vm.runInContext
-var sandbox2 = { foo: 'bar' };
-var context = vm.createContext(sandbox2);
+const sandbox2 = { foo: 'bar' };
+const context = vm.createContext(sandbox2);
result = vm.runInContext(
'baz = foo; this.typeofProcess = typeof process; typeof Object;',
context
@@ -45,6 +45,6 @@ assert.strictEqual(global.vmResult, undefined);
assert.strictEqual(result, 'undefined');
// Test 5: vm.createContext
-var sandbox3 = {};
-var context2 = vm.createContext(sandbox3);
+const sandbox3 = {};
+const context2 = vm.createContext(sandbox3);
assert.strictEqual(sandbox3, context2);
diff --git a/test/parallel/test-vm-context-async-script.js b/test/parallel/test-vm-context-async-script.js
index b09eda85209807..1e9ed629fb114f 100644
--- a/test/parallel/test-vm-context-async-script.js
+++ b/test/parallel/test-vm-context-async-script.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
-var vm = require('vm');
+const assert = require('assert');
+const vm = require('vm');
-var sandbox = { setTimeout: setTimeout };
+const sandbox = { setTimeout: setTimeout };
-var ctx = vm.createContext(sandbox);
+const ctx = vm.createContext(sandbox);
vm.runInContext('setTimeout(function() { x = 3; }, 0);', ctx);
setTimeout(function() {
diff --git a/test/parallel/test-vm-context-property-forwarding.js b/test/parallel/test-vm-context-property-forwarding.js
index 4034441615ca9e..b77fc45217039f 100644
--- a/test/parallel/test-vm-context-property-forwarding.js
+++ b/test/parallel/test-vm-context-property-forwarding.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
-var vm = require('vm');
+const assert = require('assert');
+const vm = require('vm');
-var sandbox = { x: 3 };
+const sandbox = { x: 3 };
-var ctx = vm.createContext(sandbox);
+const ctx = vm.createContext(sandbox);
assert.strictEqual(vm.runInContext('x;', ctx), 3);
vm.runInContext('y = 4;', ctx);
diff --git a/test/parallel/test-vm-context.js b/test/parallel/test-vm-context.js
index 659a092eb3e6c0..933d975c2c5542 100644
--- a/test/parallel/test-vm-context.js
+++ b/test/parallel/test-vm-context.js
@@ -1,14 +1,14 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var vm = require('vm');
-var Script = vm.Script;
-var script = new Script('"passed";');
+const vm = require('vm');
+const Script = vm.Script;
+let script = new Script('"passed";');
console.error('run in a new empty context');
-var context = vm.createContext();
-var result = script.runInContext(context);
+let context = vm.createContext();
+let result = script.runInContext(context);
assert.equal('passed', result);
console.error('create a new pre-populated context');
@@ -29,7 +29,7 @@ assert.throws(function() {
// Issue GH-1140:
console.error('test runInContext signature');
-var gh1140Exception;
+let gh1140Exception;
try {
vm.runInContext('throw new Error()', context, 'expected-filename.js');
} catch (e) {
@@ -55,7 +55,7 @@ script.runInNewContext({ require: require });
// Issue GH-7529
script = vm.createScript('delete b');
-var ctx = {};
+let ctx = {};
Object.defineProperty(ctx, 'b', { configurable: false });
ctx = vm.createContext(ctx);
assert.equal(script.runInContext(ctx), false);
diff --git a/test/parallel/test-vm-create-and-run-in-context.js b/test/parallel/test-vm-create-and-run-in-context.js
index fc92cf2f6cb6eb..a0026102b578f8 100644
--- a/test/parallel/test-vm-create-and-run-in-context.js
+++ b/test/parallel/test-vm-create-and-run-in-context.js
@@ -1,13 +1,13 @@
'use strict';
// Flags: --expose-gc
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var vm = require('vm');
+const vm = require('vm');
console.error('run in a new empty context');
-var context = vm.createContext();
-var result = vm.runInContext('"passed";', context);
+let context = vm.createContext();
+let result = vm.runInContext('"passed";', context);
assert.equal('passed', result);
console.error('create a new pre-populated context');
@@ -22,7 +22,7 @@ assert.equal('lala', context.thing);
// https://github.com/nodejs/node/issues/5768
console.error('run in contextified sandbox without referencing the context');
-var sandbox = {x: 1};
+const sandbox = {x: 1};
vm.createContext(sandbox);
global.gc();
vm.runInContext('x = 2', sandbox);
diff --git a/test/parallel/test-vm-create-context-accessors.js b/test/parallel/test-vm-create-context-accessors.js
index 497bab1a57225f..27d7e6d7fc0274 100644
--- a/test/parallel/test-vm-create-context-accessors.js
+++ b/test/parallel/test-vm-create-context-accessors.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
-var vm = require('vm');
+const assert = require('assert');
+const vm = require('vm');
-var ctx = {};
+let ctx = {};
Object.defineProperty(ctx, 'getter', {
get: function() {
@@ -11,7 +11,7 @@ Object.defineProperty(ctx, 'getter', {
}
});
-var val;
+let val;
Object.defineProperty(ctx, 'setter', {
set: function(_val) {
val = _val;
@@ -23,6 +23,6 @@ Object.defineProperty(ctx, 'setter', {
ctx = vm.createContext(ctx);
-var result = vm.runInContext('setter = "test";[getter,setter]', ctx);
+const result = vm.runInContext('setter = "test";[getter,setter]', ctx);
assert.strictEqual(result[0], 'ok');
assert.strictEqual(result[1], 'ok=test');
diff --git a/test/parallel/test-vm-create-context-arg.js b/test/parallel/test-vm-create-context-arg.js
index a0c29762330133..91bbbc3b7793bc 100644
--- a/test/parallel/test-vm-create-context-arg.js
+++ b/test/parallel/test-vm-create-context-arg.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var vm = require('vm');
+const assert = require('assert');
+const vm = require('vm');
assert.throws(function() {
vm.createContext('string is not supported');
@@ -13,7 +13,7 @@ assert.doesNotThrow(function() {
});
assert.doesNotThrow(function() {
- var sandbox = {};
+ const sandbox = {};
vm.createContext(sandbox);
vm.createContext(sandbox);
});
diff --git a/test/parallel/test-vm-create-context-circular-reference.js b/test/parallel/test-vm-create-context-circular-reference.js
index 248ef24f69ca07..13680c4c4e11ef 100644
--- a/test/parallel/test-vm-create-context-circular-reference.js
+++ b/test/parallel/test-vm-create-context-circular-reference.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
-var vm = require('vm');
+const assert = require('assert');
+const vm = require('vm');
-var sbx = {};
+let sbx = {};
sbx.window = sbx;
sbx = vm.createContext(sbx);
diff --git a/test/parallel/test-vm-cross-context.js b/test/parallel/test-vm-cross-context.js
index 5674f582426f1f..bafb32accb6a0e 100644
--- a/test/parallel/test-vm-cross-context.js
+++ b/test/parallel/test-vm-cross-context.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var vm = require('vm');
-var ctx = vm.createContext(global);
+const vm = require('vm');
+const ctx = vm.createContext(global);
assert.doesNotThrow(function() {
vm.runInContext('!function() { var x = console.log; }()', ctx);
diff --git a/test/parallel/test-vm-function-declaration.js b/test/parallel/test-vm-function-declaration.js
index fd41be7564aab0..9f27723a0421a9 100644
--- a/test/parallel/test-vm-function-declaration.js
+++ b/test/parallel/test-vm-function-declaration.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var vm = require('vm');
-var o = vm.createContext({ console: console });
+const vm = require('vm');
+const o = vm.createContext({ console: console });
// This triggers the setter callback in node_contextify.cc
-var code = 'var a = function() {};\n';
+let code = 'var a = function() {};\n';
// but this does not, since function decls are defineProperties,
// not simple sets.
@@ -16,7 +16,7 @@ code += 'function b(){}\n';
// we are getting the global function, and not some other thing
code += '(function(){return this})().b;\n';
-var res = vm.runInContext(code, o, 'test');
+const res = vm.runInContext(code, o, 'test');
assert.equal(typeof res, 'function', 'result should be function');
assert.equal(res.name, 'b', 'res should be named b');
diff --git a/test/parallel/test-vm-global-define-property.js b/test/parallel/test-vm-global-define-property.js
index 73d1520e0dad69..62a714615ddc31 100644
--- a/test/parallel/test-vm-global-define-property.js
+++ b/test/parallel/test-vm-global-define-property.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var vm = require('vm');
+const vm = require('vm');
-var code =
+const code =
'Object.defineProperty(this, "f", {\n' +
' get: function() { return x; },\n' +
' set: function(k) { x = k; },\n' +
@@ -14,10 +14,10 @@ var code =
'g = f;\n' +
'f;\n';
-var x = {};
-var o = vm.createContext({ console: console, x: x });
+const x = {};
+const o = vm.createContext({ console: console, x: x });
-var res = vm.runInContext(code, o, 'test');
+const res = vm.runInContext(code, o, 'test');
assert(res);
assert.equal(typeof res, 'object');
diff --git a/test/parallel/test-vm-global-identity.js b/test/parallel/test-vm-global-identity.js
index 7d90408b64c2c7..ae9fd71b3109ee 100644
--- a/test/parallel/test-vm-global-identity.js
+++ b/test/parallel/test-vm-global-identity.js
@@ -1,11 +1,11 @@
'use strict';
require('../common');
-var assert = require('assert');
-var vm = require('vm');
+const assert = require('assert');
+const vm = require('vm');
-var ctx = vm.createContext();
+const ctx = vm.createContext();
ctx.window = ctx;
-var thisVal = vm.runInContext('this;', ctx);
-var windowVal = vm.runInContext('window;', ctx);
+const thisVal = vm.runInContext('this;', ctx);
+const windowVal = vm.runInContext('window;', ctx);
assert.strictEqual(thisVal, windowVal);
diff --git a/test/parallel/test-vm-harmony-symbols.js b/test/parallel/test-vm-harmony-symbols.js
index 1c1274ef3543f6..80c1a2127f918c 100644
--- a/test/parallel/test-vm-harmony-symbols.js
+++ b/test/parallel/test-vm-harmony-symbols.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var assert = require('assert');
-var vm = require('vm');
+const assert = require('assert');
+const vm = require('vm');
// The sandbox should have its own Symbol constructor.
-var sandbox = {};
+let sandbox = {};
vm.runInNewContext('this.Symbol = Symbol', sandbox);
assert.strictEqual(typeof sandbox.Symbol, 'function');
assert.notStrictEqual(sandbox.Symbol, Symbol);
diff --git a/test/parallel/test-vm-is-context.js b/test/parallel/test-vm-is-context.js
index cc106a15fbfc61..e58b896fccaa43 100644
--- a/test/parallel/test-vm-is-context.js
+++ b/test/parallel/test-vm-is-context.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var vm = require('vm');
+const assert = require('assert');
+const vm = require('vm');
assert.throws(function() {
vm.isContext('string is not supported');
@@ -13,6 +13,6 @@ assert.strictEqual(vm.isContext([]), false);
assert.strictEqual(vm.isContext(vm.createContext()), true);
assert.strictEqual(vm.isContext(vm.createContext([])), true);
-var sandbox = { foo: 'bar' };
+const sandbox = { foo: 'bar' };
vm.createContext(sandbox);
assert.strictEqual(vm.isContext(sandbox), true);
diff --git a/test/parallel/test-vm-new-script-new-context.js b/test/parallel/test-vm-new-script-new-context.js
index 2af8f05f1c5236..a02627668f6db7 100644
--- a/test/parallel/test-vm-new-script-new-context.js
+++ b/test/parallel/test-vm-new-script-new-context.js
@@ -6,7 +6,7 @@ const Script = require('vm').Script;
common.globalCheck = false;
console.error('run a string');
-var script = new Script('\'passed\';');
+let script = new Script('\'passed\';');
console.error('script created');
const result1 = script.runInNewContext();
const result2 = script.runInNewContext();
@@ -41,7 +41,7 @@ global.foo = 2;
global.obj = { foo: 0, baz: 3 };
script = new Script(global.code);
/* eslint-disable no-unused-vars */
-var baz = script.runInNewContext(global.obj);
+const baz = script.runInNewContext(global.obj);
/* eslint-enable no-unused-vars */
assert.equal(1, global.obj.foo);
assert.equal(2, global.obj.bar);
@@ -55,7 +55,7 @@ assert.equal(global.foo, 100);
console.error('modify an object by reference');
script = new Script('f.a = 2');
-var f = { a: 1 };
+const f = { a: 1 };
script.runInNewContext({ f: f });
assert.equal(f.a, 2);
diff --git a/test/parallel/test-vm-new-script-this-context.js b/test/parallel/test-vm-new-script-this-context.js
index d225fb0d4025d0..fb7e2719855174 100644
--- a/test/parallel/test-vm-new-script-this-context.js
+++ b/test/parallel/test-vm-new-script-this-context.js
@@ -6,7 +6,7 @@ const Script = require('vm').Script;
common.globalCheck = false;
console.error('run a string');
-var script = new Script('\'passed\';');
+let script = new Script('\'passed\';');
const result = script.runInThisContext(script);
assert.equal('passed', result);
diff --git a/test/parallel/test-vm-proxies.js b/test/parallel/test-vm-proxies.js
index d908d713748f7f..25e16e8f5ccc55 100644
--- a/test/parallel/test-vm-proxies.js
+++ b/test/parallel/test-vm-proxies.js
@@ -1,12 +1,12 @@
'use strict';
require('../common');
-var assert = require('assert');
-var vm = require('vm');
+const assert = require('assert');
+const vm = require('vm');
// src/node_contextify.cc filters out the Proxy object from the parent
// context. Make sure that the new context has a Proxy object of its own.
-var sandbox = {};
+let sandbox = {};
vm.runInNewContext('this.Proxy = Proxy', sandbox);
assert.strictEqual(typeof sandbox.Proxy, 'function');
assert.notStrictEqual(sandbox.Proxy, Proxy);
diff --git a/test/parallel/test-vm-run-in-new-context.js b/test/parallel/test-vm-run-in-new-context.js
index 956e02306d4fb8..b00e5a973e0d25 100644
--- a/test/parallel/test-vm-run-in-new-context.js
+++ b/test/parallel/test-vm-run-in-new-context.js
@@ -30,7 +30,7 @@ global.code = 'foo = 1;' +
global.foo = 2;
global.obj = { foo: 0, baz: 3 };
/* eslint-disable no-unused-vars */
-var baz = vm.runInNewContext(global.code, global.obj);
+const baz = vm.runInNewContext(global.code, global.obj);
/* eslint-enable no-unused-vars */
assert.equal(1, global.obj.foo);
assert.equal(2, global.obj.bar);
@@ -42,12 +42,12 @@ vm.runInNewContext('f()', { f: changeFoo });
assert.equal(global.foo, 100);
console.error('modify an object by reference');
-var f = { a: 1 };
+const f = { a: 1 };
vm.runInNewContext('f.a = 2', { f: f });
assert.equal(f.a, 2);
console.error('use function in context without referencing context');
-var fn = vm.runInNewContext('(function() { obj.p = {}; })', { obj: {} });
+const fn = vm.runInNewContext('(function() { obj.p = {}; })', { obj: {} });
global.gc();
fn();
// Should not crash
diff --git a/test/parallel/test-vm-static-this.js b/test/parallel/test-vm-static-this.js
index c4f10c183b6ef2..8968f52d1b6f19 100644
--- a/test/parallel/test-vm-static-this.js
+++ b/test/parallel/test-vm-static-this.js
@@ -1,12 +1,12 @@
/* eslint-disable strict */
-var common = require('../common');
-var assert = require('assert');
-var vm = require('vm');
+const common = require('../common');
+const assert = require('assert');
+const vm = require('vm');
common.globalCheck = false;
// Run a string
-var result = vm.runInThisContext('\'passed\';');
+const result = vm.runInThisContext('\'passed\';');
assert.strictEqual('passed', result);
// thrown error
@@ -20,13 +20,14 @@ assert.strictEqual(2, global.hello);
// pass values
-var code = 'foo = 1;' +
- 'bar = 2;' +
- 'if (typeof baz !== \'undefined\') throw new Error(\'test fail\');';
+const code = 'foo = 1;' +
+ 'bar = 2;' +
+ 'if (typeof baz !== \'undefined\') ' +
+ 'throw new Error(\'test fail\');';
global.foo = 2;
global.obj = { foo: 0, baz: 3 };
/* eslint-disable no-unused-vars */
-var baz = vm.runInThisContext(code);
+const baz = vm.runInThisContext(code);
/* eslint-enable no-unused-vars */
assert.strictEqual(0, global.obj.foo);
assert.strictEqual(2, global.bar);
diff --git a/test/parallel/test-vm-syntax-error-message.js b/test/parallel/test-vm-syntax-error-message.js
index 75748b24e193ee..1a97393d6d97a7 100644
--- a/test/parallel/test-vm-syntax-error-message.js
+++ b/test/parallel/test-vm-syntax-error-message.js
@@ -1,9 +1,9 @@
'use strict';
require('../common');
-var assert = require('assert');
-var child_process = require('child_process');
+const assert = require('assert');
+const child_process = require('child_process');
-var p = child_process.spawn(process.execPath, [
+const p = child_process.spawn(process.execPath, [
'-e',
'vm = require("vm");' +
'context = vm.createContext({});' +
@@ -15,7 +15,7 @@ p.stderr.on('data', function(data) {
assert(false, 'Unexpected stderr data: ' + data);
});
-var output = '';
+let output = '';
p.stdout.on('data', function(data) {
output += data;
diff --git a/test/parallel/test-vm-timeout.js b/test/parallel/test-vm-timeout.js
index 0536ae37a1b489..5260ca7dc28572 100644
--- a/test/parallel/test-vm-timeout.js
+++ b/test/parallel/test-vm-timeout.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var assert = require('assert');
-var vm = require('vm');
+const assert = require('assert');
+const vm = require('vm');
// Test 1: Timeout of 100ms executing endless loop
assert.throws(function() {
@@ -23,7 +23,7 @@ vm.runInThisContext('', { timeout: 1000 });
// Test 5: Nested vm timeouts, inner timeout propagates out
assert.throws(function() {
- var context = {
+ const context = {
log: console.log,
runInVM: function(timeout) {
vm.runInNewContext('while(true) {}', context, { timeout: timeout });
diff --git a/test/parallel/test-writedouble.js b/test/parallel/test-writedouble.js
index 107bf521342ef3..935f9e7ae08ffd 100644
--- a/test/parallel/test-writedouble.js
+++ b/test/parallel/test-writedouble.js
@@ -6,7 +6,7 @@ require('../common');
const assert = require('assert');
function test(clazz) {
- var buffer = new clazz(16);
+ const buffer = new clazz(16);
buffer.writeDoubleBE(2.225073858507201e-308, 0);
buffer.writeDoubleLE(2.225073858507201e-308, 8);
diff --git a/test/parallel/test-writefloat.js b/test/parallel/test-writefloat.js
index 2f76dd57c7b077..113e97c6d333b7 100644
--- a/test/parallel/test-writefloat.js
+++ b/test/parallel/test-writefloat.js
@@ -6,7 +6,7 @@ require('../common');
const assert = require('assert');
function test(clazz) {
- var buffer = new clazz(8);
+ const buffer = new clazz(8);
buffer.writeFloatBE(1, 0);
buffer.writeFloatLE(1, 4);
diff --git a/test/parallel/test-writeint.js b/test/parallel/test-writeint.js
index 9fce2bc410e1be..838b1ce4798b75 100644
--- a/test/parallel/test-writeint.js
+++ b/test/parallel/test-writeint.js
@@ -7,7 +7,7 @@ const assert = require('assert');
const errorOutOfBounds = /^TypeError: "value" argument is out of bounds$/;
function test8(clazz) {
- var buffer = new clazz(2);
+ const buffer = new clazz(2);
buffer.writeInt8(0x23, 0);
buffer.writeInt8(-5, 1);
@@ -39,7 +39,7 @@ function test8(clazz) {
function test16(clazz) {
- var buffer = new clazz(6);
+ const buffer = new clazz(6);
buffer.writeInt16BE(0x0023, 0);
buffer.writeInt16LE(0x0023, 2);
@@ -92,7 +92,7 @@ function test16(clazz) {
function test32(clazz) {
- var buffer = new clazz(8);
+ const buffer = new clazz(8);
buffer.writeInt32BE(0x23, 0);
buffer.writeInt32LE(0x23, 4);
diff --git a/test/parallel/test-writeuint.js b/test/parallel/test-writeuint.js
index 0cccd4bc150436..bddb954d248633 100644
--- a/test/parallel/test-writeuint.js
+++ b/test/parallel/test-writeuint.js
@@ -13,7 +13,7 @@ const assert = require('assert');
* - Correctly interpreting values that are beyond the signed range as unsigned
*/
function test8(clazz) {
- var data = new clazz(4);
+ const data = new clazz(4);
data.writeUInt8(23, 0);
data.writeUInt8(23, 1);
@@ -42,8 +42,8 @@ function test8(clazz) {
function test16(clazz) {
- var value = 0x2343;
- var data = new clazz(4);
+ let value = 0x2343;
+ const data = new clazz(4);
data.writeUInt16BE(value, 0);
assert.equal(0x23, data[0]);
@@ -81,8 +81,8 @@ function test16(clazz) {
function test32(clazz) {
- var data = new clazz(6);
- var value = 0xe7f90a6d;
+ const data = new clazz(6);
+ const value = 0xe7f90a6d;
data.writeUInt32BE(value, 0);
assert.equal(0xe7, data[0]);
@@ -124,10 +124,10 @@ function test32(clazz) {
function testUint(clazz) {
const data = new clazz(8);
- var val = 1;
+ let val = 1;
// Test 0 to 5 bytes.
- for (var i = 0; i <= 5; i++) {
+ for (let i = 0; i <= 5; i++) {
const errmsg = `byteLength: ${i}`;
assert.throws(function() {
data.writeUIntBE(val, 0, i);
diff --git a/test/parallel/test-zerolengthbufferbug.js b/test/parallel/test-zerolengthbufferbug.js
index 056fc725ff5593..42e6994e1b6389 100644
--- a/test/parallel/test-zerolengthbufferbug.js
+++ b/test/parallel/test-zerolengthbufferbug.js
@@ -2,10 +2,10 @@
// Serving up a zero-length buffer should work.
const common = require('../common');
-var http = require('http');
+const http = require('http');
-var server = http.createServer(function(req, res) {
- var buffer = Buffer.alloc(0);
+const server = http.createServer(function(req, res) {
+ const buffer = Buffer.alloc(0);
// FIXME: WTF gjslint want this?
res.writeHead(200, {'Content-Type': 'text/html',
'Content-Length': buffer.length});
diff --git a/test/parallel/test-zlib-convenience-methods.js b/test/parallel/test-zlib-convenience-methods.js
index 3aac0142b55d66..b67b65d7d0b689 100644
--- a/test/parallel/test-zlib-convenience-methods.js
+++ b/test/parallel/test-zlib-convenience-methods.js
@@ -5,7 +5,7 @@ require('../common');
const assert = require('assert');
const zlib = require('zlib');
-var hadRun = 0;
+let hadRun = 0;
const expect = 'blahblahblahblahblahblah';
const opts = {
@@ -38,7 +38,7 @@ const opts = {
});
});
- var result = zlib[method[0] + 'Sync'](expect, opts);
+ let result = zlib[method[0] + 'Sync'](expect, opts);
result = zlib[method[1] + 'Sync'](result, opts);
assert.equal(result, expect,
'Should get original string after ' +
diff --git a/test/parallel/test-zlib-flush-drain.js b/test/parallel/test-zlib-flush-drain.js
index 45cca584858322..afa4194ac6d453 100644
--- a/test/parallel/test-zlib-flush-drain.js
+++ b/test/parallel/test-zlib-flush-drain.js
@@ -13,8 +13,8 @@ const opts = {
const deflater = zlib.createDeflate(opts);
// shim deflater.flush so we can count times executed
-var flushCount = 0;
-var drainCount = 0;
+let flushCount = 0;
+let drainCount = 0;
const flush = deflater.flush;
deflater.flush = function(kind, callback) {
@@ -26,7 +26,7 @@ deflater.write(bigData);
const ws = deflater._writableState;
const beforeFlush = ws.needDrain;
-var afterFlush = ws.needDrain;
+let afterFlush = ws.needDrain;
deflater.flush(function(err) {
afterFlush = ws.needDrain;
diff --git a/test/parallel/test-zlib-flush.js b/test/parallel/test-zlib-flush.js
index abaa9ed2953d49..f4f8d75dee3ec0 100644
--- a/test/parallel/test-zlib-flush.js
+++ b/test/parallel/test-zlib-flush.js
@@ -22,7 +22,8 @@ deflater.write(chunk, function() {
deflater.flush(zlib.Z_NO_FLUSH, function() {
actualNone = deflater.read();
deflater.flush(function() {
- var bufs = [], buf;
+ const bufs = [];
+ let buf;
while (buf = deflater.read())
bufs.push(buf);
actualFull = Buffer.concat(bufs);
diff --git a/test/parallel/test-zlib-from-gzip.js b/test/parallel/test-zlib-from-gzip.js
index 3739d8f9b48b28..3c7e96cef92a0a 100644
--- a/test/parallel/test-zlib-from-gzip.js
+++ b/test/parallel/test-zlib-from-gzip.js
@@ -24,7 +24,7 @@ inp.pipe(gunzip).pipe(out);
out.on('close', function() {
const actual = fs.readFileSync(outputFile);
assert.equal(actual.length, expect.length, 'length should match');
- for (var i = 0, l = actual.length; i < l; i++) {
+ for (let i = 0, l = actual.length; i < l; i++) {
assert.equal(actual[i], expect[i], 'byte[' + i + ']');
}
});
diff --git a/test/parallel/test-zlib-from-string.js b/test/parallel/test-zlib-from-string.js
index f3b8426eb4d862..0f885ac80ecbe6 100644
--- a/test/parallel/test-zlib-from-string.js
+++ b/test/parallel/test-zlib-from-string.js
@@ -51,7 +51,7 @@ zlib.gzip(inputString, function(err, buffer) {
});
});
-var buffer = Buffer.from(expectedBase64Deflate, 'base64');
+let buffer = Buffer.from(expectedBase64Deflate, 'base64');
zlib.unzip(buffer, function(err, buffer) {
assert.equal(buffer.toString(), inputString,
'decoded inflated string should match');
diff --git a/test/parallel/test-zlib-invalid-input.js b/test/parallel/test-zlib-invalid-input.js
index eb9cd334c11b84..7b0e1fcaae8ce6 100644
--- a/test/parallel/test-zlib-invalid-input.js
+++ b/test/parallel/test-zlib-invalid-input.js
@@ -24,7 +24,7 @@ const unzips = [ zlib.Unzip(),
zlib.Gunzip(),
zlib.Inflate(),
zlib.InflateRaw() ];
-var hadError = [];
+const hadError = [];
unzips.forEach(function(uz, i) {
console.error('Error for ' + uz.constructor.name);
uz.on('error', function(er) {
diff --git a/test/parallel/test-zlib-params.js b/test/parallel/test-zlib-params.js
index fc5888b32ac60d..93e06ea1b7c083 100644
--- a/test/parallel/test-zlib-params.js
+++ b/test/parallel/test-zlib-params.js
@@ -21,7 +21,7 @@ deflater.write(chunk1, function() {
while (deflater.read());
deflater.end(chunk2, function() {
const bufs = [];
- var buf;
+ let buf;
while (buf = deflater.read())
bufs.push(buf);
actual = Buffer.concat(bufs);
diff --git a/test/parallel/test-zlib-random-byte-pipes.js b/test/parallel/test-zlib-random-byte-pipes.js
index 6037703f7bf2ca..83855ebd1f2c0a 100644
--- a/test/parallel/test-zlib-random-byte-pipes.js
+++ b/test/parallel/test-zlib-random-byte-pipes.js
@@ -72,14 +72,14 @@ RandomReadStream.prototype._process = function() {
// figure out how many bytes to output
// if finished, then just emit end.
- var block = this._opt.block;
+ let block = this._opt.block;
const jitter = this._opt.jitter;
if (jitter) {
block += Math.ceil(Math.random() * jitter - (jitter / 2));
}
block = Math.min(block, this._remaining);
const buf = Buffer.allocUnsafe(block);
- for (var i = 0; i < block; i++) {
+ for (let i = 0; i < block; i++) {
buf[i] = Math.random() * 256;
}
@@ -129,10 +129,10 @@ HashStream.prototype.end = function(c) {
};
-var inp = new RandomReadStream({ total: 1024, block: 256, jitter: 16 });
-var out = new HashStream();
-var gzip = zlib.createGzip();
-var gunz = zlib.createGunzip();
+const inp = new RandomReadStream({ total: 1024, block: 256, jitter: 16 });
+const out = new HashStream();
+const gzip = zlib.createGzip();
+const gunz = zlib.createGunzip();
inp.pipe(gzip).pipe(gunz).pipe(out);
diff --git a/test/parallel/test-zlib-write-after-flush.js b/test/parallel/test-zlib-write-after-flush.js
index 9409558a3dee69..f5ad7c6f0e5c91 100644
--- a/test/parallel/test-zlib-write-after-flush.js
+++ b/test/parallel/test-zlib-write-after-flush.js
@@ -8,7 +8,7 @@ const gunz = zlib.createUnzip();
gzip.pipe(gunz);
-var output = '';
+let output = '';
const input = 'A line of data\n';
gunz.setEncoding('utf8');
gunz.on('data', function(c) {
diff --git a/test/parallel/test-zlib-zero-byte.js b/test/parallel/test-zlib-zero-byte.js
index ca58d06ff272ba..cd4cf41f98ac07 100644
--- a/test/parallel/test-zlib-zero-byte.js
+++ b/test/parallel/test-zlib-zero-byte.js
@@ -5,7 +5,7 @@ const assert = require('assert');
const zlib = require('zlib');
const gz = zlib.Gzip();
const emptyBuffer = Buffer.alloc(0);
-var received = 0;
+let received = 0;
gz.on('data', function(c) {
received += c.length;
});
diff --git a/test/parallel/test-zlib.js b/test/parallel/test-zlib.js
index 54a4bc473631a0..fdd5d0a9400f25 100644
--- a/test/parallel/test-zlib.js
+++ b/test/parallel/test-zlib.js
@@ -7,7 +7,7 @@ const fs = require('fs');
const util = require('util');
const stream = require('stream');
-var zlibPairs = [
+let zlibPairs = [
[zlib.Deflate, zlib.Inflate],
[zlib.Gzip, zlib.Gunzip],
[zlib.Deflate, zlib.Unzip],
@@ -16,18 +16,18 @@ var zlibPairs = [
];
// how fast to trickle through the slowstream
-var trickle = [128, 1024, 1024 * 1024];
+let trickle = [128, 1024, 1024 * 1024];
// tunable options for zlib classes.
// several different chunk sizes
-var chunkSize = [128, 1024, 1024 * 16, 1024 * 1024];
+let chunkSize = [128, 1024, 1024 * 16, 1024 * 1024];
// this is every possible value.
-var level = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
-var windowBits = [8, 9, 10, 11, 12, 13, 14, 15];
-var memLevel = [1, 2, 3, 4, 5, 6, 7, 8, 9];
-var strategy = [0, 1, 2, 3, 4];
+let level = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+let windowBits = [8, 9, 10, 11, 12, 13, 14, 15];
+let memLevel = [1, 2, 3, 4, 5, 6, 7, 8, 9];
+let strategy = [0, 1, 2, 3, 4];
// it's nice in theory to test every combination, but it
// takes WAY too long. Maybe a pummel test could do this?
@@ -40,7 +40,7 @@ if (!process.env.PUMMEL) {
strategy = [0];
}
-var testFiles = ['person.jpg', 'elipses.txt', 'empty.txt'];
+let testFiles = ['person.jpg', 'elipses.txt', 'empty.txt'];
if (process.env.FAST) {
zlibPairs = [[zlib.Gzip, zlib.Unzip]];
@@ -72,8 +72,8 @@ BufferStream.prototype.write = function(c) {
BufferStream.prototype.end = function(c) {
if (c) this.write(c);
// flatten
- var buf = Buffer.allocUnsafe(this.length);
- var i = 0;
+ const buf = Buffer.allocUnsafe(this.length);
+ let i = 0;
this.chunks.forEach(function(c) {
c.copy(buf, i);
i += c.length;
@@ -108,8 +108,8 @@ SlowStream.prototype.resume = function() {
this.ended = true;
return this.emit('end');
}
- var end = Math.min(this.offset + this.trickle, this.length);
- var c = this.chunk.slice(this.offset, end);
+ const end = Math.min(this.offset + this.trickle, this.length);
+ const c = this.chunk.slice(this.offset, end);
this.offset += c.length;
this.emit('data', c);
process.nextTick(emit);
@@ -134,12 +134,12 @@ SlowStream.prototype.end = function(chunk) {
// for each of the files, make sure that compressing and
// decompressing results in the same data, for every combination
// of the options set above.
-var failures = 0;
-var total = 0;
-var done = 0;
+let failures = 0;
+let total = 0;
+let done = 0;
Object.keys(tests).forEach(function(file) {
- var test = tests[file];
+ const test = tests[file];
chunkSize.forEach(function(chunkSize) {
trickle.forEach(function(trickle) {
windowBits.forEach(function(windowBits) {
@@ -147,29 +147,30 @@ Object.keys(tests).forEach(function(file) {
memLevel.forEach(function(memLevel) {
strategy.forEach(function(strategy) {
zlibPairs.forEach(function(pair) {
- var Def = pair[0];
- var Inf = pair[1];
- var opts = { level: level,
- windowBits: windowBits,
- memLevel: memLevel,
- strategy: strategy };
+ const Def = pair[0];
+ const Inf = pair[1];
+ const opts = { level: level,
+ windowBits: windowBits,
+ memLevel: memLevel,
+ strategy: strategy };
total++;
- var def = new Def(opts);
- var inf = new Inf(opts);
- var ss = new SlowStream(trickle);
- var buf = new BufferStream();
+ const def = new Def(opts);
+ const inf = new Inf(opts);
+ const ss = new SlowStream(trickle);
+ const buf = new BufferStream();
// verify that the same exact buffer comes out the other end.
buf.on('data', function(c) {
- var msg = file + ' ' +
- chunkSize + ' ' +
- JSON.stringify(opts) + ' ' +
- Def.name + ' -> ' + Inf.name;
- var ok = true;
- var testNum = ++done;
- for (var i = 0; i < Math.max(c.length, test.length); i++) {
+ const msg = file + ' ' +
+ chunkSize + ' ' +
+ JSON.stringify(opts) + ' ' +
+ Def.name + ' -> ' + Inf.name;
+ let ok = true;
+ const testNum = ++done;
+ let i;
+ for (i = 0; i < Math.max(c.length, test.length); i++) {
if (c[i] !== test[i]) {
ok = false;
failures++;
diff --git a/test/pseudo-tty/no_dropped_stdio.js b/test/pseudo-tty/no_dropped_stdio.js
index 1a20889073ce06..b24d234a38b2b7 100644
--- a/test/pseudo-tty/no_dropped_stdio.js
+++ b/test/pseudo-tty/no_dropped_stdio.js
@@ -6,7 +6,7 @@ require('../common');
// 1000 bytes wrapped at 50 columns
// \n turns into a double-byte character
// (48 + {2}) * 20 = 1000
-var out = ('o'.repeat(48) + '\n').repeat(20);
+let out = ('o'.repeat(48) + '\n').repeat(20);
// Add the remaining 24 bytes and terminate with an 'O'.
// This results in 1025 bytes, just enough to overflow the 1kb OS X TTY buffer.
out += 'o'.repeat(24) + 'O';
diff --git a/test/pseudo-tty/no_interleaved_stdio.js b/test/pseudo-tty/no_interleaved_stdio.js
index 778b2c09583b90..ff3ed8594a0baa 100644
--- a/test/pseudo-tty/no_interleaved_stdio.js
+++ b/test/pseudo-tty/no_interleaved_stdio.js
@@ -6,7 +6,7 @@ require('../common');
// 1000 bytes wrapped at 50 columns
// \n turns into a double-byte character
// (48 + {2}) * 20 = 1000
-var out = ('o'.repeat(48) + '\n').repeat(20);
+let out = ('o'.repeat(48) + '\n').repeat(20);
// Add the remaining 24 bytes and terminate with an 'O'.
// This results in 1025 bytes, just enough to overflow the 1kb OS X TTY buffer.
out += 'o'.repeat(24) + 'O';
diff --git a/test/pummel/test-abort-fatal-error.js b/test/pummel/test-abort-fatal-error.js
index 0bb2cb2c39998e..d1a8d3daa65e4c 100644
--- a/test/pummel/test-abort-fatal-error.js
+++ b/test/pummel/test-abort-fatal-error.js
@@ -1,15 +1,15 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
if (common.isWindows) {
common.skip('no RLIMIT_NOFILE on Windows');
return;
}
-var exec = require('child_process').exec;
+const exec = require('child_process').exec;
-var cmdline = 'ulimit -c 0; ' + process.execPath;
+let cmdline = 'ulimit -c 0; ' + process.execPath;
cmdline += ' --max-old-space-size=4 --max-semi-space-size=1';
cmdline += ' -e "a = []; for (i = 0; i < 1e9; i++) { a.push({}) }"';
diff --git a/test/pummel/test-child-process-spawn-loop.js b/test/pummel/test-child-process-spawn-loop.js
index 7a3cf114b4e8e9..41d9ff1e49c17b 100644
--- a/test/pummel/test-child-process-spawn-loop.js
+++ b/test/pummel/test-child-process-spawn-loop.js
@@ -1,8 +1,8 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var spawn = require('child_process').spawn;
+const spawn = require('child_process').spawn;
const SIZE = 1000 * 1024;
const N = 40;
diff --git a/test/pummel/test-crypto-dh.js b/test/pummel/test-crypto-dh.js
index a19e583c516398..30c06b8795db41 100644
--- a/test/pummel/test-crypto-dh.js
+++ b/test/pummel/test-crypto-dh.js
@@ -35,7 +35,7 @@ assert.throws(
'failed to throw the expected error.'
);
-var hashes = {
+const hashes = {
modp1: '630e9acd2cc63f7e80d8507624ba60ac0757201a',
modp2: '18f7aa964484137f57bca64b21917a385b6a0b60',
modp5: 'c0a8eec0c2c8a5ec2f9c26f9661eb339a010ec61',
@@ -47,10 +47,10 @@ var hashes = {
};
for (const name in hashes) {
- var group = crypto.getDiffieHellman(name);
- var private_key = group.getPrime('hex');
- var hash1 = hashes[name];
- var hash2 = crypto.createHash('sha1')
+ const group = crypto.getDiffieHellman(name);
+ const private_key = group.getPrime('hex');
+ const hash1 = hashes[name];
+ const hash2 = crypto.createHash('sha1')
.update(private_key.toUpperCase()).digest('hex');
assert.equal(hash1, hash2);
assert.equal(group.getGenerator('hex'), '02');
@@ -60,11 +60,11 @@ for (const name in hashes) {
// modp1 is 768 bits, FIPS requires >= 1024
if (name === 'modp1' && common.hasFipsCrypto)
continue;
- var group1 = crypto.getDiffieHellman(name);
- var group2 = crypto.getDiffieHellman(name);
+ const group1 = crypto.getDiffieHellman(name);
+ const group2 = crypto.getDiffieHellman(name);
group1.generateKeys();
group2.generateKeys();
- var key1 = group1.computeSecret(group2.getPublicKey());
- var key2 = group2.computeSecret(group1.getPublicKey());
+ const key1 = group1.computeSecret(group2.getPublicKey());
+ const key2 = group2.computeSecret(group1.getPublicKey());
assert.deepStrictEqual(key1, key2);
}
diff --git a/test/pummel/test-dh-regr.js b/test/pummel/test-dh-regr.js
index 448319318b44a4..5be6abb9a8b29c 100644
--- a/test/pummel/test-dh-regr.js
+++ b/test/pummel/test-dh-regr.js
@@ -1,16 +1,16 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var crypto = require('crypto');
+const crypto = require('crypto');
-var p = crypto.createDiffieHellman(1024).getPrime();
+const p = crypto.createDiffieHellman(1024).getPrime();
-for (var i = 0; i < 2000; i++) {
+for (let i = 0; i < 2000; i++) {
const a = crypto.createDiffieHellman(p);
const b = crypto.createDiffieHellman(p);
diff --git a/test/pummel/test-dtrace-jsstack.js b/test/pummel/test-dtrace-jsstack.js
index 1949045888c138..d1615a3855af43 100644
--- a/test/pummel/test-dtrace-jsstack.js
+++ b/test/pummel/test-dtrace-jsstack.js
@@ -1,7 +1,7 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var os = require('os');
+const assert = require('assert');
+const os = require('os');
if (!common.isSunOS) {
common.skip('no DTRACE support');
@@ -11,37 +11,37 @@ if (!common.isSunOS) {
/*
* Some functions to create a recognizable stack.
*/
-var frames = [ 'stalloogle', 'bagnoogle', 'doogle' ];
+const frames = [ 'stalloogle', 'bagnoogle', 'doogle' ];
-var stalloogle = function(str) {
+const stalloogle = function(str) {
global.expected = str;
os.loadavg();
};
-var bagnoogle = function(arg0, arg1) {
+const bagnoogle = function(arg0, arg1) {
stalloogle(arg0 + ' is ' + arg1 + ' except that it is read-only');
};
-var done = false;
+let done = false;
-var doogle = function() {
+const doogle = function() {
if (!done)
setTimeout(doogle, 10);
bagnoogle('The bfs command', '(almost) like ed(1)');
};
-var spawn = require('child_process').spawn;
+const spawn = require('child_process').spawn;
/*
* We're going to use DTrace to stop us, gcore us, and set us running again
* when we call getloadavg() -- with the implicit assumption that our
* deepest function is the only caller of os.loadavg().
*/
-var dtrace = spawn('dtrace', [ '-qwn', 'syscall::getloadavg:entry/pid == ' +
+const dtrace = spawn('dtrace', [ '-qwn', 'syscall::getloadavg:entry/pid == ' +
process.pid + '/{ustack(100, 8192); exit(0); }' ]);
-var output = '';
+let output = '';
dtrace.stderr.on('data', function(data) {
console.log('dtrace: ' + data);
@@ -59,17 +59,17 @@ dtrace.on('exit', function(code) {
done = true;
- var sentinel = '(anon) as ';
- var lines = output.split('\n');
+ const sentinel = '(anon) as ';
+ const lines = output.split('\n');
- for (var i = 0; i < lines.length; i++) {
- var line = lines[i];
+ for (let i = 0; i < lines.length; i++) {
+ const line = lines[i];
if (line.indexOf(sentinel) === -1 || frames.length === 0)
continue;
- var frame = line.substr(line.indexOf(sentinel) + sentinel.length);
- var top = frames.shift();
+ const frame = line.substr(line.indexOf(sentinel) + sentinel.length);
+ const top = frames.shift();
assert.equal(frame.indexOf(top), 0, 'unexpected frame where ' +
top + ' was expected');
diff --git a/test/pummel/test-exec.js b/test/pummel/test-exec.js
index 18404373318917..131b214fc53f42 100644
--- a/test/pummel/test-exec.js
+++ b/test/pummel/test-exec.js
@@ -1,9 +1,9 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var exec = require('child_process').exec;
+const common = require('../common');
+const assert = require('assert');
+const exec = require('child_process').exec;
-var SLEEP3_COMMAND;
+let SLEEP3_COMMAND;
if (!common.isWindows) {
// Unix.
SLEEP3_COMMAND = 'sleep 3';
@@ -14,8 +14,8 @@ if (!common.isWindows) {
}
-var success_count = 0;
-var error_count = 0;
+let success_count = 0;
+let error_count = 0;
exec(
@@ -55,9 +55,9 @@ exec('thisisnotavalidcommand', function(err, stdout, stderr) {
});
-var sleeperStart = new Date();
+const sleeperStart = new Date();
exec(SLEEP3_COMMAND, { timeout: 50 }, function(err, stdout, stderr) {
- var diff = (new Date()) - sleeperStart;
+ const diff = (new Date()) - sleeperStart;
console.log('\'sleep 3\' with timeout 50 took %d ms', diff);
assert.ok(diff < 500);
assert.ok(err);
@@ -68,8 +68,8 @@ exec(SLEEP3_COMMAND, { timeout: 50 }, function(err, stdout, stderr) {
});
-var startSleep3 = new Date();
-var killMeTwice = exec(SLEEP3_COMMAND, {timeout: 1000}, killMeTwiceCallback);
+const startSleep3 = new Date();
+const killMeTwice = exec(SLEEP3_COMMAND, {timeout: 1000}, killMeTwiceCallback);
process.nextTick(function() {
console.log('kill pid %d', killMeTwice.pid);
@@ -81,7 +81,7 @@ process.nextTick(function() {
});
function killMeTwiceCallback(err, stdout, stderr) {
- var diff = (new Date()) - startSleep3;
+ const diff = (new Date()) - startSleep3;
// We should have already killed this process. Assert that the timeout still
// works and that we are getting the proper callback parameters.
assert.ok(err);
diff --git a/test/pummel/test-fs-watch-file-slow.js b/test/pummel/test-fs-watch-file-slow.js
index 508de487f6dc23..78c36152ecd315 100644
--- a/test/pummel/test-fs-watch-file-slow.js
+++ b/test/pummel/test-fs-watch-file-slow.js
@@ -1,13 +1,13 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var path = require('path');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const path = require('path');
+const fs = require('fs');
-var FILENAME = path.join(common.tmpDir, 'watch-me');
-var TIMEOUT = 1300;
+const FILENAME = path.join(common.tmpDir, 'watch-me');
+const TIMEOUT = 1300;
-var nevents = 0;
+let nevents = 0;
try {
fs.unlinkSync(FILENAME);
diff --git a/test/pummel/test-fs-watch-file.js b/test/pummel/test-fs-watch-file.js
index fc291cfe64c618..7713fe74ed99aa 100644
--- a/test/pummel/test-fs-watch-file.js
+++ b/test/pummel/test-fs-watch-file.js
@@ -1,26 +1,26 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var path = require('path');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const path = require('path');
+const fs = require('fs');
-var watchSeenOne = 0;
-var watchSeenTwo = 0;
-var watchSeenThree = 0;
-var watchSeenFour = 0;
+let watchSeenOne = 0;
+let watchSeenTwo = 0;
+let watchSeenThree = 0;
+let watchSeenFour = 0;
-var testDir = common.tmpDir;
+const testDir = common.tmpDir;
-var filenameOne = 'watch.txt';
-var filepathOne = path.join(testDir, filenameOne);
+const filenameOne = 'watch.txt';
+const filepathOne = path.join(testDir, filenameOne);
-var filenameTwo = 'hasOwnProperty';
-var filepathTwo = filenameTwo;
-var filepathTwoAbs = path.join(testDir, filenameTwo);
+const filenameTwo = 'hasOwnProperty';
+const filepathTwo = filenameTwo;
+const filepathTwoAbs = path.join(testDir, filenameTwo);
-var filenameThree = 'charm'; // because the third time is
+const filenameThree = 'charm'; // because the third time is
-var filenameFour = 'get';
+const filenameFour = 'get';
process.on('exit', function() {
fs.unlinkSync(filepathOne);
diff --git a/test/pummel/test-fs-watch-non-recursive.js b/test/pummel/test-fs-watch-non-recursive.js
index ead7de9e28dc47..b7c19b9c360818 100644
--- a/test/pummel/test-fs-watch-non-recursive.js
+++ b/test/pummel/test-fs-watch-non-recursive.js
@@ -1,11 +1,11 @@
'use strict';
-var common = require('../common');
-var path = require('path');
-var fs = require('fs');
+const common = require('../common');
+const path = require('path');
+const fs = require('fs');
-var testDir = common.tmpDir;
-var testsubdir = path.join(testDir, 'testsubdir');
-var filepath = path.join(testsubdir, 'watch.txt');
+const testDir = common.tmpDir;
+const testsubdir = path.join(testDir, 'testsubdir');
+const filepath = path.join(testsubdir, 'watch.txt');
function cleanup() {
try { fs.unlinkSync(filepath); } catch (e) { }
@@ -18,7 +18,7 @@ try { fs.mkdirSync(testsubdir, 0o700); } catch (e) {}
// Need a grace period, else the mkdirSync() above fires off an event.
setTimeout(function() {
- var watcher = fs.watch(testDir, { persistent: true }, common.fail);
+ const watcher = fs.watch(testDir, { persistent: true }, common.fail);
setTimeout(function() {
fs.writeFileSync(filepath, 'test');
}, 100);
diff --git a/test/pummel/test-http-client-reconnect-bug.js b/test/pummel/test-http-client-reconnect-bug.js
index 395a538178fe79..98d21c5cba7bc5 100644
--- a/test/pummel/test-http-client-reconnect-bug.js
+++ b/test/pummel/test-http-client-reconnect-bug.js
@@ -3,17 +3,17 @@ const common = require('../common');
const net = require('net');
const http = require('http');
-var server = net.createServer(function(socket) {
+const server = net.createServer(function(socket) {
socket.end();
});
server.on('listening', common.mustCall(function() {
- var client = http.createClient(common.PORT);
+ const client = http.createClient(common.PORT);
client.on('error', common.mustCall(function(err) {}));
client.on('end', common.mustCall(function() {}));
- var request = client.request('GET', '/', {'host': 'localhost'});
+ const request = client.request('GET', '/', {'host': 'localhost'});
request.end();
request.on('response', function(response) {
console.log('STATUS: ' + response.statusCode);
diff --git a/test/pummel/test-http-many-keep-alive-connections.js b/test/pummel/test-http-many-keep-alive-connections.js
index 293c6ab748e9c2..e465c02a90161c 100644
--- a/test/pummel/test-http-many-keep-alive-connections.js
+++ b/test/pummel/test-http-many-keep-alive-connections.js
@@ -1,14 +1,14 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var http = require('http');
+const common = require('../common');
+const assert = require('assert');
+const http = require('http');
-var expected = 10000;
-var responses = 0;
-var requests = 0;
-var connection;
+const expected = 10000;
+let responses = 0;
+let requests = 0;
+let connection;
-var server = http.Server(function(req, res) {
+const server = http.Server(function(req, res) {
requests++;
assert.equal(req.connection, connection);
res.writeHead(200);
@@ -20,7 +20,7 @@ server.once('connection', function(c) {
});
server.listen(common.PORT, function connect() {
- var request = http.get({
+ const request = http.get({
port: common.PORT,
path: '/',
headers: {
diff --git a/test/pummel/test-http-upload-timeout.js b/test/pummel/test-http-upload-timeout.js
index 15bc267ff61947..da91ab3f0909e7 100644
--- a/test/pummel/test-http-upload-timeout.js
+++ b/test/pummel/test-http-upload-timeout.js
@@ -24,18 +24,18 @@ server.on('request', function(req, res) {
});
server.listen(common.PORT, '127.0.0.1', function() {
- for (var i = 0; i < 10; i++) {
+ for (let i = 0; i < 10; i++) {
connections++;
setTimeout(function() {
- var request = http.request({
+ const request = http.request({
port: common.PORT,
method: 'POST',
path: '/'
});
function ping() {
- var nextPing = (Math.random() * 900).toFixed();
+ const nextPing = (Math.random() * 900).toFixed();
if (nextPing > 600) {
request.end();
return;
diff --git a/test/pummel/test-https-ci-reneg-attack.js b/test/pummel/test-https-ci-reneg-attack.js
index 8bda7cc10286e9..850e0949c4a64a 100644
--- a/test/pummel/test-https-ci-reneg-attack.js
+++ b/test/pummel/test-https-ci-reneg-attack.js
@@ -1,16 +1,16 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
+const common = require('../common');
+const assert = require('assert');
+const spawn = require('child_process').spawn;
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
-var https = require('https');
+const tls = require('tls');
+const https = require('https');
-var fs = require('fs');
+const fs = require('fs');
if (!common.opensslCli) {
common.skip('node compiled without OpenSSL CLI.');
@@ -18,7 +18,7 @@ if (!common.opensslCli) {
}
// renegotiation limits to test
-var LIMITS = [0, 1, 2, 3, 5, 10, 16];
+const LIMITS = [0, 1, 2, 3, 5, 10, 16];
{
let n = 0;
@@ -31,15 +31,15 @@ var LIMITS = [0, 1, 2, 3, 5, 10, 16];
}
function test(next) {
- var options = {
+ const options = {
cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem'),
key: fs.readFileSync(common.fixturesDir + '/test_key.pem')
};
- var seenError = false;
+ let seenError = false;
- var server = https.createServer(options, function(req, res) {
- var conn = req.connection;
+ const server = https.createServer(options, function(req, res) {
+ const conn = req.connection;
conn.on('error', function(err) {
console.error('Caught exception: ' + err);
assert(/TLS session renegotiation attack/.test(err));
@@ -50,8 +50,8 @@ function test(next) {
});
server.listen(common.PORT, function() {
- var args = ('s_client -connect 127.0.0.1:' + common.PORT).split(' ');
- var child = spawn(common.opensslCli, args);
+ const args = ('s_client -connect 127.0.0.1:' + common.PORT).split(' ');
+ const child = spawn(common.opensslCli, args);
//child.stdout.pipe(process.stdout);
//child.stderr.pipe(process.stderr);
@@ -60,8 +60,8 @@ function test(next) {
child.stderr.resume();
// count handshakes, start the attack after the initial handshake is done
- var handshakes = 0;
- var renegs = 0;
+ let handshakes = 0;
+ let renegs = 0;
child.stderr.on('data', function(data) {
if (seenError) return;
@@ -76,7 +76,7 @@ function test(next) {
process.nextTick(next);
});
- var closed = false;
+ let closed = false;
child.stdin.on('error', function(err) {
switch (err.code) {
case 'ECONNRESET':
diff --git a/test/pummel/test-https-large-response.js b/test/pummel/test-https-large-response.js
index a122e47bc57a57..39256aa6304b74 100644
--- a/test/pummel/test-https-large-response.js
+++ b/test/pummel/test-https-large-response.js
@@ -1,25 +1,25 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var fs = require('fs');
+const fs = require('fs');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
process.stdout.write('build body...');
-var body = 'hello world\n'.repeat(1024 * 1024);
+const body = 'hello world\n'.repeat(1024 * 1024);
process.stdout.write('done\n');
-var server = https.createServer(options, common.mustCall(function(req, res) {
+const server = https.createServer(options, common.mustCall(function(req, res) {
console.log('got request');
res.writeHead(200, { 'content-type': 'text/plain' });
res.end(body);
@@ -32,7 +32,7 @@ server.listen(common.PORT, common.mustCall(function() {
}, common.mustCall(function(res) {
console.log('response!');
- var count = 0;
+ let count = 0;
res.on('data', function(d) {
process.stdout.write('.');
diff --git a/test/pummel/test-https-no-reader.js b/test/pummel/test-https-no-reader.js
index fab59591993a69..a08676277af6ce 100644
--- a/test/pummel/test-https-no-reader.js
+++ b/test/pummel/test-https-no-reader.js
@@ -1,34 +1,34 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var Buffer = require('buffer').Buffer;
-var fs = require('fs');
-var path = require('path');
+const Buffer = require('buffer').Buffer;
+const fs = require('fs');
+const path = require('path');
-var options = {
+const options = {
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
};
-var buf = Buffer.allocUnsafe(1024 * 1024);
+const buf = Buffer.allocUnsafe(1024 * 1024);
-var server = https.createServer(options, function(req, res) {
+const server = https.createServer(options, function(req, res) {
res.writeHead(200);
- for (var i = 0; i < 50; i++) {
+ for (let i = 0; i < 50; i++) {
res.write(buf);
}
res.end();
});
server.listen(common.PORT, function() {
- var req = https.request({
+ const req = https.request({
method: 'POST',
port: common.PORT,
rejectUnauthorized: false
diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js
index 47d529b64082fa..a9e91e201bb19b 100644
--- a/test/pummel/test-keep-alive.js
+++ b/test/pummel/test-keep-alive.js
@@ -1,11 +1,11 @@
'use strict';
// This test requires the program 'wrk'
-var common = require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
-var http = require('http');
-var url = require('url');
+const common = require('../common');
+const assert = require('assert');
+const spawn = require('child_process').spawn;
+const http = require('http');
+const url = require('url');
if (common.isWindows) {
common.skip('no `wrk` on windows');
diff --git a/test/pummel/test-net-connect-econnrefused.js b/test/pummel/test-net-connect-econnrefused.js
index 2b6dc84f37195c..30da36d983e4f7 100644
--- a/test/pummel/test-net-connect-econnrefused.js
+++ b/test/pummel/test-net-connect-econnrefused.js
@@ -1,21 +1,22 @@
'use strict';
// verify that connect reqs are properly cleaned up
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
-var ROUNDS = 10;
-var ATTEMPTS_PER_ROUND = 100;
-var rounds = 1;
-var reqs = 0;
+const ROUNDS = 10;
+const ATTEMPTS_PER_ROUND = 100;
+let rounds = 1;
+let reqs = 0;
pummel();
function pummel() {
console.log('Round', rounds, '/', ROUNDS);
- for (var pending = 0; pending < ATTEMPTS_PER_ROUND; pending++) {
+ let pending;
+ for (pending = 0; pending < ATTEMPTS_PER_ROUND; pending++) {
net.createConnection(common.PORT).on('error', function(err) {
assert.equal(err.code, 'ECONNREFUSED');
if (--pending > 0) return;
@@ -34,7 +35,7 @@ function check() {
check_called = true;
}, 0);
}
-var check_called = false;
+let check_called = false;
process.on('exit', function() {
assert.equal(rounds, ROUNDS);
diff --git a/test/pummel/test-net-connect-memleak.js b/test/pummel/test-net-connect-memleak.js
index 3b91a110eaa585..f16034e4773510 100644
--- a/test/pummel/test-net-connect-memleak.js
+++ b/test/pummel/test-net-connect-memleak.js
@@ -1,9 +1,9 @@
'use strict';
// Flags: --expose-gc
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
assert.strictEqual(
typeof global.gc,
@@ -12,7 +12,7 @@ assert.strictEqual(
);
net.createServer(function() {}).listen(common.PORT);
-var before = 0;
+let before = 0;
{
// 2**26 == 64M entries
global.gc();
@@ -29,8 +29,8 @@ var before = 0;
function done() {
global.gc();
- var after = process.memoryUsage().rss;
- var reclaimed = (before - after) / 1024;
+ const after = process.memoryUsage().rss;
+ const reclaimed = (before - after) / 1024;
console.log('%d kB reclaimed', reclaimed);
assert(reclaimed > 128 * 1024); // It's around 256 MB on x64.
process.exit();
diff --git a/test/pummel/test-net-many-clients.js b/test/pummel/test-net-many-clients.js
index 52d05b35cbe2c4..a92ae033a09a17 100644
--- a/test/pummel/test-net-many-clients.js
+++ b/test/pummel/test-net-many-clients.js
@@ -1,19 +1,19 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
// settings
-var bytes = 1024 * 40;
-var concurrency = 100;
-var connections_per_client = 5;
+const bytes = 1024 * 40;
+const concurrency = 100;
+const connections_per_client = 5;
// measured
-var total_connections = 0;
+let total_connections = 0;
-var body = 'C'.repeat(bytes);
+const body = 'C'.repeat(bytes);
-var server = net.createServer(function(c) {
+const server = net.createServer(function(c) {
console.log('connected');
total_connections++;
console.log('#');
@@ -22,7 +22,7 @@ var server = net.createServer(function(c) {
});
function runClient(callback) {
- var client = net.createConnection(common.PORT);
+ const client = net.createConnection(common.PORT);
client.connections = 0;
@@ -66,8 +66,8 @@ function runClient(callback) {
}
server.listen(common.PORT, function() {
- var finished_clients = 0;
- for (var i = 0; i < concurrency; i++) {
+ let finished_clients = 0;
+ for (let i = 0; i < concurrency; i++) {
runClient(function() {
if (++finished_clients === concurrency) server.close();
});
diff --git a/test/pummel/test-net-pause.js b/test/pummel/test-net-pause.js
index b0c51260436e0c..db426edbe9c507 100644
--- a/test/pummel/test-net-pause.js
+++ b/test/pummel/test-net-pause.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
-var N = 200;
-var recv = '', chars_recved = 0;
+const N = 200;
+let recv = '', chars_recved = 0;
-var server = net.createServer(function(connection) {
+const server = net.createServer(function(connection) {
function write(j) {
if (j >= N) {
connection.end();
@@ -21,7 +21,7 @@ var server = net.createServer(function(connection) {
});
server.on('listening', function() {
- var client = net.createConnection(common.PORT);
+ const client = net.createConnection(common.PORT);
client.setEncoding('ascii');
client.on('data', function(d) {
console.log(d);
diff --git a/test/pummel/test-net-pingpong-delay.js b/test/pummel/test-net-pingpong-delay.js
index c9cac778d59f4e..9a598435d1bd28 100644
--- a/test/pummel/test-net-pingpong-delay.js
+++ b/test/pummel/test-net-pingpong-delay.js
@@ -1,15 +1,15 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
function pingPongTest(port, host, on_complete) {
- var N = 100;
- var DELAY = 1;
- var count = 0;
- var client_ended = false;
+ const N = 100;
+ const DELAY = 1;
+ let count = 0;
+ let client_ended = false;
- var server = net.createServer({ allowHalfOpen: true }, function(socket) {
+ const server = net.createServer({ allowHalfOpen: true }, function(socket) {
socket.setEncoding('utf8');
socket.on('data', function(data) {
@@ -43,7 +43,7 @@ function pingPongTest(port, host, on_complete) {
});
server.listen(port, host, common.mustCall(function() {
- var client = net.createConnection(port, host);
+ const client = net.createConnection(port, host);
client.setEncoding('utf8');
diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js
index 85dce02b6cf635..6ede6f9fcb2763 100644
--- a/test/pummel/test-net-pingpong.js
+++ b/test/pummel/test-net-pingpong.js
@@ -1,19 +1,19 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
-var tests_run = 0;
+let tests_run = 0;
function pingPongTest(port, host, on_complete) {
- var N = 1000;
- var count = 0;
- var sent_final_ping = false;
+ const N = 1000;
+ let count = 0;
+ let sent_final_ping = false;
- var server = net.createServer({ allowHalfOpen: true }, function(socket) {
+ const server = net.createServer({ allowHalfOpen: true }, function(socket) {
assert.equal(true, socket.remoteAddress !== null);
assert.equal(true, socket.remoteAddress !== undefined);
- var address = socket.remoteAddress;
+ const address = socket.remoteAddress;
if (host === '127.0.0.1') {
assert.equal(address, '127.0.0.1');
} else if (host == null || host === 'localhost') {
@@ -49,7 +49,7 @@ function pingPongTest(port, host, on_complete) {
});
server.listen(port, host, function() {
- var client = net.createConnection(port, host);
+ const client = net.createConnection(port, host);
client.setEncoding('utf8');
diff --git a/test/pummel/test-net-throttle.js b/test/pummel/test-net-throttle.js
index d2f32ec25b6ff2..23f05f4d5eaeaa 100644
--- a/test/pummel/test-net-throttle.js
+++ b/test/pummel/test-net-throttle.js
@@ -5,15 +5,15 @@ const net = require('net');
const N = 1024 * 1024;
const part_N = N / 3;
-var chars_recved = 0;
-var npauses = 0;
+let chars_recved = 0;
+let npauses = 0;
console.log('build big string');
const body = 'C'.repeat(N);
console.log('start server on port ' + common.PORT);
-var server = net.createServer(function(connection) {
+const server = net.createServer(function(connection) {
connection.write(body.slice(0, part_N));
connection.write(body.slice(part_N, 2 * part_N));
assert.equal(false, connection.write(body.slice(2 * part_N, N)));
@@ -24,8 +24,8 @@ var server = net.createServer(function(connection) {
});
server.listen(common.PORT, function() {
- var paused = false;
- var client = net.createConnection(common.PORT);
+ let paused = false;
+ const client = net.createConnection(common.PORT);
client.setEncoding('ascii');
client.on('data', function(d) {
chars_recved += d.length;
@@ -35,7 +35,7 @@ server.listen(common.PORT, function() {
npauses += 1;
paused = true;
console.log('pause');
- var x = chars_recved;
+ const x = chars_recved;
setTimeout(function() {
assert.equal(chars_recved, x);
client.resume();
diff --git a/test/pummel/test-net-timeout.js b/test/pummel/test-net-timeout.js
index 415523763eef3c..d6dd8e489cc116 100644
--- a/test/pummel/test-net-timeout.js
+++ b/test/pummel/test-net-timeout.js
@@ -1,14 +1,14 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
+const common = require('../common');
+const assert = require('assert');
+const net = require('net');
-var exchanges = 0;
-var starttime = null;
-var timeouttime = null;
-var timeout = 1000;
+let exchanges = 0;
+let starttime = null;
+let timeouttime = null;
+const timeout = 1000;
-var echo_server = net.createServer(function(socket) {
+const echo_server = net.createServer(function(socket) {
socket.setTimeout(timeout);
socket.on('timeout', function() {
@@ -36,7 +36,7 @@ var echo_server = net.createServer(function(socket) {
echo_server.listen(common.PORT, function() {
console.log('server listening at ' + common.PORT);
- var client = net.createConnection(common.PORT);
+ const client = net.createConnection(common.PORT);
client.setEncoding('UTF8');
client.setTimeout(0); // disable the timeout for client
client.on('connect', function() {
@@ -79,7 +79,7 @@ process.on('exit', function() {
assert.ok(starttime != null);
assert.ok(timeouttime != null);
- var diff = timeouttime - starttime;
+ const diff = timeouttime - starttime;
console.log('diff = ' + diff);
assert.ok(timeout < diff);
diff --git a/test/pummel/test-net-timeout2.js b/test/pummel/test-net-timeout2.js
index 7af47a47a8b634..a3d0abceb6c765 100644
--- a/test/pummel/test-net-timeout2.js
+++ b/test/pummel/test-net-timeout2.js
@@ -2,16 +2,16 @@
// socket.write was not resetting the timeout timer. See
// https://github.com/joyent/node/issues/2002
-var common = require('../common');
-var net = require('net');
+const common = require('../common');
+const net = require('net');
-var seconds = 5;
-var counter = 0;
+const seconds = 5;
+let counter = 0;
-var server = net.createServer(function(socket) {
+const server = net.createServer(function(socket) {
socket.setTimeout((seconds / 2) * 1000, common.fail);
- var interval = setInterval(function() {
+ const interval = setInterval(function() {
counter++;
if (counter === seconds) {
@@ -28,6 +28,6 @@ var server = net.createServer(function(socket) {
server.listen(common.PORT, function() {
- var s = net.connect(common.PORT);
+ const s = net.connect(common.PORT);
s.pipe(process.stdout);
});
diff --git a/test/pummel/test-net-write-callbacks.js b/test/pummel/test-net-write-callbacks.js
index 21eae0f5ab72d0..6c3c1f202a81c3 100644
--- a/test/pummel/test-net-write-callbacks.js
+++ b/test/pummel/test-net-write-callbacks.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var net = require('net');
-var assert = require('assert');
+const common = require('../common');
+const net = require('net');
+const assert = require('assert');
-var cbcount = 0;
-var N = 500000;
+let cbcount = 0;
+const N = 500000;
-var server = net.Server(function(socket) {
+const server = net.Server(function(socket) {
socket.on('data', function(d) {
console.error('got %d bytes', d.length);
});
@@ -18,9 +18,9 @@ var server = net.Server(function(socket) {
});
});
-var lastCalled = -1;
+let lastCalled = -1;
function makeCallback(c) {
- var called = false;
+ let called = false;
return function() {
if (called)
throw new Error('called callback #' + c + ' more than once');
@@ -34,10 +34,10 @@ function makeCallback(c) {
}
server.listen(common.PORT, function() {
- var client = net.createConnection(common.PORT);
+ const client = net.createConnection(common.PORT);
client.on('connect', function() {
- for (var i = 0; i < N; i++) {
+ for (let i = 0; i < N; i++) {
client.write('hello world', makeCallback(i));
}
client.end();
diff --git a/test/pummel/test-next-tick-infinite-calls.js b/test/pummel/test-next-tick-infinite-calls.js
index 18223885d6cc19..afce6ef846b10f 100644
--- a/test/pummel/test-next-tick-infinite-calls.js
+++ b/test/pummel/test-next-tick-infinite-calls.js
@@ -1,7 +1,7 @@
'use strict';
require('../common');
-var complete = 0;
+let complete = 0;
// This will fail with:
// FATAL ERROR: JS Allocation failed - process out of memory
diff --git a/test/pummel/test-process-hrtime.js b/test/pummel/test-process-hrtime.js
index 04225bae421b1a..d02b9c79822a88 100644
--- a/test/pummel/test-process-hrtime.js
+++ b/test/pummel/test-process-hrtime.js
@@ -1,18 +1,18 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var start = process.hrtime();
+const start = process.hrtime();
// process.hrtime() should return an Array
assert(Array.isArray(start));
// busy-loop for 2 seconds
-var now = Date.now();
+const now = Date.now();
while (Date.now() - now < 2000);
// get a diff reading
-var diff = process.hrtime(start);
+const diff = process.hrtime(start);
// should be at least 1 second, at most 2 seconds later
// (the while loop will usually exit a few nanoseconds before 2)
diff --git a/test/pummel/test-process-uptime.js b/test/pummel/test-process-uptime.js
index 8d2d88b74f736f..5c09d59b06d55c 100644
--- a/test/pummel/test-process-uptime.js
+++ b/test/pummel/test-process-uptime.js
@@ -1,14 +1,14 @@
'use strict';
require('../common');
-var assert = require('assert');
+const assert = require('assert');
console.error(process.uptime());
assert.ok(process.uptime() <= 2);
-var original = process.uptime();
+const original = process.uptime();
setTimeout(function() {
- var uptime = process.uptime();
+ const uptime = process.uptime();
// some wiggle room to account for timer
// granularity, processor speed, and scheduling
assert.ok(uptime >= original + 2);
diff --git a/test/pummel/test-regress-GH-814.js b/test/pummel/test-regress-GH-814.js
index 7bbd13dd196457..a3700c500b4f53 100644
--- a/test/pummel/test-regress-GH-814.js
+++ b/test/pummel/test-regress-GH-814.js
@@ -4,7 +4,7 @@
const common = require('../common');
function newBuffer(size, value) {
- var buffer = Buffer.allocUnsafe(size);
+ const buffer = Buffer.allocUnsafe(size);
while (size--) {
buffer[size] = value;
}
@@ -13,19 +13,19 @@ function newBuffer(size, value) {
return buffer;
}
-var fs = require('fs');
-var testFileName = require('path').join(common.tmpDir, 'GH-814_testFile.txt');
-var testFileFD = fs.openSync(testFileName, 'w');
+const fs = require('fs');
+const testFileName = require('path').join(common.tmpDir, 'GH-814_testFile.txt');
+const testFileFD = fs.openSync(testFileName, 'w');
console.log(testFileName);
-var kBufSize = 128 * 1024;
-var PASS = true;
-var neverWrittenBuffer = newBuffer(kBufSize, 0x2e); //0x2e === '.'
-var bufPool = [];
+const kBufSize = 128 * 1024;
+let PASS = true;
+const neverWrittenBuffer = newBuffer(kBufSize, 0x2e); //0x2e === '.'
+const bufPool = [];
-var tail = require('child_process').spawn('tail', ['-f', testFileName]);
+const tail = require('child_process').spawn('tail', ['-f', testFileName]);
tail.stdout.on('data', tailCB);
function tailCB(data) {
@@ -33,13 +33,13 @@ function tailCB(data) {
}
-var timeToQuit = Date.now() + 8e3; //Test during no more than this seconds.
+const timeToQuit = Date.now() + 8e3; //Test during no more than this seconds.
(function main() {
if (PASS) {
fs.write(testFileFD, newBuffer(kBufSize, 0x61), 0, kBufSize, -1, cb);
global.gc();
- var nuBuf = Buffer.allocUnsafe(kBufSize);
+ const nuBuf = Buffer.allocUnsafe(kBufSize);
neverWrittenBuffer.copy(nuBuf);
if (bufPool.push(nuBuf) > 100) {
bufPool.length = 0;
diff --git a/test/pummel/test-regress-GH-814_2.js b/test/pummel/test-regress-GH-814_2.js
index 7909a461f37956..ba7d45124bf9fa 100644
--- a/test/pummel/test-regress-GH-814_2.js
+++ b/test/pummel/test-regress-GH-814_2.js
@@ -1,15 +1,15 @@
'use strict';
// Flags: --expose_gc
-var common = require('../common');
+const common = require('../common');
-var fs = require('fs');
-var testFileName = require('path').join(common.tmpDir, 'GH-814_test.txt');
-var testFD = fs.openSync(testFileName, 'w');
+const fs = require('fs');
+const testFileName = require('path').join(common.tmpDir, 'GH-814_test.txt');
+const testFD = fs.openSync(testFileName, 'w');
console.error(testFileName + '\n');
-var tailProc = require('child_process').spawn('tail', ['-f', testFileName]);
+const tailProc = require('child_process').spawn('tail', ['-f', testFileName]);
tailProc.stdout.on('data', tailCB);
function tailCB(data) {
@@ -26,12 +26,12 @@ function tailCB(data) {
}
-var PASS = true;
-var bufPool = [];
-var kBufSize = 16 * 1024 * 1024;
-var neverWrittenBuffer = newBuffer(kBufSize, 0x2e); //0x2e === '.'
+let PASS = true;
+const bufPool = [];
+const kBufSize = 16 * 1024 * 1024;
+const neverWrittenBuffer = newBuffer(kBufSize, 0x2e); //0x2e === '.'
-var timeToQuit = Date.now() + 5e3; //Test should last no more than this.
+const timeToQuit = Date.now() + 5e3; //Test should last no more than this.
writer();
function writer() {
@@ -50,7 +50,7 @@ function writer() {
global.gc();
global.gc();
global.gc();
- var nuBuf = Buffer.allocUnsafe(kBufSize);
+ const nuBuf = Buffer.allocUnsafe(kBufSize);
neverWrittenBuffer.copy(nuBuf);
if (bufPool.push(nuBuf) > 100) {
bufPool.length = 0;
@@ -74,7 +74,7 @@ function writerCB(err, written) {
function newBuffer(size, value) {
- var buffer = Buffer.allocUnsafe(size);
+ const buffer = Buffer.allocUnsafe(size);
while (size--) {
buffer[size] = value;
}
diff --git a/test/pummel/test-regress-GH-892.js b/test/pummel/test-regress-GH-892.js
index 8bbf3c8f1a0ff4..0619fd84de3b5e 100644
--- a/test/pummel/test-regress-GH-892.js
+++ b/test/pummel/test-regress-GH-892.js
@@ -5,39 +5,40 @@
// to POST a 32mb file to us. A bug in the pause/resume functionality of the
// TLS server causes the child process to exit cleanly before having sent
// the entire buffer.
-var common = require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
+const common = require('../common');
+const assert = require('assert');
+const spawn = require('child_process').spawn;
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var https = require('https');
+const https = require('https');
-var fs = require('fs');
+const fs = require('fs');
-var bytesExpected = 1024 * 1024 * 32;
+const bytesExpected = 1024 * 1024 * 32;
-var started = false;
+let started = false;
-var childScript = require('path').join(common.fixturesDir, 'GH-892-request.js');
+const childScript = require('path').join(common.fixturesDir,
+ 'GH-892-request.js');
function makeRequest() {
if (started) return;
started = true;
- var stderrBuffer = '';
+ let stderrBuffer = '';
// Pass along --trace-deprecation/--throw-deprecation in
// process.execArgv to track down nextTick recursion errors
// more easily. Also, this is handy when using this test to
// view V8 opt/deopt behavior.
- var args = process.execArgv.concat([ childScript,
- common.PORT,
- bytesExpected ]);
+ const args = process.execArgv.concat([ childScript,
+ common.PORT,
+ bytesExpected ]);
- var child = spawn(process.execPath, args);
+ const child = spawn(process.execPath, args);
child.on('exit', function(code) {
assert.ok(/DONE/.test(stderrBuffer));
@@ -58,14 +59,14 @@ function makeRequest() {
}
-var serverOptions = {
+const serverOptions = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
-var uploadCount = 0;
+let uploadCount = 0;
-var server = https.Server(serverOptions, function(req, res) {
+const server = https.Server(serverOptions, function(req, res) {
// Close the server immediately. This test is only doing a single upload.
// We need to make sure the server isn't keeping the event loop alive
// while the upload is in progress.
diff --git a/test/pummel/test-stream-pipe-multi.js b/test/pummel/test-stream-pipe-multi.js
index 897b9d6dc27d46..e1e5e011020fe2 100644
--- a/test/pummel/test-stream-pipe-multi.js
+++ b/test/pummel/test-stream-pipe-multi.js
@@ -3,16 +3,16 @@
// doesn't break anything.
require('../common');
-var assert = require('assert');
-var Stream = require('stream').Stream;
-var rr = [];
-var ww = [];
-var cnt = 100;
-var chunks = 1000;
-var chunkSize = 250;
-var data = Buffer.allocUnsafe(chunkSize);
-var wclosed = 0;
-var rclosed = 0;
+const assert = require('assert');
+const Stream = require('stream').Stream;
+const rr = [];
+const ww = [];
+const cnt = 100;
+const chunks = 1000;
+const chunkSize = 250;
+const data = Buffer.allocUnsafe(chunkSize);
+let wclosed = 0;
+let rclosed = 0;
function FakeStream() {
Stream.apply(this);
@@ -54,14 +54,14 @@ for (let i = 0; i < chunkSize; i++) {
}
for (let i = 0; i < cnt; i++) {
- var r = new FakeStream();
+ const r = new FakeStream();
r.on('close', function() {
console.error(this.ID, 'read close');
rclosed++;
});
rr.push(r);
- var w = new FakeStream();
+ const w = new FakeStream();
w.on('close', function() {
console.error(this.ID, 'write close');
wclosed++;
@@ -75,8 +75,8 @@ for (let i = 0; i < cnt; i++) {
// now start passing through data
// simulate a relatively fast async stream.
rr.forEach(function(r) {
- var cnt = chunks;
- var paused = false;
+ let cnt = chunks;
+ let paused = false;
r.on('pause', function() {
paused = true;
diff --git a/test/pummel/test-stream2-basic.js b/test/pummel/test-stream2-basic.js
index 6bb2386b0b17dc..67ee4eb7a812a6 100644
--- a/test/pummel/test-stream2-basic.js
+++ b/test/pummel/test-stream2-basic.js
@@ -1,10 +1,10 @@
'use strict';
require('../common');
-var R = require('_stream_readable');
-var assert = require('assert');
+const R = require('_stream_readable');
+const assert = require('assert');
-var util = require('util');
-var EE = require('events').EventEmitter;
+const util = require('util');
+const EE = require('events').EventEmitter;
function TestReader(n) {
R.apply(this);
@@ -16,9 +16,9 @@ function TestReader(n) {
util.inherits(TestReader, R);
TestReader.prototype._read = function(n) {
- var max = this._buffer.length - this._pos;
+ const max = this._buffer.length - this._pos;
n = Math.max(n, 0);
- var toRead = Math.min(n, max);
+ const toRead = Math.min(n, max);
if (toRead === 0) {
// simulate the read buffer filling up with some more bytes some time
// in the future.
@@ -39,7 +39,7 @@ TestReader.prototype._read = function(n) {
return;
}
- var ret = this._buffer.slice(this._pos, this._pos + toRead);
+ const ret = this._buffer.slice(this._pos, this._pos + toRead);
this._pos += toRead;
this.push(ret);
};
@@ -68,8 +68,8 @@ TestWriter.prototype.end = function(c) {
////////
// tiny node-tap lookalike.
-var tests = [];
-var count = 0;
+const tests = [];
+let count = 0;
function test(name, fn) {
count++;
@@ -77,12 +77,12 @@ function test(name, fn) {
}
function run() {
- var next = tests.shift();
+ const next = tests.shift();
if (!next)
return console.error('ok');
- var name = next[0];
- var fn = next[1];
+ const name = next[0];
+ const fn = next[1];
console.log('# %s', name);
fn({
same: assert.deepStrictEqual,
@@ -104,34 +104,34 @@ process.nextTick(run);
test('a most basic test', function(t) {
- var r = new TestReader(20);
-
- var reads = [];
- var expect = [ 'x',
- 'xx',
- 'xxx',
- 'xxxx',
- 'xxxxx',
- 'xxxxxxxxx',
- 'xxxxxxxxxx',
- 'xxxxxxxxxxxx',
- 'xxxxxxxxxxxxx',
- 'xxxxxxxxxxxxxxx',
- 'xxxxxxxxxxxxxxxxx',
- 'xxxxxxxxxxxxxxxxxxx',
- 'xxxxxxxxxxxxxxxxxxxxx',
- 'xxxxxxxxxxxxxxxxxxxxxxx',
- 'xxxxxxxxxxxxxxxxxxxxxxxxx',
- 'xxxxxxxxxxxxxxxxxxxxx' ];
+ const r = new TestReader(20);
+
+ const reads = [];
+ const expect = [ 'x',
+ 'xx',
+ 'xxx',
+ 'xxxx',
+ 'xxxxx',
+ 'xxxxxxxxx',
+ 'xxxxxxxxxx',
+ 'xxxxxxxxxxxx',
+ 'xxxxxxxxxxxxx',
+ 'xxxxxxxxxxxxxxx',
+ 'xxxxxxxxxxxxxxxxx',
+ 'xxxxxxxxxxxxxxxxxxx',
+ 'xxxxxxxxxxxxxxxxxxxxx',
+ 'xxxxxxxxxxxxxxxxxxxxxxx',
+ 'xxxxxxxxxxxxxxxxxxxxxxxxx',
+ 'xxxxxxxxxxxxxxxxxxxxx' ];
r.on('end', function() {
t.same(reads, expect);
t.end();
});
- var readSize = 1;
+ let readSize = 1;
function flow() {
- var res;
+ let res;
while (null !== (res = r.read(readSize++))) {
reads.push(res.toString());
}
@@ -142,20 +142,20 @@ test('a most basic test', function(t) {
});
test('pipe', function(t) {
- var r = new TestReader(5);
+ const r = new TestReader(5);
- var expect = [ 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx' ];
+ const expect = [ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx' ];
- var w = new TestWriter();
+ const w = new TestWriter();
w.on('end', function(received) {
t.same(received, expect);
@@ -168,10 +168,10 @@ test('pipe', function(t) {
[1, 2, 3, 4, 5, 6, 7, 8, 9].forEach(function(SPLIT) {
test('unpipe', function(t) {
- var r = new TestReader(5);
+ const r = new TestReader(5);
// unpipe after 3 writes, then write to another stream instead.
- var expect = [ 'xxxxx',
+ let expect = [ 'xxxxx',
'xxxxx',
'xxxxx',
'xxxxx',
@@ -183,9 +183,9 @@ test('pipe', function(t) {
'xxxxx' ];
expect = [ expect.slice(0, SPLIT), expect.slice(SPLIT) ];
- var w = [ new TestWriter(), new TestWriter() ];
+ const w = [ new TestWriter(), new TestWriter() ];
- var writes = SPLIT;
+ let writes = SPLIT;
w[0].on('write', function() {
if (--writes === 0) {
r.unpipe();
@@ -196,10 +196,10 @@ test('pipe', function(t) {
}
});
- var ended = 0;
+ let ended = 0;
- var ended0 = false;
- var ended1 = false;
+ let ended0 = false;
+ let ended1 = false;
w[0].on('end', function(results) {
t.equal(ended0, false);
ended0 = true;
@@ -223,21 +223,21 @@ test('pipe', function(t) {
// both writers should get the same exact data.
test('multipipe', function(t) {
- var r = new TestReader(5);
- var w = [ new TestWriter(), new TestWriter() ];
-
- var expect = [ 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx',
- 'xxxxx' ];
-
- var c = 2;
+ const r = new TestReader(5);
+ const w = [ new TestWriter(), new TestWriter() ];
+
+ const expect = [ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx',
+ 'xxxxx' ];
+
+ let c = 2;
w[0].on('end', function(received) {
t.same(received, expect, 'first');
if (--c === 0) t.end();
@@ -254,10 +254,10 @@ test('multipipe', function(t) {
[1, 2, 3, 4, 5, 6, 7, 8, 9].forEach(function(SPLIT) {
test('multi-unpipe', function(t) {
- var r = new TestReader(5);
+ const r = new TestReader(5);
// unpipe after 3 writes, then write to another stream instead.
- var expect = [ 'xxxxx',
+ let expect = [ 'xxxxx',
'xxxxx',
'xxxxx',
'xxxxx',
@@ -269,9 +269,9 @@ test('multipipe', function(t) {
'xxxxx' ];
expect = [ expect.slice(0, SPLIT), expect.slice(SPLIT) ];
- var w = [ new TestWriter(), new TestWriter(), new TestWriter() ];
+ const w = [ new TestWriter(), new TestWriter(), new TestWriter() ];
- var writes = SPLIT;
+ let writes = SPLIT;
w[0].on('write', function() {
if (--writes === 0) {
r.unpipe();
@@ -280,7 +280,7 @@ test('multipipe', function(t) {
}
});
- var ended = 0;
+ let ended = 0;
w[0].on('end', function(results) {
ended++;
@@ -302,16 +302,16 @@ test('multipipe', function(t) {
test('back pressure respected', function(t) {
function noop() {}
- var r = new R({ objectMode: true });
+ const r = new R({ objectMode: true });
r._read = noop;
- var counter = 0;
+ let counter = 0;
r.push(['one']);
r.push(['two']);
r.push(['three']);
r.push(['four']);
r.push(null);
- var w1 = new R();
+ const w1 = new R();
w1.write = function(chunk) {
console.error('w1.emit("close")');
assert.equal(chunk[0], 'one');
@@ -325,9 +325,9 @@ test('back pressure respected', function(t) {
r.pipe(w1);
- var expected = ['two', 'two', 'three', 'three', 'four', 'four'];
+ const expected = ['two', 'two', 'three', 'three', 'four', 'four'];
- var w2 = new R();
+ let w2 = new R();
w2.write = function(chunk) {
console.error('w2 write', chunk, counter);
assert.equal(chunk[0], expected.shift());
@@ -349,7 +349,7 @@ test('back pressure respected', function(t) {
};
w2.end = noop;
- var w3 = new R();
+ let w3 = new R();
w3.write = function(chunk) {
console.error('w3 write', chunk, counter);
assert.equal(chunk[0], expected.shift());
@@ -377,19 +377,19 @@ test('back pressure respected', function(t) {
});
test('read(0) for ended streams', function(t) {
- var r = new R();
- var written = false;
- var ended = false;
+ const r = new R();
+ let written = false;
+ let ended = false;
r._read = function(n) {};
r.push(Buffer.from('foo'));
r.push(null);
- var v = r.read(0);
+ const v = r.read(0);
assert.equal(v, null);
- var w = new R();
+ const w = new R();
w.write = function(buffer) {
written = true;
@@ -407,8 +407,8 @@ test('read(0) for ended streams', function(t) {
});
test('sync _read ending', function(t) {
- var r = new R();
- var called = false;
+ const r = new R();
+ let called = false;
r._read = function(n) {
r.push(null);
};
@@ -426,9 +426,9 @@ test('sync _read ending', function(t) {
});
test('adding readable triggers data flow', function(t) {
- var r = new R({ highWaterMark: 5 });
- var onReadable = false;
- var readCalled = 0;
+ const r = new R({ highWaterMark: 5 });
+ let onReadable = false;
+ let readCalled = 0;
r._read = function(n) {
if (readCalled++ === 2)
@@ -450,9 +450,9 @@ test('adding readable triggers data flow', function(t) {
});
test('chainable', function(t) {
- var r = new R();
+ const r = new R();
r._read = function() {};
- var r2 = r.setEncoding('utf8').pause().resume().pause();
+ const r2 = r.setEncoding('utf8').pause().resume().pause();
t.equal(r, r2);
t.end();
});
diff --git a/test/pummel/test-timer-wrap.js b/test/pummel/test-timer-wrap.js
index 659912d1fc28ce..d30661716bd2b2 100644
--- a/test/pummel/test-timer-wrap.js
+++ b/test/pummel/test-timer-wrap.js
@@ -1,10 +1,10 @@
'use strict';
const common = require('../common');
-var Timer = process.binding('timer_wrap').Timer;
-var kOnTimeout = Timer.kOnTimeout;
+const Timer = process.binding('timer_wrap').Timer;
+const kOnTimeout = Timer.kOnTimeout;
-var t = new Timer();
+const t = new Timer();
t.start(1000);
diff --git a/test/pummel/test-timer-wrap2.js b/test/pummel/test-timer-wrap2.js
index 87497b2685f5d3..4bae86f8cefb0c 100644
--- a/test/pummel/test-timer-wrap2.js
+++ b/test/pummel/test-timer-wrap2.js
@@ -4,5 +4,5 @@ require('../common');
// Test that allocating a timer does not increase the loop's reference
// count.
-var Timer = process.binding('timer_wrap').Timer;
+const Timer = process.binding('timer_wrap').Timer;
new Timer();
diff --git a/test/pummel/test-timers.js b/test/pummel/test-timers.js
index 588d2327ff37dd..4555582371b9ff 100644
--- a/test/pummel/test-timers.js
+++ b/test/pummel/test-timers.js
@@ -1,21 +1,21 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var WINDOW = 200; // why is does this need to be so big?
+const WINDOW = 200; // why is does this need to be so big?
-var interval_count = 0;
+let interval_count = 0;
// check that these don't blow up.
clearTimeout(null);
clearInterval(null);
assert.equal(true, setTimeout instanceof Function);
-var starttime = new Date();
+const starttime = new Date();
setTimeout(common.mustCall(function() {
- var endtime = new Date();
+ const endtime = new Date();
- var diff = endtime - starttime;
+ const diff = endtime - starttime;
assert.ok(diff > 0);
console.error('diff: ' + diff);
@@ -23,18 +23,18 @@ setTimeout(common.mustCall(function() {
}), 1000);
// this timer shouldn't execute
-var id = setTimeout(function() { assert.equal(true, false); }, 500);
+const id = setTimeout(function() { assert.equal(true, false); }, 500);
clearTimeout(id);
setInterval(function() {
interval_count += 1;
- var endtime = new Date();
+ const endtime = new Date();
- var diff = endtime - starttime;
+ const diff = endtime - starttime;
assert.ok(diff > 0);
console.error('diff: ' + diff);
- var t = interval_count * 1000;
+ const t = interval_count * 1000;
assert.equal(true, t - WINDOW < diff && diff < t + WINDOW);
@@ -49,7 +49,7 @@ setTimeout(function(param) {
assert.equal('test param', param);
}, 1000, 'test param');
-var interval_count2 = 0;
+let interval_count2 = 0;
setInterval(function(param) {
++interval_count2;
assert.equal('test param', param);
@@ -65,7 +65,7 @@ setTimeout(function(param1, param2) {
assert.equal('param2', param2);
}, 1000, 'param1', 'param2');
-var interval_count3 = 0;
+let interval_count3 = 0;
setInterval(function(param1, param2) {
++interval_count3;
assert.equal('param1', param1);
@@ -76,14 +76,14 @@ setInterval(function(param1, param2) {
}, 1000, 'param1', 'param2');
// setInterval(cb, 0) should be called multiple times.
-var count4 = 0;
-var interval4 = setInterval(function() {
+let count4 = 0;
+const interval4 = setInterval(function() {
if (++count4 > 10) clearInterval(interval4);
}, 0);
// we should be able to clearTimeout multiple times without breakage.
-var expectedTimeouts = 3;
+let expectedTimeouts = 3;
function t() {
expectedTimeouts--;
@@ -91,7 +91,7 @@ function t() {
setTimeout(t, 200);
setTimeout(t, 200);
-var y = setTimeout(t, 200);
+const y = setTimeout(t, 200);
clearTimeout(y);
setTimeout(t, 200);
diff --git a/test/pummel/test-tls-ci-reneg-attack.js b/test/pummel/test-tls-ci-reneg-attack.js
index 5075806c1085b6..dd2b43ed60278f 100644
--- a/test/pummel/test-tls-ci-reneg-attack.js
+++ b/test/pummel/test-tls-ci-reneg-attack.js
@@ -1,15 +1,15 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
+const common = require('../common');
+const assert = require('assert');
+const spawn = require('child_process').spawn;
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
if (!common.opensslCli) {
common.skip('node compiled without OpenSSL CLI.');
@@ -17,7 +17,7 @@ if (!common.opensslCli) {
}
// renegotiation limits to test
-var LIMITS = [0, 1, 2, 3, 5, 10, 16];
+const LIMITS = [0, 1, 2, 3, 5, 10, 16];
{
let n = 0;
@@ -30,14 +30,14 @@ var LIMITS = [0, 1, 2, 3, 5, 10, 16];
}
function test(next) {
- var options = {
+ const options = {
cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem'),
key: fs.readFileSync(common.fixturesDir + '/test_key.pem')
};
- var seenError = false;
+ let seenError = false;
- var server = tls.createServer(options, function(conn) {
+ const server = tls.createServer(options, function(conn) {
conn.on('error', function(err) {
console.error('Caught exception: ' + err);
assert(/TLS session renegotiation attack/.test(err));
@@ -48,8 +48,8 @@ function test(next) {
});
server.listen(common.PORT, function() {
- var args = ('s_client -connect 127.0.0.1:' + common.PORT).split(' ');
- var child = spawn(common.opensslCli, args);
+ const args = ('s_client -connect 127.0.0.1:' + common.PORT).split(' ');
+ const child = spawn(common.opensslCli, args);
//child.stdout.pipe(process.stdout);
//child.stderr.pipe(process.stderr);
@@ -58,8 +58,8 @@ function test(next) {
child.stderr.resume();
// count handshakes, start the attack after the initial handshake is done
- var handshakes = 0;
- var renegs = 0;
+ let handshakes = 0;
+ let renegs = 0;
child.stderr.on('data', function(data) {
if (seenError) return;
@@ -74,7 +74,7 @@ function test(next) {
process.nextTick(next);
});
- var closed = false;
+ let closed = false;
child.stdin.on('error', function(err) {
switch (err.code) {
case 'ECONNRESET':
diff --git a/test/pummel/test-tls-connect-memleak.js b/test/pummel/test-tls-connect-memleak.js
index b55e33cee0afc4..b1d1f05190c39d 100644
--- a/test/pummel/test-tls-connect-memleak.js
+++ b/test/pummel/test-tls-connect-memleak.js
@@ -1,16 +1,16 @@
'use strict';
// Flags: --expose-gc
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
+const fs = require('fs');
assert.strictEqual(
typeof global.gc,
@@ -38,10 +38,10 @@ tls.createServer({
}
function done() {
- var before = process.memoryUsage().rss;
+ const before = process.memoryUsage().rss;
global.gc();
- var after = process.memoryUsage().rss;
- var reclaimed = (before - after) / 1024;
+ const after = process.memoryUsage().rss;
+ const reclaimed = (before - after) / 1024;
console.log('%d kB reclaimed', reclaimed);
assert(reclaimed > 256 * 1024); // it's more like 512M on x64
process.exit();
diff --git a/test/pummel/test-tls-securepair-client.js b/test/pummel/test-tls-securepair-client.js
index 7a1b8770132e96..75e7b400592191 100644
--- a/test/pummel/test-tls-securepair-client.js
+++ b/test/pummel/test-tls-securepair-client.js
@@ -1,7 +1,7 @@
'use strict';
//
-var common = require('../common');
+const common = require('../common');
if (!common.opensslCli) {
common.skip('node compiled without OpenSSL CLI.');
@@ -13,12 +13,12 @@ if (!common.hasCrypto) {
return;
}
-var join = require('path').join;
-var net = require('net');
-var assert = require('assert');
-var fs = require('fs');
-var tls = require('tls');
-var spawn = require('child_process').spawn;
+const join = require('path').join;
+const net = require('net');
+const assert = require('assert');
+const fs = require('fs');
+const tls = require('tls');
+const spawn = require('child_process').spawn;
test1();
@@ -40,22 +40,22 @@ function test2() {
function test(keyfn, certfn, check, next) {
keyfn = join(common.fixturesDir, keyfn);
- var key = fs.readFileSync(keyfn).toString();
+ const key = fs.readFileSync(keyfn).toString();
certfn = join(common.fixturesDir, certfn);
- var cert = fs.readFileSync(certfn).toString();
+ const cert = fs.readFileSync(certfn).toString();
- var server = spawn(common.opensslCli, ['s_server',
- '-accept', common.PORT,
- '-cert', certfn,
- '-key', keyfn]);
+ const server = spawn(common.opensslCli, ['s_server',
+ '-accept', common.PORT,
+ '-cert', certfn,
+ '-key', keyfn]);
server.stdout.pipe(process.stdout);
server.stderr.pipe(process.stdout);
- var state = 'WAIT-ACCEPT';
+ let state = 'WAIT-ACCEPT';
- var serverStdoutBuffer = '';
+ let serverStdoutBuffer = '';
server.stdout.setEncoding('utf8');
server.stdout.on('data', function(s) {
serverStdoutBuffer += s;
@@ -86,13 +86,13 @@ function test(keyfn, certfn, check, next) {
});
- var timeout = setTimeout(function() {
+ const timeout = setTimeout(function() {
server.kill();
process.exit(1);
}, 5000);
- var gotWriteCallback = false;
- var serverExitCode = -1;
+ let gotWriteCallback = false;
+ let serverExitCode = -1;
server.on('exit', function(code) {
serverExitCode = code;
@@ -102,12 +102,12 @@ function test(keyfn, certfn, check, next) {
function startClient() {
- var s = new net.Stream();
+ const s = new net.Stream();
- var sslcontext = tls.createSecureContext({key: key, cert: cert});
+ const sslcontext = tls.createSecureContext({key: key, cert: cert});
sslcontext.context.setCiphers('RC4-SHA:AES128-SHA:AES256-SHA');
- var pair = tls.createSecurePair(sslcontext, false);
+ const pair = tls.createSecurePair(sslcontext, false);
assert.ok(pair.encrypted.writable);
assert.ok(pair.cleartext.writable);
diff --git a/test/pummel/test-tls-server-large-request.js b/test/pummel/test-tls-server-large-request.js
index 66d700ae4bc6a9..f79c4d95cfa031 100644
--- a/test/pummel/test-tls-server-large-request.js
+++ b/test/pummel/test-tls-server-large-request.js
@@ -1,20 +1,20 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
+const tls = require('tls');
-var fs = require('fs');
-var stream = require('stream');
-var util = require('util');
+const fs = require('fs');
+const stream = require('stream');
+const util = require('util');
-var request = Buffer.from(new Array(1024 * 256).join('ABCD')); // 1mb
+const request = Buffer.from(new Array(1024 * 256).join('ABCD')); // 1mb
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
@@ -35,14 +35,14 @@ Mediator.prototype._write = function _write(data, enc, cb) {
}
};
-var mediator = new Mediator();
+const mediator = new Mediator();
-var server = tls.Server(options, common.mustCall(function(socket) {
+let server = tls.Server(options, common.mustCall(function(socket) {
socket.pipe(mediator);
}));
server.listen(common.PORT, common.mustCall(function() {
- var client1 = tls.connect({
+ const client1 = tls.connect({
port: common.PORT,
rejectUnauthorized: false
}, common.mustCall(function() {
diff --git a/test/pummel/test-tls-session-timeout.js b/test/pummel/test-tls-session-timeout.js
index c23a8afcf7fe9a..c194188b3682a9 100644
--- a/test/pummel/test-tls-session-timeout.js
+++ b/test/pummel/test-tls-session-timeout.js
@@ -1,5 +1,5 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
if (!common.opensslCli) {
common.skip('node compiled without OpenSSL CLI.');
@@ -22,19 +22,19 @@ doTest();
// that we used has expired by now.
function doTest() {
- var assert = require('assert');
- var tls = require('tls');
- var fs = require('fs');
- var join = require('path').join;
- var spawn = require('child_process').spawn;
+ const assert = require('assert');
+ const tls = require('tls');
+ const fs = require('fs');
+ const join = require('path').join;
+ const spawn = require('child_process').spawn;
- var SESSION_TIMEOUT = 1;
+ const SESSION_TIMEOUT = 1;
- var keyFile = join(common.fixturesDir, 'agent.key');
- var certFile = join(common.fixturesDir, 'agent.crt');
- var key = fs.readFileSync(keyFile);
- var cert = fs.readFileSync(certFile);
- var options = {
+ const keyFile = join(common.fixturesDir, 'agent.key');
+ const certFile = join(common.fixturesDir, 'agent.crt');
+ const key = fs.readFileSync(keyFile);
+ const cert = fs.readFileSync(certFile);
+ const options = {
key: key,
cert: cert,
ca: [cert],
@@ -47,41 +47,41 @@ function doTest() {
// file containing a proper serialization of a session ticket.
// To avoid a source control diff, we copy the ticket to a temporary file.
- var sessionFileName = (function() {
- var ticketFileName = 'tls-session-ticket.txt';
- var fixturesPath = join(common.fixturesDir, ticketFileName);
- var tmpPath = join(common.tmpDir, ticketFileName);
+ const sessionFileName = (function() {
+ const ticketFileName = 'tls-session-ticket.txt';
+ const fixturesPath = join(common.fixturesDir, ticketFileName);
+ const tmpPath = join(common.tmpDir, ticketFileName);
fs.writeFileSync(tmpPath, fs.readFileSync(fixturesPath));
return tmpPath;
}());
// Expects a callback -- cb(connectionType : enum ['New'|'Reused'])
- var Client = function(cb) {
- var flags = [
+ const Client = function(cb) {
+ const flags = [
's_client',
'-connect', 'localhost:' + common.PORT,
'-sess_in', sessionFileName,
'-sess_out', sessionFileName
];
- var client = spawn(common.opensslCli, flags, {
+ const client = spawn(common.opensslCli, flags, {
stdio: ['ignore', 'pipe', 'ignore']
});
- var clientOutput = '';
+ let clientOutput = '';
client.stdout.on('data', function(data) {
clientOutput += data.toString();
});
client.on('exit', function(code) {
- var connectionType;
- var grepConnectionType = function(line) {
- var matches = line.match(/(New|Reused), /);
+ let connectionType;
+ const grepConnectionType = function(line) {
+ const matches = line.match(/(New|Reused), /);
if (matches) {
connectionType = matches[1];
return true;
}
};
- var lines = clientOutput.split('\n');
+ const lines = clientOutput.split('\n');
if (!lines.some(grepConnectionType)) {
throw new Error('unexpected output from openssl client');
}
@@ -89,7 +89,7 @@ function doTest() {
});
};
- var server = tls.createServer(options, function(cleartext) {
+ const server = tls.createServer(options, function(cleartext) {
cleartext.on('error', function(er) {
if (er.code !== 'ECONNRESET')
throw er;
diff --git a/test/pummel/test-tls-throttle.js b/test/pummel/test-tls-throttle.js
index a93793989f0b2b..939a9fc3b0fe8a 100644
--- a/test/pummel/test-tls-throttle.js
+++ b/test/pummel/test-tls-throttle.js
@@ -2,33 +2,33 @@
// Server sends a large string. Client counts bytes and pauses every few
// seconds. Makes sure that pause and resume work properly.
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
-var tls = require('tls');
-var fs = require('fs');
+const tls = require('tls');
+const fs = require('fs');
process.stdout.write('build body...');
-var body = 'hello world\n'.repeat(1024 * 1024);
+const body = 'hello world\n'.repeat(1024 * 1024);
process.stdout.write('done\n');
-var options = {
+const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem')
};
-var server = tls.Server(options, common.mustCall(function(socket) {
+const server = tls.Server(options, common.mustCall(function(socket) {
socket.end(body);
}));
-var recvCount = 0;
+let recvCount = 0;
server.listen(common.PORT, function() {
- var client = tls.connect({
+ const client = tls.connect({
port: common.PORT,
rejectUnauthorized: false
});
@@ -58,7 +58,7 @@ function displayCounts() {
}
-var timeout = setTimeout(displayCounts, 10 * 1000);
+let timeout = setTimeout(displayCounts, 10 * 1000);
process.on('exit', function() {
diff --git a/test/pummel/test-vm-memleak.js b/test/pummel/test-vm-memleak.js
index c6623991922da9..8503e2389b44a7 100644
--- a/test/pummel/test-vm-memleak.js
+++ b/test/pummel/test-vm-memleak.js
@@ -2,23 +2,23 @@
// Flags: --max_old_space_size=32
require('../common');
-var assert = require('assert');
+const assert = require('assert');
-var start = Date.now();
-var maxMem = 0;
+const start = Date.now();
+let maxMem = 0;
-var ok = process.execArgv.some(function(arg) {
+const ok = process.execArgv.some(function(arg) {
return arg === '--max_old_space_size=32';
});
assert(ok, 'Run this test with --max_old_space_size=32.');
-var interval = setInterval(function() {
+const interval = setInterval(function() {
try {
require('vm').runInNewContext('throw 1;');
} catch (e) {
}
- var rss = process.memoryUsage().rss;
+ const rss = process.memoryUsage().rss;
maxMem = Math.max(rss, maxMem);
if (Date.now() - start > 5 * 1000) {
@@ -30,7 +30,7 @@ var interval = setInterval(function() {
}, 1);
function testContextLeak() {
- for (var i = 0; i < 1000; i++)
+ for (let i = 0; i < 1000; i++)
require('vm').createContext({});
}
diff --git a/test/pummel/test-watch-file.js b/test/pummel/test-watch-file.js
index 8b79ef8ede4a63..90909875d74a15 100644
--- a/test/pummel/test-watch-file.js
+++ b/test/pummel/test-watch-file.js
@@ -1,9 +1,9 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var fs = require('fs');
-var path = require('path');
+const fs = require('fs');
+const path = require('path');
const f = path.join(common.fixturesDir, 'x.txt');
diff --git a/test/sequential/test-child-process-execsync.js b/test/sequential/test-child-process-execsync.js
index 137ddbda425f2c..20a35b98b36c6f 100644
--- a/test/sequential/test-child-process-execsync.js
+++ b/test/sequential/test-child-process-execsync.js
@@ -1,16 +1,16 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var execSync = require('child_process').execSync;
-var execFileSync = require('child_process').execFileSync;
+const execSync = require('child_process').execSync;
+const execFileSync = require('child_process').execFileSync;
-var TIMER = 200;
-var SLEEP = 2000;
+const TIMER = 200;
+const SLEEP = 2000;
-var start = Date.now();
-var err;
-var caught = false;
+const start = Date.now();
+let err;
+let caught = false;
// Verify that stderr is not accessed when a bad shell is used
assert.throws(
@@ -24,9 +24,10 @@ assert.throws(
'execFileSync did not throw the expected exception!'
);
+let cmd, ret;
try {
- var cmd = `"${process.execPath}" -e "setTimeout(function(){}, ${SLEEP});"`;
- var ret = execSync(cmd, {timeout: TIMER});
+ cmd = `"${process.execPath}" -e "setTimeout(function(){}, ${SLEEP});"`;
+ ret = execSync(cmd, {timeout: TIMER});
} catch (e) {
caught = true;
assert.strictEqual(e.errno, 'ETIMEDOUT');
@@ -34,7 +35,7 @@ try {
} finally {
assert.strictEqual(ret, undefined, 'we should not have a return value');
assert.strictEqual(caught, true, 'execSync should throw');
- var end = Date.now() - start;
+ const end = Date.now() - start;
assert(end < SLEEP);
assert(err.status > 128 || err.signal);
}
@@ -43,8 +44,8 @@ assert.throws(function() {
execSync('iamabadcommand');
}, /Command failed: iamabadcommand/);
-var msg = 'foobar';
-var msgBuf = Buffer.from(msg + '\n');
+const msg = 'foobar';
+const msgBuf = Buffer.from(msg + '\n');
// console.log ends every line with just '\n', even on Windows.
@@ -59,7 +60,7 @@ ret = execSync(cmd, { encoding: 'utf8' });
assert.strictEqual(ret, msg + '\n', 'execSync encoding result should match');
-var args = [
+const args = [
'-e',
`console.log("${msg}");`
];
diff --git a/test/sequential/test-debugger-debug-brk.js b/test/sequential/test-debugger-debug-brk.js
index 3b54f853bc8de3..26c3418171e8df 100644
--- a/test/sequential/test-debugger-debug-brk.js
+++ b/test/sequential/test-debugger-debug-brk.js
@@ -1,16 +1,16 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
+const common = require('../common');
+const assert = require('assert');
+const spawn = require('child_process').spawn;
-var script = common.fixturesDir + '/empty.js';
+const script = common.fixturesDir + '/empty.js';
function fail() {
assert(0); // `node --debug-brk script.js` should not quit
}
function test(arg) {
- var child = spawn(process.execPath, [arg, script]);
+ const child = spawn(process.execPath, [arg, script]);
child.on('exit', fail);
// give node time to start up the debugger
diff --git a/test/sequential/test-deprecation-flags.js b/test/sequential/test-deprecation-flags.js
index e9f5ee673d23bd..eb5c1a3ae6261f 100644
--- a/test/sequential/test-deprecation-flags.js
+++ b/test/sequential/test-deprecation-flags.js
@@ -38,7 +38,7 @@ execFile(node, traceDep, function(er, stdout, stderr) {
console.error('--trace-deprecation: show stack');
assert.equal(er, null);
assert.equal(stdout, '');
- var stack = stderr.trim().split('\n');
+ const stack = stderr.trim().split('\n');
// just check the top and bottom.
assert(/util.debug is deprecated. Use console.error instead./.test(stack[1]));
assert(/DEBUG: This is deprecated/.test(stack[0]));
diff --git a/test/sequential/test-fs-readfile-tostring-fail.js b/test/sequential/test-fs-readfile-tostring-fail.js
index 8ed9658a25889a..593b8da0fd8afa 100644
--- a/test/sequential/test-fs-readfile-tostring-fail.js
+++ b/test/sequential/test-fs-readfile-tostring-fail.js
@@ -23,7 +23,7 @@ const stream = fs.createWriteStream(file, {
const size = kStringMaxLength / 200;
const a = Buffer.alloc(size, 'a');
-for (var i = 0; i < 201; i++) {
+for (let i = 0; i < 201; i++) {
stream.write(a);
}
diff --git a/test/sequential/test-http-regr-gh-2928.js b/test/sequential/test-http-regr-gh-2928.js
index b4ae7054d72bb9..190966083e3f97 100644
--- a/test/sequential/test-http-regr-gh-2928.js
+++ b/test/sequential/test-http-regr-gh-2928.js
@@ -11,11 +11,11 @@ const net = require('net');
const COUNT = httpCommon.parsers.max + 1;
const parsers = new Array(COUNT);
-for (var i = 0; i < parsers.length; i++)
+for (let i = 0; i < parsers.length; i++)
parsers[i] = httpCommon.parsers.alloc();
-var gotRequests = 0;
-var gotResponses = 0;
+let gotRequests = 0;
+let gotResponses = 0;
function execAndClose() {
if (parsers.length === 0)
@@ -50,7 +50,7 @@ function execAndClose() {
};
}
-var server = net.createServer(function(c) {
+const server = net.createServer(function(c) {
if (++gotRequests === COUNT)
server.close();
c.end('HTTP/1.1 200 OK\r\n\r\n', function() {
diff --git a/test/sequential/test-module-loading.js b/test/sequential/test-module-loading.js
index 5e9c6e1bd4b787..5a4332b471c5ee 100644
--- a/test/sequential/test-module-loading.js
+++ b/test/sequential/test-module-loading.js
@@ -1,8 +1,8 @@
'use strict';
require('../common');
-var assert = require('assert');
-var path = require('path');
-var fs = require('fs');
+const assert = require('assert');
+const path = require('path');
+const fs = require('fs');
console.error('load test-module-loading.js');
@@ -15,21 +15,21 @@ assert.strictEqual(process.mainModule, module,
require('../fixtures/not-main-module.js');
// require a file with a request that includes the extension
-var a_js = require('../fixtures/a.js');
+const a_js = require('../fixtures/a.js');
assert.strictEqual(42, a_js.number);
// require a file without any extensions
-var foo_no_ext = require('../fixtures/foo');
+const foo_no_ext = require('../fixtures/foo');
assert.strictEqual('ok', foo_no_ext.foo);
-var a = require('../fixtures/a');
-var c = require('../fixtures/b/c');
-var d = require('../fixtures/b/d');
-var d2 = require('../fixtures/b/d');
+const a = require('../fixtures/a');
+const c = require('../fixtures/b/c');
+const d = require('../fixtures/b/d');
+const d2 = require('../fixtures/b/d');
// Absolute
-var d3 = require(path.join(__dirname, '../fixtures/b/d'));
+const d3 = require(path.join(__dirname, '../fixtures/b/d'));
// Relative
-var d4 = require('../fixtures/b/d');
+const d4 = require('../fixtures/b/d');
assert.strictEqual(false, false, 'testing the test program.');
@@ -94,13 +94,13 @@ require('../fixtures/node_modules/foo');
console.error('test name clashes');
// this one exists and should import the local module
-var my_path = require('../fixtures/path');
+const my_path = require('../fixtures/path');
assert.ok(my_path.path_func instanceof Function);
// this one does not exist and should throw
assert.throws(function() { require('./utils'); },
/^Error: Cannot find module '.\/utils'$/);
-var errorThrown = false;
+let errorThrown = false;
try {
require('../fixtures/throws_error');
} catch (e) {
@@ -112,7 +112,7 @@ assert.strictEqual(require('path').dirname(__filename), __dirname);
console.error('load custom file types with extensions');
require.extensions['.test'] = function(module, filename) {
- var content = fs.readFileSync(filename).toString();
+ let content = fs.readFileSync(filename).toString();
assert.strictEqual('this is custom source\n', content);
content = content.replace('this is custom source',
'exports.test = \'passed\'');
@@ -174,13 +174,13 @@ assert.strictEqual(require(loadOrder + 'file9').file9, 'file9/index.reg2', msg);
// make sure that module.require() is the same as
// doing require() inside of that module.
-var parent = require('../fixtures/module-require/parent/');
-var child = require('../fixtures/module-require/child/');
+const parent = require('../fixtures/module-require/parent/');
+const child = require('../fixtures/module-require/child/');
assert.strictEqual(child.loaded, parent.loaded);
// #1357 Loading JSON files with require()
-var json = require('../fixtures/packages/main/package.json');
+const json = require('../fixtures/packages/main/package.json');
assert.deepStrictEqual(json, {
name: 'package-name',
version: '1.2.3',
@@ -192,8 +192,8 @@ assert.deepStrictEqual(json, {
// modules that we've required, and that all of them contain
// the appropriate children, and so on.
-var children = module.children.reduce(function red(set, child) {
- var id = path.relative(path.dirname(__dirname), child.id);
+const children = module.children.reduce(function red(set, child) {
+ let id = path.relative(path.dirname(__dirname), child.id);
id = id.replace(/\\/g, '/');
set[id] = child.children.reduce(red, {});
return set;
diff --git a/test/sequential/test-net-GH-5504.js b/test/sequential/test-net-GH-5504.js
index 3ebf9db548d4db..a7f64c2e73da10 100644
--- a/test/sequential/test-net-GH-5504.js
+++ b/test/sequential/test-net-GH-5504.js
@@ -1,5 +1,5 @@
'use strict';
-var common = require('../common');
+const common = require('../common');
// this test only fails with CentOS 6.3 using kernel version 2.6.32
// On other linuxes and darwin, the `read` call gets an ECONNRESET in
@@ -18,8 +18,8 @@ switch (process.argv[2]) {
}
function server() {
- var net = require('net');
- var content = Buffer.alloc(64 * 1024 * 1024, '#');
+ const net = require('net');
+ const content = Buffer.alloc(64 * 1024 * 1024, '#');
net.createServer(function(socket) {
this.close();
socket.on('end', function() {
@@ -35,8 +35,8 @@ function server() {
}
function client() {
- var net = require('net');
- var client = net.connect({
+ const net = require('net');
+ const client = net.connect({
host: common.localhostIPv4,
port: common.PORT
}, function() {
@@ -45,15 +45,15 @@ function client() {
}
function parent() {
- var spawn = require('child_process').spawn;
- var node = process.execPath;
+ const spawn = require('child_process').spawn;
+ const node = process.execPath;
- var s = spawn(node, [__filename, 'server'], {
+ const s = spawn(node, [__filename, 'server'], {
env: Object.assign(process.env, {
NODE_DEBUG: 'net'
})
});
- var c;
+ let c;
wrap(s.stderr, process.stderr, 'SERVER 2>');
wrap(s.stdout, process.stdout, 'SERVER 1>');
diff --git a/test/sequential/test-regress-GH-1697.js b/test/sequential/test-regress-GH-1697.js
index 1511cfd1cfcf6b..d99acf9e468bb3 100644
--- a/test/sequential/test-regress-GH-1697.js
+++ b/test/sequential/test-regress-GH-1697.js
@@ -6,7 +6,7 @@ const cp = require('child_process');
if (process.argv[2] === 'server') {
// Server
- var server = net.createServer(function(conn) {
+ const server = net.createServer(function(conn) {
conn.on('data', function(data) {
console.log('server received ' + data.length + ' bytes');
});
@@ -23,22 +23,22 @@ if (process.argv[2] === 'server') {
} else {
// Client
- var serverProcess = cp.spawn(process.execPath, [process.argv[1], 'server']);
+ const serverProcess = cp.spawn(process.execPath, [process.argv[1], 'server']);
serverProcess.stdout.pipe(process.stdout);
serverProcess.stderr.pipe(process.stdout);
serverProcess.stdout.once('data', function() {
- var client = net.createConnection(common.PORT, '127.0.0.1');
+ const client = net.createConnection(common.PORT, '127.0.0.1');
client.on('connect', function() {
const alot = Buffer.allocUnsafe(1024);
const alittle = Buffer.allocUnsafe(1);
- for (var i = 0; i < 100; i++) {
+ for (let i = 0; i < 100; i++) {
client.write(alot);
}
// Block the event loop for 1 second
- var start = (new Date()).getTime();
+ const start = (new Date()).getTime();
while ((new Date()).getTime() < start + 1000) {}
client.write(alittle);
diff --git a/test/sequential/test-regress-GH-1726.js b/test/sequential/test-regress-GH-1726.js
index c5f0bba1335264..c464193b23f3e4 100644
--- a/test/sequential/test-regress-GH-1726.js
+++ b/test/sequential/test-regress-GH-1726.js
@@ -5,11 +5,11 @@
// https://github.com/joyent/node/issues/1726
require('../common');
-var assert = require('assert');
-var ch = require('child_process');
+const assert = require('assert');
+const ch = require('child_process');
-var gen = +(process.argv[2] || 0);
-var maxGen = 5;
+const gen = +(process.argv[2] || 0);
+const maxGen = 5;
if (gen === maxGen) {
@@ -17,7 +17,7 @@ if (gen === maxGen) {
return;
}
-var child = ch.spawn(process.execPath, [__filename, gen + 1], {
+const child = ch.spawn(process.execPath, [__filename, gen + 1], {
stdio: [ 'ignore', 'pipe', 'ignore' ]
});
assert.ok(!child.stdin);
diff --git a/test/sequential/test-regress-GH-4015.js b/test/sequential/test-regress-GH-4015.js
index 7f0e03f9ac08e1..249817de1d2068 100644
--- a/test/sequential/test-regress-GH-4015.js
+++ b/test/sequential/test-regress-GH-4015.js
@@ -1,10 +1,10 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var exec = require('child_process').exec;
+const common = require('../common');
+const assert = require('assert');
+const exec = require('child_process').exec;
-var cmd = '"' + process.execPath + '" ' +
- '"' + common.fixturesDir + '/test-regress-GH-4015.js"';
+const cmd = '"' + process.execPath + '" ' +
+ '"' + common.fixturesDir + '/test-regress-GH-4015.js"';
exec(cmd, function(err, stdout, stderr) {
assert(/RangeError: Maximum call stack size exceeded/.test(stderr));
diff --git a/test/sequential/test-regress-GH-4027.js b/test/sequential/test-regress-GH-4027.js
index aa1ec12c30f609..87a8861ac35477 100644
--- a/test/sequential/test-regress-GH-4027.js
+++ b/test/sequential/test-regress-GH-4027.js
@@ -1,12 +1,12 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var path = require('path');
-var fs = require('fs');
+const common = require('../common');
+const assert = require('assert');
+const path = require('path');
+const fs = require('fs');
common.refreshTmpDir();
-var filename = path.join(common.tmpDir, 'watched');
+const filename = path.join(common.tmpDir, 'watched');
fs.writeFileSync(filename, 'quis custodiet ipsos custodes');
setTimeout(fs.unlinkSync, 100, filename);
diff --git a/test/sequential/test-regress-GH-784.js b/test/sequential/test-regress-GH-784.js
index 0c70337de7f146..c9b630b0c81755 100644
--- a/test/sequential/test-regress-GH-784.js
+++ b/test/sequential/test-regress-GH-784.js
@@ -7,13 +7,13 @@
// The next two are made with server on - they should come back successful.
// The next two are made with the server off - and so on. Without the fix
// we were experiencing parse errors and instead of ECONNREFUSED.
-var common = require('../common');
-var http = require('http');
-var assert = require('assert');
+const common = require('../common');
+const http = require('http');
+const assert = require('assert');
-var server = http.createServer(function(req, res) {
- var body = '';
+const server = http.createServer(function(req, res) {
+ let body = '';
req.setEncoding('utf8');
req.on('data', function(chunk) {
@@ -43,7 +43,7 @@ function serverOff() {
pingping();
}
-var responses = [];
+const responses = [];
function afterPing(result) {
@@ -81,14 +81,14 @@ function afterPing(result) {
function ping() {
console.error('making req');
- var opt = {
+ const opt = {
port: common.PORT,
path: '/ping',
method: 'POST'
};
- var req = http.request(opt, function(res) {
- var body = '';
+ const req = http.request(opt, function(res) {
+ let body = '';
res.setEncoding('utf8');
res.on('data', function(chunk) {
@@ -105,8 +105,8 @@ function ping() {
req.end('PING');
- var gotEnd = false;
- var hadError = false;
+ let gotEnd = false;
+ let hadError = false;
req.on('error', function(error) {
console.log('Error making ping req: ' + error);
diff --git a/test/sequential/test-regress-GH-877.js b/test/sequential/test-regress-GH-877.js
index 5b0aac802e16a3..06c839aa483fa8 100644
--- a/test/sequential/test-regress-GH-877.js
+++ b/test/sequential/test-regress-GH-877.js
@@ -1,30 +1,30 @@
'use strict';
-var common = require('../common');
-var http = require('http');
-var assert = require('assert');
+const common = require('../common');
+const http = require('http');
+const assert = require('assert');
-var N = 20;
-var responses = 0;
-var maxQueued = 0;
+const N = 20;
+let responses = 0;
+let maxQueued = 0;
-var agent = http.globalAgent;
+const agent = http.globalAgent;
agent.maxSockets = 10;
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
res.writeHead(200);
res.end('Hello World\n');
});
-var addrString = agent.getName({ host: '127.0.0.1', port: common.PORT });
+const addrString = agent.getName({ host: '127.0.0.1', port: common.PORT });
server.listen(common.PORT, '127.0.0.1', function() {
- for (var i = 0; i < N; i++) {
- var options = {
+ for (let i = 0; i < N; i++) {
+ const options = {
host: '127.0.0.1',
port: common.PORT
};
- var req = http.get(options, function(res) {
+ const req = http.get(options, function(res) {
if (++responses === N) {
server.close();
}
@@ -37,7 +37,7 @@ server.listen(common.PORT, '127.0.0.1', function() {
agent.maxSockets + ' queued: ' + (agent.requests[addrString] ?
agent.requests[addrString].length : 0));
- var agentRequests = agent.requests[addrString] ?
+ const agentRequests = agent.requests[addrString] ?
agent.requests[addrString].length : 0;
if (maxQueued < agentRequests) {
diff --git a/test/sequential/test-repl-timeout-throw.js b/test/sequential/test-repl-timeout-throw.js
index 0188b3b8c502d8..fbe593230cf1ba 100644
--- a/test/sequential/test-repl-timeout-throw.js
+++ b/test/sequential/test-repl-timeout-throw.js
@@ -8,7 +8,7 @@ const child = spawn(process.execPath, [ '-i' ], {
stdio: [null, null, 2]
});
-var stdout = '';
+let stdout = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(c) {
process.stdout.write(c);
@@ -30,7 +30,7 @@ child.stdout.once('data', function() {
setTimeout(fsTest, 50);
function fsTest() {
- var f = JSON.stringify(__filename);
+ const f = JSON.stringify(__filename);
child.stdin.write('fs.readFile(' + f + ', thrower);\n');
setTimeout(eeTest, 50);
}
@@ -54,6 +54,6 @@ child.stdout.once('data', function() {
child.on('close', function(c) {
assert.strictEqual(c, 0);
// make sure we got 3 throws, in the end.
- var lastLine = stdout.trim().split(/\r?\n/).pop();
+ const lastLine = stdout.trim().split(/\r?\n/).pop();
assert.strictEqual(lastLine, '> 3');
});
diff --git a/test/sequential/test-require-cache-without-stat.js b/test/sequential/test-require-cache-without-stat.js
index 2571583f7690b5..b591f1746b62d4 100644
--- a/test/sequential/test-require-cache-without-stat.js
+++ b/test/sequential/test-require-cache-without-stat.js
@@ -2,17 +2,17 @@
// We've experienced a regression where the module loader stats a bunch of
// directories on require() even if it's been called before. The require()
// should caching the request.
-var common = require('../common');
-var fs = require('fs');
-var assert = require('assert');
+const common = require('../common');
+const fs = require('fs');
+const assert = require('assert');
-var counter = 0;
+let counter = 0;
// Switch out the two stat implementations so that they increase a counter
// each time they are called.
-var _statSync = fs.statSync;
-var _stat = fs.stat;
+const _statSync = fs.statSync;
+const _stat = fs.stat;
fs.statSync = function() {
counter++;
@@ -31,7 +31,7 @@ require('./../fixtures/a.js');
require('http');
console.log('counterBefore = %d', counter);
-var counterBefore = counter;
+const counterBefore = counter;
// Now load the module a bunch of times with equivalent paths.
// stat should not be called.
@@ -47,6 +47,6 @@ for (let i = 0; i < 100; i++) {
}
console.log('counterAfter = %d', counter);
-var counterAfter = counter;
+const counterAfter = counter;
assert.equal(counterBefore, counterAfter);
diff --git a/test/sequential/test-stream2-fs.js b/test/sequential/test-stream2-fs.js
index 7baba6e63b81b0..2891335c813562 100644
--- a/test/sequential/test-stream2-fs.js
+++ b/test/sequential/test-stream2-fs.js
@@ -1,19 +1,19 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var fs = require('fs');
-var FSReadable = fs.ReadStream;
+const fs = require('fs');
+const FSReadable = fs.ReadStream;
-var path = require('path');
-var file = path.resolve(common.fixturesDir, 'x1024.txt');
+const path = require('path');
+const file = path.resolve(common.fixturesDir, 'x1024.txt');
-var size = fs.statSync(file).size;
+const size = fs.statSync(file).size;
-var expectLengths = [1024];
+const expectLengths = [1024];
-var util = require('util');
-var Stream = require('stream');
+const util = require('util');
+const Stream = require('stream');
util.inherits(TestWriter, Stream);
@@ -34,8 +34,8 @@ TestWriter.prototype.end = function(c) {
this.emit('results', this.buffer);
};
-var r = new FSReadable(file);
-var w = new TestWriter();
+const r = new FSReadable(file);
+const w = new TestWriter();
w.on('results', function(res) {
console.error(res, w.length);
diff --git a/test/sequential/test-stream2-stderr-sync.js b/test/sequential/test-stream2-stderr-sync.js
index c7daaa6b083205..0b86790d62058d 100644
--- a/test/sequential/test-stream2-stderr-sync.js
+++ b/test/sequential/test-stream2-stderr-sync.js
@@ -4,12 +4,12 @@
require('../common');
function parent() {
- var spawn = require('child_process').spawn;
- var assert = require('assert');
- var i = 0;
+ const spawn = require('child_process').spawn;
+ const assert = require('assert');
+ let i = 0;
children.forEach(function(_, c) {
- var child = spawn(process.execPath, [__filename, '' + c]);
- var err = '';
+ const child = spawn(process.execPath, [__filename, '' + c]);
+ let err = '';
child.stderr.on('data', function(c) {
err += c;
@@ -42,8 +42,8 @@ function child1() {
// using a net socket
function child2() {
- var net = require('net');
- var socket = new net.Socket({
+ const net = require('net');
+ const socket = new net.Socket({
fd: 2,
readable: false,
writable: true});
@@ -62,7 +62,7 @@ function child4() {
process.stderr.write('child 4\nfoo\nbar\nbaz\n');
}
-var children = [ child0, child1, child2, child3, child4 ];
+let children = [ child0, child1, child2, child3, child4 ];
if (!process.argv[2]) {
parent();
diff --git a/test/sequential/test-timers-blocking-callback.js b/test/sequential/test-timers-blocking-callback.js
index e4e85cddc6302d..73b0f13997716d 100644
--- a/test/sequential/test-timers-blocking-callback.js
+++ b/test/sequential/test-timers-blocking-callback.js
@@ -28,9 +28,9 @@ const Timer = process.binding('timer_wrap').Timer;
const TIMEOUT = 100;
-var nbBlockingCallbackCalls = 0;
-var latestDelay = 0;
-var timeCallbackScheduled = 0;
+let nbBlockingCallbackCalls = 0;
+let latestDelay = 0;
+let timeCallbackScheduled = 0;
function initTest() {
nbBlockingCallbackCalls = 0;
diff --git a/test/sequential/test-util-debug.js b/test/sequential/test-util-debug.js
index 1159278efa475d..515f6e32692c5b 100644
--- a/test/sequential/test-util-debug.js
+++ b/test/sequential/test-util-debug.js
@@ -1,6 +1,6 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
+const assert = require('assert');
if (process.argv[2] === 'child')
child();
@@ -17,27 +17,27 @@ function parent() {
}
function test(environ, shouldWrite) {
- var expectErr = '';
+ let expectErr = '';
if (shouldWrite) {
expectErr = 'TUD %PID%: this { is: \'a\' } /debugging/\n' +
'TUD %PID%: number=1234 string=asdf obj={"foo":"bar"}\n';
}
- var expectOut = 'ok\n';
+ const expectOut = 'ok\n';
- var spawn = require('child_process').spawn;
- var child = spawn(process.execPath, [__filename, 'child'], {
+ const spawn = require('child_process').spawn;
+ const child = spawn(process.execPath, [__filename, 'child'], {
env: Object.assign(process.env, { NODE_DEBUG: environ })
});
expectErr = expectErr.split('%PID%').join(child.pid);
- var err = '';
+ let err = '';
child.stderr.setEncoding('utf8');
child.stderr.on('data', function(c) {
err += c;
});
- var out = '';
+ let out = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(c) {
out += c;
@@ -53,8 +53,8 @@ function test(environ, shouldWrite) {
function child() {
- var util = require('util');
- var debug = util.debuglog('tud');
+ const util = require('util');
+ const debug = util.debuglog('tud');
debug('this', { is: 'a' }, /debugging/);
debug('number=%d string=%s obj=%j', 1234, 'asdf', { foo: 'bar' });
console.log('ok');
diff --git a/test/sequential/test-vm-timeout-rethrow.js b/test/sequential/test-vm-timeout-rethrow.js
index 7e148bd4d0b94f..54ffee1ff976f5 100644
--- a/test/sequential/test-vm-timeout-rethrow.js
+++ b/test/sequential/test-vm-timeout-rethrow.js
@@ -1,8 +1,8 @@
'use strict';
require('../common');
-var assert = require('assert');
-var vm = require('vm');
-var spawn = require('child_process').spawn;
+const assert = require('assert');
+const vm = require('vm');
+const spawn = require('child_process').spawn;
if (process.argv[2] === 'child') {
const code = 'while(true);';
@@ -11,8 +11,8 @@ if (process.argv[2] === 'child') {
vm.runInContext(code, ctx, { timeout: 1 });
} else {
- var proc = spawn(process.execPath, process.argv.slice(1).concat('child'));
- var err = '';
+ const proc = spawn(process.execPath, process.argv.slice(1).concat('child'));
+ let err = '';
proc.stderr.on('data', function(data) {
err += data;
});
diff --git a/test/timers/test-timers-reliability.js b/test/timers/test-timers-reliability.js
index 0626c45826781b..9a9834aefecc7f 100644
--- a/test/timers/test-timers-reliability.js
+++ b/test/timers/test-timers-reliability.js
@@ -3,11 +3,11 @@
require('../common');
-var Timer = process.binding('timer_wrap').Timer;
-var assert = require('assert');
+const Timer = process.binding('timer_wrap').Timer;
+const assert = require('assert');
-var timerFired = false;
-var intervalFired = false;
+let timerFired = false;
+let intervalFired = false;
/*
* This test case aims at making sure that timing utilities such
@@ -31,7 +31,7 @@ var intervalFired = false;
* is vulnerable to time drift or inconsistent time changes.
*/
-var monoTimer = new Timer();
+const monoTimer = new Timer();
monoTimer[Timer.kOnTimeout] = function() {
/*
* Make sure that setTimeout's and setInterval's callbacks have
@@ -48,7 +48,7 @@ setTimeout(function() {
timerFired = true;
}, 200);
-var interval = setInterval(function() {
+const interval = setInterval(function() {
intervalFired = true;
clearInterval(interval);
}, 200);