mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
test: remove unnecessary noop function args to mustCall()
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
1a8f8ba6c6
commit
6059cbedbd
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 }) => {
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -37,6 +37,6 @@ watcher.addListener('change', () => {
|
|||
fs.rmdirSync(root);
|
||||
// Wait for the listener to hit
|
||||
setTimeout(
|
||||
common.mustCall(() => {}),
|
||||
common.mustCall(),
|
||||
common.platformTimeout(100)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -100,4 +100,4 @@ for (const buffers of buffersList) {
|
|||
p = p.then(() => run(buffers, initialWindowSize));
|
||||
}
|
||||
}
|
||||
p.then(common.mustCall(() => {}));
|
||||
p.then(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ server.listen(common.mustCall(() => {
|
|||
});
|
||||
};
|
||||
|
||||
const cb = common.mustCall(() => {}, 3);
|
||||
const cb = common.mustCall(3);
|
||||
|
||||
connect(cb);
|
||||
connect('foo', cb);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ falseyValues.forEach((testVal) => socket.setNoDelay(testVal));
|
|||
|
||||
socket = new net.Socket({
|
||||
handle: {
|
||||
setNoDelay: common.mustCall(() => {}, 3),
|
||||
setNoDelay: common.mustCall(3),
|
||||
readStart() {}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ const { Blob } = require('buffer');
|
|||
}
|
||||
assert.strictEqual(ret, 'abcdefghi');
|
||||
},
|
||||
common.mustCall(() => {}),
|
||||
common.mustCall(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -15,4 +15,4 @@ async function runTest() {
|
|||
);
|
||||
}
|
||||
|
||||
runTest().then(common.mustCall(() => {}));
|
||||
runTest().then(common.mustCall());
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const tls = require('tls');
|
|||
});
|
||||
});
|
||||
|
||||
connectDoesNotThrow(common.mustCall(() => {}));
|
||||
connectDoesNotThrow(common.mustCall());
|
||||
|
||||
function connectDoesNotThrow(input) {
|
||||
const opts = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user