Skip to content

Commit

Permalink
test: remove unnecessary noop function args to mustNotCall()
Browse files Browse the repository at this point in the history
PR-URL: #48513
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Harshitha K P <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
aduh95 authored and RafaelGSS committed Jul 3, 2023
1 parent 84d0eb7 commit 24a8fa9
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion test/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ rules:
message: Use Number.isNaN() instead of the global isNaN() function.
- selector: VariableDeclarator > CallExpression:matches([callee.name='debuglog'], [callee.property.name='debuglog']):not([arguments.0.value='test'])
message: Use 'test' as debuglog value in tests.
- selector: CallExpression:matches([callee.object.name="common"][callee.property.name=/^mustCall/],[callee.name="mustCall"],[callee.name="mustCallAtLeast"])>:first-child[type=/FunctionExpression$/][body.body.length=0]
- selector: CallExpression:matches([callee.object.name="common"][callee.property.name=/^must(Not)?Call/],[callee.name="mustCall"],[callee.name="mustCallAtLeast"],[callee.name="mustNotCall"])>:first-child[type=/FunctionExpression$/][body.body.length=0]
message: Do not use an empty function, omit the parameter altogether.
- selector: Identifier[name='webcrypto']
message: Use `globalThis.crypto`.
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-execfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const execOpts = { encoding: 'utf8', shell: true };
// Verify that if something different than Abortcontroller.signal
// is passed, ERR_INVALID_ARG_TYPE is thrown
assert.throws(() => {
const callback = common.mustNotCall(() => {});
const callback = common.mustNotCall();

execFile(process.execPath, [echoFixture, 0], { signal: 'hello' }, callback);
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-promises-readfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async function validateWrongSignalParam() {
// is passed, ERR_INVALID_ARG_TYPE is thrown

await assert.rejects(async () => {
const callback = common.mustNotCall(() => {});
const callback = common.mustNotCall();
await readFile(fn, { signal: 'hello' }, callback);
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-fs-readfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ for (const e of fileInfo) {
// Verify that if something different than Abortcontroller.signal
// is passed, ERR_INVALID_ARG_TYPE is thrown
assert.throws(() => {
const callback = common.mustNotCall(() => {});
const callback = common.mustNotCall();
fs.readFile(fileInfo[0].name, { signal: 'hello' }, callback);
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
}
2 changes: 1 addition & 1 deletion test/parallel/test-http2-client-http1-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const http2 = require('http2');
const { NghttpError } = require('internal/http2/util');

// Creating an http1 server here...
const server = http.createServer(common.mustNotCall(() => {}))
const server = http.createServer(common.mustNotCall())
.on('clientError', common.mustCall((error, socket) => {
assert.strictEqual(error.code, 'HPE_PAUSED_H2_UPGRADE');
assert.strictEqual(error.bytesParsed, 24);
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-https-agent-session-injection.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const server = https.createServer(options, function(req, res) {
path: '/',
ca,
servername: 'nodejs.org',
}, common.mustNotCall(() => {}));
}, common.mustNotCall());

req.on('error', common.mustCall((err) => {
assert.strictEqual(
Expand All @@ -45,7 +45,7 @@ const server = https.createServer(options, function(req, res) {
path: '/',
ca,
servername: 'nodejs.org',
}, common.mustNotCall(() => {}));
}, common.mustNotCall());

second.on('error', common.mustCall((err) => {
server.close();
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-readline-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -1067,8 +1067,7 @@ for (let i = 0; i < 12; i++) {
rli.question('foo?', common.mustCall((answer) => {
assert.strictEqual(answer, 'baz');
}));
rli.question('bar?', common.mustNotCall(() => {
}));
rli.question('bar?', common.mustNotCall());
rli.write('baz\n');
rli.close();
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const { setTimeout } = require('timers/promises');
{
const stream = Readable.from([1, 2, 3, 4, 5]);
Object.defineProperty(stream, 'map', {
value: common.mustNotCall(() => {}),
value: common.mustNotCall(),
});
// Check that map isn't getting called.
stream.filter(() => true);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream-flatMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function oneTo5() {
{
const stream = oneTo5();
Object.defineProperty(stream, 'map', {
value: common.mustNotCall(() => {}),
value: common.mustNotCall(),
});
// Check that map isn't getting called.
stream.flatMap(() => true);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream-forEach.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const { once } = require('events');
{
const stream = Readable.from([1, 2, 3, 4, 5]);
Object.defineProperty(stream, 'map', {
value: common.mustNotCall(() => {}),
value: common.mustNotCall(),
});
// Check that map isn't getting called.
stream.forEach(() => true);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream-readable-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const assert = require('assert');

{
const read = new Readable({
read: common.mustNotCall(function() {})
read: common.mustNotCall()
});
read.destroy();
assert.strictEqual(read.destroyed, true);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream-readable-next-no-null.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ stream.on('error', expectsError({
message: 'May not write null values to stream'
}));

stream.on('data', mustNotCall((chunk) => {}));
stream.on('data', mustNotCall());

stream.on('end', mustNotCall());
2 changes: 1 addition & 1 deletion test/parallel/test-stream-some-find-every.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function oneTo5Async() {
for (const op of ['some', 'every', 'find']) {
const stream = oneTo5();
Object.defineProperty(stream, 'map', {
value: common.mustNotCall(() => {}),
value: common.mustNotCall(),
});
// Check that map isn't getting called.
stream[op](() => {});
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-worker-data-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ const { Worker } = require('worker_threads');
const assert = require('assert');

new Worker(new URL('data:text/javascript,'))
.on('error', common.mustNotCall(() => {}));
.on('error', common.mustNotCall());
new Worker(new URL('data:text/javascript,export{}'))
.on('error', common.mustNotCall(() => {}));
.on('error', common.mustNotCall());

new Worker(new URL('data:text/plain,'))
.on('error', common.mustCall());
new Worker(new URL('data:text/javascript,module.exports={}'))
.on('error', common.mustCall());

new Worker(new URL('data:text/javascript,await Promise.resolve()'))
.on('error', common.mustNotCall(() => {}));
.on('error', common.mustNotCall());
new Worker(new URL('data:text/javascript,await Promise.reject()'))
.on('error', common.mustCall());
new Worker(new URL('data:text/javascript,await new Promise(()=>{})'))
Expand Down

0 comments on commit 24a8fa9

Please sign in to comment.