Skip to content

Commit

Permalink
test: remove unnecessary noop function args to mustCall()
Browse files Browse the repository at this point in the history
PR-URL: #45027
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
Trott authored and RafaelGSS committed Nov 1, 2022
1 parent c5705db commit a6a3439
Show file tree
Hide file tree
Showing 22 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion test/async-hooks/test-late-hook-enable.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const fnsToTest = [setTimeout, (cb) => {

const hook = async_hooks.createHook({
before: common.mustNotCall(),
after: common.mustCall(() => {}, 3),
after: common.mustCall(3),
destroy: common.mustCall(() => {
hook.disable();
nextTest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const promise = new Promise((resolve) => {
setTimeout(() => {
initialAsyncId = async_hooks.executionAsyncId();
async_hooks.createHook({
after: common.mustCall(() => {}, 2)
after: common.mustCall(2)
}).enable();
resolve();
}, 0);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-async-hooks-enable-disable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const assert = require('assert');
const async_hooks = require('async_hooks');

const hook = async_hooks.createHook({
init: common.mustCall(() => {}, 1),
init: common.mustCall(1),
before: common.mustNotCall(),
after: common.mustNotCall(),
destroy: common.mustNotCall()
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-cluster-worker-kill-signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ if (cluster.isWorker) {
}, 1));

// Check if the cluster was killed as well
cluster.on('exit', common.mustCall(() => {}, 1));
cluster.on('exit', common.mustCall(1));
}
12 changes: 6 additions & 6 deletions test/parallel/test-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ assert.throws(
message: /^fhqwhgads$/
});

const fnOnce = common.mustCall(() => {});
const fnOnce = common.mustCall();
fnOnce();
const fnTwice = common.mustCall(() => {}, 2);
const fnTwice = common.mustCall(2);
fnTwice();
fnTwice();
const fnAtLeast1Called1 = common.mustCallAtLeast(() => {}, 1);
const fnAtLeast1Called1 = common.mustCallAtLeast(1);
fnAtLeast1Called1();
const fnAtLeast1Called2 = common.mustCallAtLeast(() => {}, 1);
const fnAtLeast1Called2 = common.mustCallAtLeast(1);
fnAtLeast1Called2();
fnAtLeast1Called2();
const fnAtLeast2Called2 = common.mustCallAtLeast(() => {}, 2);
const fnAtLeast2Called2 = common.mustCallAtLeast(2);
fnAtLeast2Called2();
fnAtLeast2Called2();
const fnAtLeast2Called3 = common.mustCallAtLeast(() => {}, 2);
const fnAtLeast2Called3 = common.mustCallAtLeast(2);
fnAtLeast2Called3();
fnAtLeast2Called3();
fnAtLeast2Called3();
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-dgram-bind-fd.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const BUFFER_SIZE = 4096;
assert.fail(err.message);
});

socket.on('close', common.mustCall(() => {}));
socket.on('close', common.mustCall());
}));

receiver.on('message', common.mustCall((data, { address, port }) => {
Expand All @@ -109,7 +109,7 @@ const BUFFER_SIZE = 4096;
assert.fail(err.message);
});

receiver.on('close', common.mustCall(() => {}));
receiver.on('close', common.mustCall());
}

testWithOptions(true, true);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-dns-get-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ const { Resolver } = require('dns');
const resolver = new Resolver();
assert(resolver.getServers().length > 0);
// return undefined
resolver._handle.getServers = common.mustCall(() => {});
resolver._handle.getServers = common.mustCall();
assert.strictEqual(resolver.getServers().length, 0);
6 changes: 3 additions & 3 deletions test/parallel/test-fs-stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ fs.stat(__filename, common.mustSucceed((s) => {
});

// Should not throw an error
fs.stat(__filename, undefined, common.mustCall(() => {}));
fs.stat(__filename, undefined, common.mustCall());

fs.open(__filename, 'r', undefined, common.mustCall((err, fd) => {
// Should not throw an error
fs.fstat(fd, undefined, common.mustCall(() => {}));
fs.fstat(fd, undefined, common.mustCall());
}));

// Should not throw an error
fs.lstat(__filename, undefined, common.mustCall(() => {}));
fs.lstat(__filename, undefined, common.mustCall());
2 changes: 1 addition & 1 deletion test/parallel/test-fs-watch-close-when-destroyed.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ watcher.addListener('change', () => {
fs.rmdirSync(root);
// Wait for the listener to hit
setTimeout(
common.mustCall(() => {}),
common.mustCall(),
common.platformTimeout(100)
);
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ server.listen(0, common.mustCall(() => {
const client = http2.connect(`http://localhost:${server.address().port}`);
const req = client.request();

req.on('response', common.mustCall(() => {}));
req.on('response', common.mustCall());
req.once('data', common.mustCall(() => {
net.Socket.prototype.destroy.call(client.socket);
server.close();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-window-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ for (const buffers of buffersList) {
p = p.then(() => run(buffers, initialWindowSize));
}
}
p.then(common.mustCall(() => {}));
p.then(common.mustCall());
2 changes: 1 addition & 1 deletion test/parallel/test-net-socket-end-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ server.listen(common.mustCall(() => {
});
};

const cb = common.mustCall(() => {}, 3);
const cb = common.mustCall(3);

connect(cb);
connect('foo', cb);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-net-socket-setnodelay.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ falseyValues.forEach((testVal) => socket.setNoDelay(testVal));

socket = new net.Socket({
handle: {
setNoDelay: common.mustCall(() => {}, 3),
setNoDelay: common.mustCall(3),
readStart() {}
}
});
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-promise-hook-exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ testHook('onSettled');
testHook('onBefore');
testHook('onAfter');

const stop = promiseHooks.onInit(common.mustCall(() => {}, 2));
const stop = promiseHooks.onInit(common.mustCall(2));

Promise.resolve().then(stop);
2 changes: 1 addition & 1 deletion test/parallel/test-stream-duplex-from.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const { Blob } = require('buffer');
}
assert.strictEqual(ret, 'abcdefghi');
},
common.mustCall(() => {}),
common.mustCall(),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { Readable, Duplex, pipeline } = require('stream');
// Refs: https://github.com/nodejs/node/issues/24456

const readable = new Readable({
read: common.mustCall(() => {})
read: common.mustCall()
});

const duplex = new Duplex({
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream-pipeline-with-empty-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ async function runTest() {
);
}

runTest().then(common.mustCall(() => {}));
runTest().then(common.mustCall());
2 changes: 1 addition & 1 deletion test/parallel/test-stream-readable-unshift.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,6 @@ const { Readable } = require('stream');

const stream = new ArrayReader();
stream.once('readable', common.mustCall(onRead));
stream.on('end', common.mustCall(() => {}));
stream.on('end', common.mustCall());

}
2 changes: 1 addition & 1 deletion test/parallel/test-tls-close-notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const server = tls.createServer({
}, common.mustCall(function() {
// Send close-notify without shutting down TCP socket.
const req = new ShutdownWrap();
req.oncomplete = common.mustCall(() => {});
req.oncomplete = common.mustCall();
req.handle = c._handle;
c._handle.shutdown(req);
}));
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-ttywrap-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const common = require('../common');
// will not crash the process if there
// is not enough space on the V8 stack

const done = common.mustCall(() => {});
const done = common.mustCall();

async function test() {
await test();
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 @@ -10,14 +10,14 @@ new Worker(new URL('data:text/javascript,export{}'))
.on('error', common.mustNotCall(() => {}));

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

new Worker(new URL('data:text/javascript,await Promise.resolve()'))
.on('error', common.mustNotCall(() => {}));
new Worker(new URL('data:text/javascript,await Promise.reject()'))
.on('error', common.mustCall(() => {}));
.on('error', common.mustCall());
new Worker(new URL('data:text/javascript,await new Promise(()=>{})'))
.on(
'exit',
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-tls-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const tls = require('tls');
});
});

connectDoesNotThrow(common.mustCall(() => {}));
connectDoesNotThrow(common.mustCall());

function connectDoesNotThrow(input) {
const opts = {
Expand Down

0 comments on commit a6a3439

Please sign in to comment.