Skip to content

Commit

Permalink
test: fix variable redeclarations
Browse files Browse the repository at this point in the history
I'm a fan of small changesets, but even I'm getting a little annoyed at
me for opening all these PRs weeding out variable redeclarations. So I'm
bundling a bunch of small changes here.

PR-URL: #4992
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and Myles Borins committed Feb 18, 2016
1 parent 58595f1 commit 88fae38
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 32 deletions.
4 changes: 2 additions & 2 deletions test/parallel/test-process-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ if (process.argv[2] == 'you-are-the-child') {
assert.equal(42, process.env.NODE_PROCESS_ENV);
assert.equal('asdf', process.env.hasOwnProperty);
var hasOwnProperty = Object.prototype.hasOwnProperty;
var has = hasOwnProperty.call(process.env, 'hasOwnProperty');
const has = hasOwnProperty.call(process.env, 'hasOwnProperty');
assert.equal(true, has);
process.exit(0);
} else {
assert.equal(Object.prototype.hasOwnProperty, process.env.hasOwnProperty);
var has = process.env.hasOwnProperty('hasOwnProperty');
const has = process.env.hasOwnProperty('hasOwnProperty');
assert.equal(false, has);

process.env.hasOwnProperty = 'asdf';
Expand Down
37 changes: 20 additions & 17 deletions test/parallel/test-querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,29 +148,32 @@ assert.strictEqual('foo=', qs.stringify({ foo: NaN }));
assert.strictEqual('foo=', qs.stringify({ foo: Infinity }));

// nested
var f = qs.stringify({
a: 'b',
q: qs.stringify({
x: 'y',
y: 'z'
})
});
assert.equal(f, 'a=b&q=x%3Dy%26y%3Dz');
{
const f = qs.stringify({
a: 'b',
q: qs.stringify({
x: 'y',
y: 'z'
})
});
assert.equal(f, 'a=b&q=x%3Dy%26y%3Dz');
}

assert.doesNotThrow(function() {
qs.parse(undefined);
});

// nested in colon
var f = qs.stringify({
a: 'b',
q: qs.stringify({
x: 'y',
y: 'z'
}, ';', ':')
}, ';', ':');
assert.equal(f, 'a:b;q:x%3Ay%3By%3Az');

{
const f = qs.stringify({
a: 'b',
q: qs.stringify({
x: 'y',
y: 'z'
}, ';', ':')
}, ';', ':');
assert.equal(f, 'a:b;q:x%3Ay%3By%3Az');
}

assert.deepEqual({}, qs.parse());

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-readline-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ function isWarned(emitter) {
rli.question(expectedLines.join('\n'), function() {
rli.close();
});
var cursorPos = rli._getCursorPos();
cursorPos = rli._getCursorPos();
assert.equal(cursorPos.rows, expectedLines.length - 1);
assert.equal(cursorPos.cols, expectedLines.slice(-1)[0].length);
rli.close();
Expand Down
6 changes: 1 addition & 5 deletions test/parallel/test-repl-persistent-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,7 @@ function runTest(assertCleaned) {
});

function onClose() {
if (after) {
var cleaned = after();
} else {
var cleaned = cleanupTmpFile();
}
const cleaned = after ? after() : cleanupTmpFile();

try {
// Ensure everything that we expected was output
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream2-push.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var EE = require('events').EventEmitter;

// a mock thing a bit like the net.Socket/tcp_wrap.handle interaction

var stream = new Readable({
stream = new Readable({
highWaterMark: 16,
encoding: 'utf8'
});
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-string-decoder-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function testBuf(encoding, buf) {

// write the whole buffer at once.
var res2 = '';
var s = new SD(encoding);
s = new SD(encoding);
res2 += s.write(buf);
res2 += s.end();

Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-stringbytes-external.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ write_str = Array(size).join(write_str);
ucs2_control = Array(size).join(ucs2_control);

// check resultant buffer and output string
var b = new Buffer(write_str, 'ucs2');
b = new Buffer(write_str, 'ucs2');
// check fist Buffer created from write string
for (var i = 0; i < b.length; i += 2) {
for (let i = 0; i < b.length; i += 2) {
assert.equal(b[i], 0x61);
assert.equal(b[i + 1], 0);
}
Expand All @@ -39,7 +39,7 @@ var c_ucs = new Buffer(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
for (var i = 0; i < c_bin.length; i++) {
for (let i = 0; i < c_bin.length; i++) {
assert.equal(c_bin[i], c_ucs[i]);
}
// check resultant strings
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-cipher-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const defaultCoreList = require('constants').defaultCoreCipherList;

function doCheck(arg, check) {
var out = '';
var arg = arg.concat([
arg = arg.concat([
'-pe',
'require("constants").defaultCipherList'
]);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var testFiles = ['person.jpg', 'elipses.txt', 'empty.txt'];

if (process.env.FAST) {
zlibPairs = [[zlib.Gzip, zlib.Unzip]];
var testFiles = ['person.jpg'];
testFiles = ['person.jpg'];
}

var tests = {};
Expand Down

0 comments on commit 88fae38

Please sign in to comment.