Skip to content

Commit

Permalink
test: use eslint to fix var->const/let
Browse files Browse the repository at this point in the history
Manually fix issues that eslint --fix couldn't do automatically.

Backport-PR-URL: #11775
PR-URL: #10685
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
  • Loading branch information
gibfahn authored and MylesBorins committed Apr 19, 2017
1 parent de63698 commit db61c95
Show file tree
Hide file tree
Showing 806 changed files with 5,037 additions and 5,001 deletions.
2 changes: 1 addition & 1 deletion test/addons/async-hello-world/test.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/addons/buffer-free-callback/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/addons/hello-world-function-export/test.js
Original file line number Diff line number Diff line change
@@ -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());
2 changes: 1 addition & 1 deletion test/addons/hello-world/test.js
Original file line number Diff line number Diff line change
@@ -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());
8 changes: 4 additions & 4 deletions test/addons/load-long-path/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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');
2 changes: 1 addition & 1 deletion test/addons/make-callback-recurse/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
Expand Down
24 changes: 12 additions & 12 deletions test/addons/repl-domain-abort/test.js
Original file line number Diff line number Diff line change
@@ -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()));
Expand All @@ -38,7 +38,7 @@ dOutput._write = function _write(chunk, encoding, cb) {
cb();
};

var options = {
const options = {
input: dInput,
output: dOutput,
terminal: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 16 additions & 16 deletions test/debugger/helper-debugger-repl.js
Original file line number Diff line number Diff line change
@@ -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 ||
Expand All @@ -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;
Expand All @@ -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();
}
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down
Loading

0 comments on commit db61c95

Please sign in to comment.