mirror of https://github.com/nodejs/node.git
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: https://github.com/nodejs/node/pull/4992 Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>pull/4992/merge
parent
415625c2a5
commit
8d61787f17
|
@ -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';
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
});
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
]);
|
||||
|
|
|
@ -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 = {};
|
||||
|
|
Loading…
Reference in New Issue