Skip to content

Commit

Permalink
test,lib: align arguments in multiline calls
Browse files Browse the repository at this point in the history
An upcoming custom lint rule will provide slightly more strict
enforcement of argument alignment for multiline function calls. Adjust
existing code to conform.

PR-URL: #8642
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
  • Loading branch information
Trott authored and Fishrock123 committed Oct 11, 2016
1 parent 38be155 commit 4492cc3
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 132 deletions.
2 changes: 1 addition & 1 deletion lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ REPLServer.prototype.createContext = function() {
return GLOBAL_OBJECT_PROPERTY_MAP[name] === undefined;
}).forEach((name) => {
Object.defineProperty(context, name,
Object.getOwnPropertyDescriptor(global, name));
Object.getOwnPropertyDescriptor(global, name));
});
}

Expand Down
10 changes: 4 additions & 6 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ assert.doesNotThrow(makeBlock(a.ok, true),
assert.doesNotThrow(makeBlock(a.ok, 'test'), 'ok(\'test\')');

assert.throws(makeBlock(a.equal, true, false),
a.AssertionError, 'equal(true, false)');
a.AssertionError, 'equal(true, false)');

assert.doesNotThrow(makeBlock(a.equal, null, null),
'equal(null, null)');
Expand Down Expand Up @@ -71,10 +71,8 @@ assert.throws(makeBlock(a.deepEqual, new Date(), new Date(2000, 3, 14)),
a.AssertionError,
'deepEqual(new Date(), new Date(2000, 3, 14))');

assert.throws(makeBlock(
a.notDeepEqual,
new Date(2000, 3, 14),
new Date(2000, 3, 14)),
assert.throws(
makeBlock(a.notDeepEqual, new Date(2000, 3, 14), new Date(2000, 3, 14)),
a.AssertionError,
'notDeepEqual(new Date(2000, 3, 14), new Date(2000, 3, 14))'
);
Expand Down Expand Up @@ -465,7 +463,7 @@ function testAssertionMessage(actual, expected) {
assert.equal(actual, '');
} catch (e) {
assert.equal(e.toString(),
['AssertionError:', expected, '==', '\'\''].join(' '));
['AssertionError:', expected, '==', '\'\''].join(' '));
assert.ok(e.generatedMessage, 'Message not marked as generated');
}
}
Expand Down
5 changes: 3 additions & 2 deletions test/parallel/test-buffer-alloc.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ assert.doesNotThrow(() => Buffer.alloc(1).write('', 1, 0));
{
// Length should be 12
const f = Buffer.from('привет', encoding);
assert.deepStrictEqual(f,
Buffer.from([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4]));
assert.deepStrictEqual(
f, Buffer.from([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4])
);
assert.strictEqual(f.toString(encoding), 'привет');
}

