Skip to content

Commit 3488fa8

Browse files
Trottrvagg
authored andcommitted
test: fix variable redeclarations
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 <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 7dc0905 commit 3488fa8

9 files changed

+31
-32
lines changed

test/parallel/test-process-env.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ if (process.argv[2] == 'you-are-the-child') {
3131
assert.equal(42, process.env.NODE_PROCESS_ENV);
3232
assert.equal('asdf', process.env.hasOwnProperty);
3333
var hasOwnProperty = Object.prototype.hasOwnProperty;
34-
var has = hasOwnProperty.call(process.env, 'hasOwnProperty');
34+
const has = hasOwnProperty.call(process.env, 'hasOwnProperty');
3535
assert.equal(true, has);
3636
process.exit(0);
3737
} else {
3838
assert.equal(Object.prototype.hasOwnProperty, process.env.hasOwnProperty);
39-
var has = process.env.hasOwnProperty('hasOwnProperty');
39+
const has = process.env.hasOwnProperty('hasOwnProperty');
4040
assert.equal(false, has);
4141

4242
process.env.hasOwnProperty = 'asdf';

test/parallel/test-querystring.js

+20-17
Original file line numberDiff line numberDiff line change
@@ -148,29 +148,32 @@ assert.strictEqual('foo=', qs.stringify({ foo: NaN }));
148148
assert.strictEqual('foo=', qs.stringify({ foo: Infinity }));
149149

150150
// nested
151-
var f = qs.stringify({
152-
a: 'b',
153-
q: qs.stringify({
154-
x: 'y',
155-
y: 'z'
156-
})
157-
});
158-
assert.equal(f, 'a=b&q=x%3Dy%26y%3Dz');
151+
{
152+
const f = qs.stringify({
153+
a: 'b',
154+
q: qs.stringify({
155+
x: 'y',
156+
y: 'z'
157+
})
158+
});
159+
assert.equal(f, 'a=b&q=x%3Dy%26y%3Dz');
160+
}
159161

160162
assert.doesNotThrow(function() {
161163
qs.parse(undefined);
162164
});
163165

164166
// nested in colon
165-
var f = qs.stringify({
166-
a: 'b',
167-
q: qs.stringify({
168-
x: 'y',
169-
y: 'z'
170-
}, ';', ':')
171-
}, ';', ':');
172-
assert.equal(f, 'a:b;q:x%3Ay%3By%3Az');
173-
167+
{
168+
const f = qs.stringify({
169+
a: 'b',
170+
q: qs.stringify({
171+
x: 'y',
172+
y: 'z'
173+
}, ';', ':')
174+
}, ';', ':');
175+
assert.equal(f, 'a:b;q:x%3Ay%3By%3Az');
176+
}
174177

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

test/parallel/test-readline-interface.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ function isWarned(emitter) {
296296
rli.question(expectedLines.join('\n'), function() {
297297
rli.close();
298298
});
299-
var cursorPos = rli._getCursorPos();
299+
cursorPos = rli._getCursorPos();
300300
assert.equal(cursorPos.rows, expectedLines.length - 1);
301301
assert.equal(cursorPos.cols, expectedLines.slice(-1)[0].length);
302302
rli.close();

test/parallel/test-repl-persistent-history.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,7 @@ function runTest(assertCleaned) {
272272
});
273273

274274
function onClose() {
275-
if (after) {
276-
var cleaned = after();
277-
} else {
278-
var cleaned = cleanupTmpFile();
279-
}
275+
const cleaned = after ? after() : cleanupTmpFile();
280276

281277
try {
282278
// Ensure everything that we expected was output

test/parallel/test-stream2-push.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var EE = require('events').EventEmitter;
1010

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

13-
var stream = new Readable({
13+
stream = new Readable({
1414
highWaterMark: 16,
1515
encoding: 'utf8'
1616
});

test/parallel/test-string-decoder-end.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function testBuf(encoding, buf) {
4343

4444
// write the whole buffer at once.
4545
var res2 = '';
46-
var s = new SD(encoding);
46+
s = new SD(encoding);
4747
res2 += s.write(buf);
4848
res2 += s.end();
4949

test/parallel/test-stringbytes-external.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ write_str = Array(size).join(write_str);
2222
ucs2_control = Array(size).join(ucs2_control);
2323

2424
// check resultant buffer and output string
25-
var b = new Buffer(write_str, 'ucs2');
25+
b = new Buffer(write_str, 'ucs2');
2626
// check fist Buffer created from write string
27-
for (var i = 0; i < b.length; i += 2) {
27+
for (let i = 0; i < b.length; i += 2) {
2828
assert.equal(b[i], 0x61);
2929
assert.equal(b[i + 1], 0);
3030
}
@@ -39,7 +39,7 @@ var c_ucs = new Buffer(b_ucs, 'ucs2');
3939
// make sure they're the same length
4040
assert.equal(c_bin.length, c_ucs.length);
4141
// make sure Buffers from externals are the same
42-
for (var i = 0; i < c_bin.length; i++) {
42+
for (let i = 0; i < c_bin.length; i++) {
4343
assert.equal(c_bin[i], c_ucs[i]);
4444
}
4545
// check resultant strings

test/parallel/test-tls-cipher-list.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const defaultCoreList = require('constants').defaultCoreCipherList;
1212

1313
function doCheck(arg, check) {
1414
var out = '';
15-
var arg = arg.concat([
15+
arg = arg.concat([
1616
'-pe',
1717
'require("constants").defaultCipherList'
1818
]);

test/parallel/test-zlib.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var testFiles = ['person.jpg', 'elipses.txt', 'empty.txt'];
4242

4343
if (process.env.FAST) {
4444
zlibPairs = [[zlib.Gzip, zlib.Unzip]];
45-
var testFiles = ['person.jpg'];
45+
testFiles = ['person.jpg'];
4646
}
4747

4848
var tests = {};

0 commit comments

Comments
 (0)