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>
This commit is contained in:
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(42, process.env.NODE_PROCESS_ENV);
|
||||||
assert.equal('asdf', process.env.hasOwnProperty);
|
assert.equal('asdf', process.env.hasOwnProperty);
|
||||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||||
var has = hasOwnProperty.call(process.env, 'hasOwnProperty');
|
const has = hasOwnProperty.call(process.env, 'hasOwnProperty');
|
||||||
assert.equal(true, has);
|
assert.equal(true, has);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} else {
|
} else {
|
||||||
assert.equal(Object.prototype.hasOwnProperty, process.env.hasOwnProperty);
|
assert.equal(Object.prototype.hasOwnProperty, process.env.hasOwnProperty);
|
||||||
var has = process.env.hasOwnProperty('hasOwnProperty');
|
const has = process.env.hasOwnProperty('hasOwnProperty');
|
||||||
assert.equal(false, has);
|
assert.equal(false, has);
|
||||||
|
|
||||||
process.env.hasOwnProperty = 'asdf';
|
process.env.hasOwnProperty = 'asdf';
|
||||||
|
@ -148,7 +148,8 @@ assert.strictEqual('foo=', qs.stringify({ foo: NaN }));
|
|||||||
assert.strictEqual('foo=', qs.stringify({ foo: Infinity }));
|
assert.strictEqual('foo=', qs.stringify({ foo: Infinity }));
|
||||||
|
|
||||||
// nested
|
// nested
|
||||||
var f = qs.stringify({
|
{
|
||||||
|
const f = qs.stringify({
|
||||||
a: 'b',
|
a: 'b',
|
||||||
q: qs.stringify({
|
q: qs.stringify({
|
||||||
x: 'y',
|
x: 'y',
|
||||||
@ -156,13 +157,15 @@ var f = qs.stringify({
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
assert.equal(f, 'a=b&q=x%3Dy%26y%3Dz');
|
assert.equal(f, 'a=b&q=x%3Dy%26y%3Dz');
|
||||||
|
}
|
||||||
|
|
||||||
assert.doesNotThrow(function() {
|
assert.doesNotThrow(function() {
|
||||||
qs.parse(undefined);
|
qs.parse(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
// nested in colon
|
// nested in colon
|
||||||
var f = qs.stringify({
|
{
|
||||||
|
const f = qs.stringify({
|
||||||
a: 'b',
|
a: 'b',
|
||||||
q: qs.stringify({
|
q: qs.stringify({
|
||||||
x: 'y',
|
x: 'y',
|
||||||
@ -170,7 +173,7 @@ var f = qs.stringify({
|
|||||||
}, ';', ':')
|
}, ';', ':')
|
||||||
}, ';', ':');
|
}, ';', ':');
|
||||||
assert.equal(f, 'a:b;q:x%3Ay%3By%3Az');
|
assert.equal(f, 'a:b;q:x%3Ay%3By%3Az');
|
||||||
|
}
|
||||||
|
|
||||||
assert.deepEqual({}, qs.parse());
|
assert.deepEqual({}, qs.parse());
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ function isWarned(emitter) {
|
|||||||
rli.question(expectedLines.join('\n'), function() {
|
rli.question(expectedLines.join('\n'), function() {
|
||||||
rli.close();
|
rli.close();
|
||||||
});
|
});
|
||||||
var cursorPos = rli._getCursorPos();
|
cursorPos = rli._getCursorPos();
|
||||||
assert.equal(cursorPos.rows, expectedLines.length - 1);
|
assert.equal(cursorPos.rows, expectedLines.length - 1);
|
||||||
assert.equal(cursorPos.cols, expectedLines.slice(-1)[0].length);
|
assert.equal(cursorPos.cols, expectedLines.slice(-1)[0].length);
|
||||||
rli.close();
|
rli.close();
|
||||||
|
@ -272,11 +272,7 @@ function runTest(assertCleaned) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function onClose() {
|
function onClose() {
|
||||||
if (after) {
|
const cleaned = after ? after() : cleanupTmpFile();
|
||||||
var cleaned = after();
|
|
||||||
} else {
|
|
||||||
var cleaned = cleanupTmpFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Ensure everything that we expected was output
|
// 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
|
// a mock thing a bit like the net.Socket/tcp_wrap.handle interaction
|
||||||
|
|
||||||
var stream = new Readable({
|
stream = new Readable({
|
||||||
highWaterMark: 16,
|
highWaterMark: 16,
|
||||||
encoding: 'utf8'
|
encoding: 'utf8'
|
||||||
});
|
});
|
||||||
|
@ -43,7 +43,7 @@ function testBuf(encoding, buf) {
|
|||||||
|
|
||||||
// write the whole buffer at once.
|
// write the whole buffer at once.
|
||||||
var res2 = '';
|
var res2 = '';
|
||||||
var s = new SD(encoding);
|
s = new SD(encoding);
|
||||||
res2 += s.write(buf);
|
res2 += s.write(buf);
|
||||||
res2 += s.end();
|
res2 += s.end();
|
||||||
|
|
||||||
|
@ -22,9 +22,9 @@ write_str = Array(size).join(write_str);
|
|||||||
ucs2_control = Array(size).join(ucs2_control);
|
ucs2_control = Array(size).join(ucs2_control);
|
||||||
|
|
||||||
// check resultant buffer and output string
|
// 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
|
// 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], 0x61);
|
||||||
assert.equal(b[i + 1], 0);
|
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
|
// make sure they're the same length
|
||||||
assert.equal(c_bin.length, c_ucs.length);
|
assert.equal(c_bin.length, c_ucs.length);
|
||||||
// make sure Buffers from externals are the same
|
// 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]);
|
assert.equal(c_bin[i], c_ucs[i]);
|
||||||
}
|
}
|
||||||
// check resultant strings
|
// check resultant strings
|
||||||
|
@ -12,7 +12,7 @@ const defaultCoreList = require('constants').defaultCoreCipherList;
|
|||||||
|
|
||||||
function doCheck(arg, check) {
|
function doCheck(arg, check) {
|
||||||
var out = '';
|
var out = '';
|
||||||
var arg = arg.concat([
|
arg = arg.concat([
|
||||||
'-pe',
|
'-pe',
|
||||||
'require("constants").defaultCipherList'
|
'require("constants").defaultCipherList'
|
||||||
]);
|
]);
|
||||||
|
@ -42,7 +42,7 @@ var testFiles = ['person.jpg', 'elipses.txt', 'empty.txt'];
|
|||||||
|
|
||||||
if (process.env.FAST) {
|
if (process.env.FAST) {
|
||||||
zlibPairs = [[zlib.Gzip, zlib.Unzip]];
|
zlibPairs = [[zlib.Gzip, zlib.Unzip]];
|
||||||
var testFiles = ['person.jpg'];
|
testFiles = ['person.jpg'];
|
||||||
}
|
}
|
||||||
|
|
||||||
var tests = {};
|
var tests = {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user