Expand Down
5 changes: 3 additions & 2 deletions test/parallel/test-buffer-bytelength.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ assert.strictEqual(Buffer.byteLength('ßœ∑≈', 'unkn0wn enc0ding'), 10);
assert.strictEqual(Buffer.byteLength('aGVsbG8gd29ybGQ=', 'base64'), 11);
assert.strictEqual(Buffer.byteLength('bm9kZS5qcyByb2NrcyE=', 'base64'), 14);
assert.strictEqual(Buffer.byteLength('aGkk', 'base64'), 3);
assert.strictEqual(Buffer.byteLength('bHNrZGZsa3NqZmtsc2xrZmFqc2RsZmtqcw==',
'base64'), 25);
assert.strictEqual(
Buffer.byteLength('bHNrZGZsa3NqZmtsc2xrZmFqc2RsZmtqcw==', 'base64'), 25
);
// special padding
assert.strictEqual(Buffer.byteLength('aaa=', 'base64'), 2);
assert.strictEqual(Buffer.byteLength('aaaa==', 'base64'), 3);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-inheritance.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ vals.forEach(function(t) {
assert.strictEqual(t.constructor, T);
assert.strictEqual(Object.getPrototypeOf(t), T.prototype);
assert.strictEqual(Object.getPrototypeOf(Object.getPrototypeOf(t)),
Buffer.prototype);
Buffer.prototype);

t.fill(5);
let cntr = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-debugger-util-regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ proc.stdin.on('error', (err) => {
process.on('exit', (code) => {
assert.equal(code, 0, 'the program should exit cleanly');
assert.equal(stdout.includes('{ a: \'b\' }'), true,
'the debugger should print the result of util.inspect');
'the debugger should print the result of util.inspect');
assert.equal(stderr, '', 'stderr should be empty');
});
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ function runTestWithoutAbortOnUncaughtException() {
// message must include only the message of the error thrown from the
// process' uncaughtException handler.
assert(stderr.includes(uncaughtExceptionHandlerErrMsg),
'stderr output must include proper uncaughtException handler\'s ' +
'error\'s message');
'stderr output must include proper uncaughtException ' +
'handler\'s error\'s message');
assert(!stderr.includes(domainErrMsg), 'stderr output must not ' +
'include domain\'s error\'s message');

Expand All @@ -75,7 +75,7 @@ function runTestWithAbortOnUncaughtException() {
'child process should not have run its uncaughtException ' +
'event handler');
assert(common.nodeProcessAborted(err.code, err.signal),
'process should have aborted, but did not');
'process should have aborted, but did not');
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ if (process.argv[2] === 'child') {
if (!options.useTryCatch && options.throwInDomainErrHandler) {
if (cmdLineOption === '--abort_on_uncaught_exception') {
assert(common.nodeProcessAborted(exitCode, signal),
'process should have aborted, but did not');
'process should have aborted, but did not');
} else {
// By default, uncaught exceptions make node exit with an exit
// code of 7.
Expand Down
36 changes: 18 additions & 18 deletions test/parallel/test-fs-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {


fs.open(fn2, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0o644,
common.mustCall(function(err, fd) {
if (err) throw err;
console.log('open done');
fs.write(fd, '', 0, 'utf8', function(err, written) {
assert.equal(0, written);
});
fs.write(fd, expected, 0, 'utf8', common.mustCall(function(err, written) {
console.log('write done');
if (err) throw err;
assert.equal(Buffer.byteLength(expected), written);
fs.closeSync(fd);
const found = fs.readFileSync(fn2, 'utf8');
console.log('expected: "%s"', expected);
console.log('found: "%s"', found);
fs.unlinkSync(fn2);
assert.strictEqual(expected, found);
}));
}));
common.mustCall((err, fd) => {
if (err) throw err;
console.log('open done');
fs.write(fd, '', 0, 'utf8', (err, written) => {
assert.equal(0, written);
});
fs.write(fd, expected, 0, 'utf8', common.mustCall((err, written) => {
console.log('write done');
if (err) throw err;
assert.equal(Buffer.byteLength(expected), written);
fs.closeSync(fd);
const found = fs.readFileSync(fn2, 'utf8');
console.log('expected: "%s"', expected);
console.log('found: "%s"', found);
fs.unlinkSync(fn2);
assert.strictEqual(expected, found);
}));
}));
8 changes: 4 additions & 4 deletions test/parallel/test-http-invalidheaderfield2.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ const checkInvalidHeaderChar = require('_http_common')._checkInvalidHeaderChar;
'Ding!\x07'
].forEach(function(str) {
assert.strictEqual(checkInvalidHeaderChar(str),
true,
'checkInvalidHeaderChar(' +
inspect(str) +
') unexpectedly succeeded');
true,
'checkInvalidHeaderChar(' +
inspect(str) +
') unexpectedly succeeded');
});
36 changes: 18 additions & 18 deletions test/parallel/test-timers-throw-when-cb-not-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ function doSetTimeout(callback, after) {
}

assert.throws(doSetTimeout('foo'),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetTimeout({foo: 'bar'}),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetTimeout(),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetTimeout(undefined, 0),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetTimeout(null, 0),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetTimeout(false, 0),
/"callback" argument must be a function/);
/"callback" argument must be a function/);


function doSetInterval(callback, after) {
Expand All @@ -29,17 +29,17 @@ function doSetInterval(callback, after) {
}

assert.throws(doSetInterval('foo'),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetInterval({foo: 'bar'}),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetInterval(),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetInterval(undefined, 0),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetInterval(null, 0),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetInterval(false, 0),
/"callback" argument must be a function/);
/"callback" argument must be a function/);


function doSetImmediate(callback, after) {
Expand All @@ -49,14 +49,14 @@ function doSetImmediate(callback, after) {
}

assert.throws(doSetImmediate('foo'),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetImmediate({foo: 'bar'}),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetImmediate(),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetImmediate(undefined, 0),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetImmediate(null, 0),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
assert.throws(doSetImmediate(false, 0),
/"callback" argument must be a function/);
/"callback" argument must be a function/);
Loading

0 comments on commit 4492cc3

Please sign in to comment.