From a7b94500f2b9acb305ccc4777f26e4f720774119 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 24 Mar 2017 09:46:44 -0700 Subject: [PATCH] test: add common.noop, default for common.mustCall() Export a new common.noop no-operation function for general use. Allow using common.mustCall() without a fn argument to simplify test cases. Replace various non-op functions throughout tests with common.noop PR-URL: https://github.com/nodejs/node/pull/12027 Reviewed-By: Jeremiah Senkpiel Reviewed-By: Richard Lau Reviewed-By: Gibson Fahnestock Reviewed-By: Teddy Katz Reviewed-By: Colin Ihrig Reviewed-By: Franziska Hinkelmann --- test/addons/async-hello-world/test.js | 2 +- test/common/index.js | 16 +++++-- test/debugger/test-debugger-client.js | 4 +- test/parallel/test-assert.js | 3 +- .../parallel/test-child-process-disconnect.js | 2 +- test/parallel/test-child-process-kill.js | 4 +- test/parallel/test-child-process-stdin.js | 4 +- test/parallel/test-cluster-eaccess.js | 4 +- .../test-cluster-setup-master-emit.js | 2 +- test/parallel/test-cluster-worker-destroy.js | 4 +- .../test-cluster-worker-wait-server-close.js | 2 +- test/parallel/test-common.js | 4 +- test/parallel/test-crypto-random.js | 2 +- .../test-dgram-close-is-not-callback.js | 2 +- test/parallel/test-dgram-close.js | 4 +- test/parallel/test-dgram-send-empty-buffer.js | 2 +- test/parallel/test-domain-crypto.js | 6 +-- test/parallel/test-domain-exit-dispose.js | 2 +- test/parallel/test-domain-timers.js | 2 +- test/parallel/test-domain.js | 4 +- test/parallel/test-env-var-no-warnings.js | 2 +- ...test-event-emitter-check-listener-leaks.js | 32 +++++++------- .../test-event-emitter-get-max-listeners.js | 6 +-- .../test-event-emitter-listener-count.js | 10 ++--- ...-emitter-max-listeners-warning-for-null.js | 4 +- ...mitter-max-listeners-warning-for-symbol.js | 4 +- ...est-event-emitter-max-listeners-warning.js | 6 +-- .../test-event-emitter-max-listeners.js | 2 +- test/parallel/test-event-emitter-once.js | 2 +- ...test-event-emitter-remove-all-listeners.js | 6 +-- test/parallel/test-event-emitter-subclass.js | 4 +- test/parallel/test-event-emitter-symbols.js | 2 +- test/parallel/test-fs-mkdir.js | 2 +- test/parallel/test-fs-read-stream-inherit.js | 12 ++--- test/parallel/test-fs-read-stream.js | 10 ++--- test/parallel/test-fs-watchfile.js | 2 +- test/parallel/test-handle-wrap-close-abort.js | 2 +- test/parallel/test-http-abort-client.js | 2 +- .../test-http-client-aborted-event.js | 2 +- test/parallel/test-http-invalidheaderfield.js | 4 +- .../test-http-pause-resume-one-end.js | 2 +- test/parallel/test-http-set-timeout-server.js | 8 ++-- test/parallel/test-http-upgrade-server.js | 4 +- test/parallel/test-https-close.js | 2 +- .../parallel/test-net-connect-options-ipv6.js | 2 +- test/parallel/test-net-connect-options.js | 2 +- ...n-close-server-callback-is-not-function.js | 2 +- .../parallel/test-net-socket-destroy-twice.js | 2 +- test/parallel/test-next-tick.js | 6 +-- test/parallel/test-process-next-tick.js | 2 +- .../test-promises-unhandled-rejections.js | 34 +++++++------- test/parallel/test-querystring.js | 4 +- test/parallel/test-readline-interface.js | 8 ++-- test/parallel/test-regress-GH-5051.js | 4 +- test/parallel/test-repl-.save.load.js | 6 +-- test/parallel/test-repl-history-perm.js | 2 +- test/parallel/test-repl-mode.js | 2 +- test/parallel/test-repl.js | 2 +- test/parallel/test-signal-handler.js | 4 +- test/parallel/test-stream-big-push.js | 2 +- test/parallel/test-stream-end-paused.js | 2 +- test/parallel/test-stream-events-prepend.js | 2 +- test/parallel/test-stream-pipe-after-end.js | 4 +- .../test-stream-pipe-error-handling.js | 6 +-- test/parallel/test-stream-readable-event.js | 6 +-- test/parallel/test-stream-wrap.js | 2 +- test/parallel/test-stream2-read-sync-stack.js | 2 +- .../test-stream2-readable-legacy-drain.js | 4 +- .../test-stream2-readable-non-empty-end.js | 2 +- .../test-stream2-readable-wrap-empty.js | 8 ++-- test/parallel/test-stream2-readable-wrap.js | 2 +- test/parallel/test-stream2-writable.js | 10 ++--- .../test-timers-uncaught-exception.js | 2 +- test/parallel/test-timers-unref-call.js | 4 +- ...-timers-unref-remove-other-unref-timers.js | 2 +- test/parallel/test-timers-unref.js | 8 ++-- test/parallel/test-timers-zero-timeout.js | 2 +- test/parallel/test-timers.js | 2 +- test/parallel/test-tls-cert-regression.js | 2 +- test/parallel/test-tls-connect-simple.js | 4 +- test/parallel/test-tls-connect.js | 4 +- .../parallel/test-tls-delayed-attach-error.js | 2 +- test/parallel/test-tls-env-extra-ca.js | 2 +- test/parallel/test-tls-invoke-queued.js | 2 +- test/parallel/test-tls-legacy-onselect.js | 2 +- test/parallel/test-tls-passphrase.js | 44 +++++++++---------- test/parallel/test-url.js | 4 +- test/parallel/test-util.js | 6 +-- test/parallel/test-vm-function-declaration.js | 2 +- test/parallel/test-zlib-close-after-write.js | 2 +- test/parallel/test-zlib-write-after-close.js | 2 +- test/parallel/test-zlib-zero-byte.js | 2 +- test/pummel/test-http-client-reconnect-bug.js | 2 +- test/pummel/test-net-connect-memleak.js | 2 +- test/pummel/test-stream2-basic.js | 4 +- test/sequential/test-child-process-pass-fd.js | 2 +- test/sequential/test-fs-watch.js | 2 +- .../test-https-set-timeout-server.js | 8 ++-- 98 files changed, 236 insertions(+), 225 deletions(-) diff --git a/test/addons/async-hello-world/test.js b/test/addons/async-hello-world/test.js index a6aa8aa20fffbc..fbd0d7eeb7ef13 100644 --- a/test/addons/async-hello-world/test.js +++ b/test/addons/async-hello-world/test.js @@ -6,5 +6,5 @@ const binding = require(`./build/${common.buildType}/binding`); binding(5, common.mustCall(function(err, val) { assert.strictEqual(err, null); assert.strictEqual(val, 10); - process.nextTick(common.mustCall(function() {})); + process.nextTick(common.mustCall()); })); diff --git a/test/common/index.js b/test/common/index.js index 455d50fe6c344a..21897a39cac456 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -12,6 +12,9 @@ const Timer = process.binding('timer_wrap').Timer; const testRoot = process.env.NODE_TEST_DIR ? fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..'); +const noop = () => {}; + +exports.noop = noop; exports.fixturesDir = path.join(__dirname, '..', 'fixtures'); exports.tmpDirName = 'tmp'; // PORT should match the definition in test/testpy/__init__.py. @@ -419,6 +422,13 @@ function runCallChecks(exitCode) { exports.mustCall = function(fn, expected) { + if (typeof fn === 'number') { + expected = fn; + fn = noop; + } else if (fn === undefined) { + fn = noop; + } + if (expected === undefined) expected = 1; else if (typeof expected !== 'number') @@ -487,9 +497,9 @@ util.inherits(ArrayStream, stream.Stream); exports.ArrayStream = ArrayStream; ArrayStream.prototype.readable = true; ArrayStream.prototype.writable = true; -ArrayStream.prototype.pause = function() {}; -ArrayStream.prototype.resume = function() {}; -ArrayStream.prototype.write = function() {}; +ArrayStream.prototype.pause = noop; +ArrayStream.prototype.resume = noop; +ArrayStream.prototype.write = noop; // Returns true if the exit code "exitCode" and/or signal name "signal" // represent the exit code and/or signal name of a node process that aborted, diff --git a/test/debugger/test-debugger-client.js b/test/debugger/test-debugger-client.js index 660d8e286ee250..89b22bc2a054fc 100644 --- a/test/debugger/test-debugger-client.js +++ b/test/debugger/test-debugger-client.js @@ -129,7 +129,7 @@ addTest(function(client, done) { let connectCount = 0; const script = 'setTimeout(function() { console.log("blah"); });' + - 'setInterval(function() {}, 1000000);'; + 'setInterval(common.noop, 1000000);'; let nodeProcess; @@ -172,7 +172,7 @@ function doTest(cb, done) { console.error('>>> connecting...'); c.connect(debug.port); c.on('break', function() { - c.reqContinue(function() {}); + c.reqContinue(common.noop); }); c.on('ready', function() { connectCount++; diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 3a81c6f810425a..ac55f6f5113857 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const a = require('assert'); @@ -515,6 +515,7 @@ testAssertionMessage(/a/, '/a/'); testAssertionMessage(/abc/gim, '/abc/gim'); testAssertionMessage(function f() {}, '[Function: f]'); testAssertionMessage(function() {}, '[Function]'); +testAssertionMessage(common.noop, '[Function: noop]'); testAssertionMessage({}, '{}'); testAssertionMessage(circular, '{ y: 1, x: [Circular] }'); testAssertionMessage({a: undefined, b: null}, '{ a: undefined, b: null }'); diff --git a/test/parallel/test-child-process-disconnect.js b/test/parallel/test-child-process-disconnect.js index ee9488d1cd0b05..d4fa99557cec11 100644 --- a/test/parallel/test-child-process-disconnect.js +++ b/test/parallel/test-child-process-disconnect.js @@ -57,7 +57,7 @@ if (process.argv[2] === 'child') { })); // the process should also self terminate without using signals - child.on('exit', common.mustCall(function() {})); + child.on('exit', common.mustCall()); // when child is listening child.on('message', function(obj) { diff --git a/test/parallel/test-child-process-kill.js b/test/parallel/test-child-process-kill.js index e0e951610dc146..02bd739f0beb27 100644 --- a/test/parallel/test-child-process-kill.js +++ b/test/parallel/test-child-process-kill.js @@ -4,9 +4,9 @@ const assert = require('assert'); const spawn = require('child_process').spawn; const cat = spawn(common.isWindows ? 'cmd' : 'cat'); -cat.stdout.on('end', common.mustCall(function() {})); +cat.stdout.on('end', common.mustCall()); cat.stderr.on('data', common.mustNotCall()); -cat.stderr.on('end', common.mustCall(function() {})); +cat.stderr.on('end', common.mustCall()); cat.on('exit', common.mustCall(function(code, signal) { assert.strictEqual(code, null); diff --git a/test/parallel/test-child-process-stdin.js b/test/parallel/test-child-process-stdin.js index 3da722ec71de2d..d811bc46b540e7 100644 --- a/test/parallel/test-child-process-stdin.js +++ b/test/parallel/test-child-process-stdin.js @@ -22,11 +22,11 @@ cat.stdout.on('data', function(chunk) { response += chunk; }); -cat.stdout.on('end', common.mustCall(function() {})); +cat.stdout.on('end', common.mustCall()); cat.stderr.on('data', common.mustNotCall()); -cat.stderr.on('end', common.mustCall(function() {})); +cat.stderr.on('end', common.mustCall()); cat.on('exit', common.mustCall(function(status) { assert.strictEqual(0, status); diff --git a/test/parallel/test-cluster-eaccess.js b/test/parallel/test-cluster-eaccess.js index 3682bac69064df..66ea101556db18 100644 --- a/test/parallel/test-cluster-eaccess.js +++ b/test/parallel/test-cluster-eaccess.js @@ -14,10 +14,10 @@ if (cluster.isMaster) { const worker = cluster.fork(); // makes sure master is able to fork the worker - cluster.on('fork', common.mustCall(function() {})); + cluster.on('fork', common.mustCall()); // makes sure the worker is ready - worker.on('online', common.mustCall(function() {})); + worker.on('online', common.mustCall()); worker.on('message', common.mustCall(function(err) { // disconnect first, so that we will not leave zombies diff --git a/test/parallel/test-cluster-setup-master-emit.js b/test/parallel/test-cluster-setup-master-emit.js index 5b828e7b8e360f..a93441c116dff4 100644 --- a/test/parallel/test-cluster-setup-master-emit.js +++ b/test/parallel/test-cluster-setup-master-emit.js @@ -22,5 +22,5 @@ function emitAndCatch2(next) { } emitAndCatch(common.mustCall(function() { - emitAndCatch2(common.mustCall(function() {})); + emitAndCatch2(common.mustCall()); })); diff --git a/test/parallel/test-cluster-worker-destroy.js b/test/parallel/test-cluster-worker-destroy.js index 62000254247a1f..4c03d4d440322d 100644 --- a/test/parallel/test-cluster-worker-destroy.js +++ b/test/parallel/test-cluster-worker-destroy.js @@ -17,8 +17,8 @@ if (cluster.isMaster) { worker2 = cluster.fork(); [worker1, worker2].forEach(function(worker) { - worker.on('disconnect', common.mustCall(function() {})); - worker.on('exit', common.mustCall(function() {})); + worker.on('disconnect', common.mustCall()); + worker.on('exit', common.mustCall()); }); } else { if (cluster.worker.id === 1) { diff --git a/test/parallel/test-cluster-worker-wait-server-close.js b/test/parallel/test-cluster-worker-wait-server-close.js index 1d19398a3d8799..f91003e9a5c33e 100644 --- a/test/parallel/test-cluster-worker-wait-server-close.js +++ b/test/parallel/test-cluster-worker-wait-server-close.js @@ -20,7 +20,7 @@ if (cluster.isWorker) { // Although not typical, the worker process can exit before the disconnect // event fires. Use this to keep the process open until the event has fired. - const keepOpen = setInterval(function() {}, 9999); + const keepOpen = setInterval(common.noop, 9999); // Check worker events and properties process.once('disconnect', function() { diff --git a/test/parallel/test-common.js b/test/parallel/test-common.js index 17f41840e4ffa5..86c6f8a0dd5b29 100644 --- a/test/parallel/test-common.js +++ b/test/parallel/test-common.js @@ -7,9 +7,9 @@ global.gc = 42; // Not a valid global unless --expose_gc is set. assert.deepStrictEqual(common.leakedGlobals(), ['gc']); assert.throws(function() { - common.mustCall(function() {}, 'foo'); + common.mustCall(common.noop, 'foo'); }, /^TypeError: Invalid expected value: foo$/); assert.throws(function() { - common.mustCall(function() {}, /foo/); + common.mustCall(common.noop, /foo/); }, /^TypeError: Invalid expected value: \/foo\/$/); diff --git a/test/parallel/test-crypto-random.js b/test/parallel/test-crypto-random.js index 28b8847e56478c..29928ad6e18a82 100644 --- a/test/parallel/test-crypto-random.js +++ b/test/parallel/test-crypto-random.js @@ -17,7 +17,7 @@ const expectedErrorRegexp = /^TypeError: size must be a number >= 0$/; [crypto.randomBytes, crypto.pseudoRandomBytes].forEach(function(f) { [-1, undefined, null, false, true, {}, []].forEach(function(value) { assert.throws(function() { f(value); }, expectedErrorRegexp); - assert.throws(function() { f(value, function() {}); }, expectedErrorRegexp); + assert.throws(function() { f(value, common.noop); }, expectedErrorRegexp); }); [0, 1, 2, 4, 16, 256, 1024].forEach(function(len) { diff --git a/test/parallel/test-dgram-close-is-not-callback.js b/test/parallel/test-dgram-close-is-not-callback.js index 416c5b305e1c49..70700a16c6a798 100644 --- a/test/parallel/test-dgram-close-is-not-callback.js +++ b/test/parallel/test-dgram-close-is-not-callback.js @@ -17,5 +17,5 @@ const portGetter = dgram.createSocket('udp4') socket.close('bad argument'); portGetter.close(); - socket.on('close', common.mustCall(function() {})); + socket.on('close', common.mustCall()); })); diff --git a/test/parallel/test-dgram-close.js b/test/parallel/test-dgram-close.js index 482cf529e6720f..f4845da479286a 100644 --- a/test/parallel/test-dgram-close.js +++ b/test/parallel/test-dgram-close.js @@ -18,8 +18,8 @@ const portGetter = dgram.createSocket('udp4') portGetter.address().port, portGetter.address().address); - assert.strictEqual(socket.close(common.mustCall(function() {})), socket); - socket.on('close', common.mustCall(function() {})); + assert.strictEqual(socket.close(common.mustCall()), socket); + socket.on('close', common.mustCall()); socket = null; // Verify that accessing handle after closure doesn't throw diff --git a/test/parallel/test-dgram-send-empty-buffer.js b/test/parallel/test-dgram-send-empty-buffer.js index 56a0383eb14c9e..0486b2bdbe3959 100644 --- a/test/parallel/test-dgram-send-empty-buffer.js +++ b/test/parallel/test-dgram-send-empty-buffer.js @@ -22,6 +22,6 @@ client.bind(0, common.mustCall(function() { const buf = Buffer.alloc(0); let interval = setInterval(function() { - client.send(buf, 0, 0, port, '127.0.0.1', common.mustCall(function() {})); + client.send(buf, 0, 0, port, '127.0.0.1', common.mustCall()); }, 10); })); diff --git a/test/parallel/test-domain-crypto.js b/test/parallel/test-domain-crypto.js index dfa2636816aff4..bc9c4b6d467ec4 100644 --- a/test/parallel/test-domain-crypto.js +++ b/test/parallel/test-domain-crypto.js @@ -17,7 +17,7 @@ global.domain = require('domain'); // should not throw a 'TypeError: undefined is not a function' exception crypto.randomBytes(8); -crypto.randomBytes(8, function() {}); +crypto.randomBytes(8, common.noop); crypto.pseudoRandomBytes(8); -crypto.pseudoRandomBytes(8, function() {}); -crypto.pbkdf2('password', 'salt', 8, 8, function() {}); +crypto.pseudoRandomBytes(8, common.noop); +crypto.pbkdf2('password', 'salt', 8, 8, common.noop); diff --git a/test/parallel/test-domain-exit-dispose.js b/test/parallel/test-domain-exit-dispose.js index e1797cb660a0c0..a9c69ac3396712 100644 --- a/test/parallel/test-domain-exit-dispose.js +++ b/test/parallel/test-domain-exit-dispose.js @@ -22,7 +22,7 @@ function err() { function err2() { // this timeout should never be called, since the domain gets // disposed when the error happens. - setTimeout(common.mustCall(() => {}, 0), 1); + setTimeout(common.mustNotCall(), 1); // this function doesn't exist, and throws an error as a result. err3(); // eslint-disable-line no-undef diff --git a/test/parallel/test-domain-timers.js b/test/parallel/test-domain-timers.js index 7d51b61fd04be6..7fff5468564449 100644 --- a/test/parallel/test-domain-timers.js +++ b/test/parallel/test-domain-timers.js @@ -32,4 +32,4 @@ immediated.run(function() { }); }); -timeout = setTimeout(function() {}, 10 * 1000); +timeout = setTimeout(common.noop, 10 * 1000); diff --git a/test/parallel/test-domain.js b/test/parallel/test-domain.js index ab286429f5c5d5..f5dc699f2595b9 100644 --- a/test/parallel/test-domain.js +++ b/test/parallel/test-domain.js @@ -1,7 +1,7 @@ 'use strict'; // Simple tests of most basic domain functionality. -require('../common'); +const common = require('../common'); const assert = require('assert'); const domain = require('domain'); const events = require('events'); @@ -238,7 +238,7 @@ let fst = fs.createReadStream('stream for nonexistent file'); d.add(fst); expectCaught++; -[42, null, , false, function() {}, 'string'].forEach(function(something) { +[42, null, , false, common.noop, 'string'].forEach(function(something) { const d = new domain.Domain(); d.run(function() { process.nextTick(function() { diff --git a/test/parallel/test-env-var-no-warnings.js b/test/parallel/test-env-var-no-warnings.js index 1df31d8920753d..37774f2a161a52 100644 --- a/test/parallel/test-env-var-no-warnings.js +++ b/test/parallel/test-env-var-no-warnings.js @@ -29,7 +29,7 @@ if (process.argv[2] === 'child') { test({ NODE_NO_WARNINGS: false }); test({ NODE_NO_WARNINGS: {} }); test({ NODE_NO_WARNINGS: [] }); - test({ NODE_NO_WARNINGS: function() {} }); + test({ NODE_NO_WARNINGS: common.noop }); test({ NODE_NO_WARNINGS: 0 }); test({ NODE_NO_WARNINGS: -1 }); test({ NODE_NO_WARNINGS: '0' }); diff --git a/test/parallel/test-event-emitter-check-listener-leaks.js b/test/parallel/test-event-emitter-check-listener-leaks.js index 5b9787f1b83bba..0f5f3757c64932 100644 --- a/test/parallel/test-event-emitter-check-listener-leaks.js +++ b/test/parallel/test-event-emitter-check-listener-leaks.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const events = require('events'); @@ -7,40 +7,40 @@ let e = new events.EventEmitter(); // default for (let i = 0; i < 10; i++) { - e.on('default', function() {}); + e.on('default', common.noop); } assert.ok(!e._events['default'].hasOwnProperty('warned')); -e.on('default', function() {}); +e.on('default', common.noop); assert.ok(e._events['default'].warned); // symbol const symbol = Symbol('symbol'); e.setMaxListeners(1); -e.on(symbol, function() {}); +e.on(symbol, common.noop); assert.ok(!e._events[symbol].hasOwnProperty('warned')); -e.on(symbol, function() {}); +e.on(symbol, common.noop); assert.ok(e._events[symbol].hasOwnProperty('warned')); // specific e.setMaxListeners(5); for (let i = 0; i < 5; i++) { - e.on('specific', function() {}); + e.on('specific', common.noop); } assert.ok(!e._events['specific'].hasOwnProperty('warned')); -e.on('specific', function() {}); +e.on('specific', common.noop); assert.ok(e._events['specific'].warned); // only one e.setMaxListeners(1); -e.on('only one', function() {}); +e.on('only one', common.noop); assert.ok(!e._events['only one'].hasOwnProperty('warned')); -e.on('only one', function() {}); +e.on('only one', common.noop); assert.ok(e._events['only one'].hasOwnProperty('warned')); // unlimited e.setMaxListeners(0); for (let i = 0; i < 1000; i++) { - e.on('unlimited', function() {}); + e.on('unlimited', common.noop); } assert.ok(!e._events['unlimited'].hasOwnProperty('warned')); @@ -49,26 +49,26 @@ events.EventEmitter.defaultMaxListeners = 42; e = new events.EventEmitter(); for (let i = 0; i < 42; ++i) { - e.on('fortytwo', function() {}); + e.on('fortytwo', common.noop); } assert.ok(!e._events['fortytwo'].hasOwnProperty('warned')); -e.on('fortytwo', function() {}); +e.on('fortytwo', common.noop); assert.ok(e._events['fortytwo'].hasOwnProperty('warned')); delete e._events['fortytwo'].warned; events.EventEmitter.defaultMaxListeners = 44; -e.on('fortytwo', function() {}); +e.on('fortytwo', common.noop); assert.ok(!e._events['fortytwo'].hasOwnProperty('warned')); -e.on('fortytwo', function() {}); +e.on('fortytwo', common.noop); assert.ok(e._events['fortytwo'].hasOwnProperty('warned')); // but _maxListeners still has precedence over defaultMaxListeners events.EventEmitter.defaultMaxListeners = 42; e = new events.EventEmitter(); e.setMaxListeners(1); -e.on('uno', function() {}); +e.on('uno', common.noop); assert.ok(!e._events['uno'].hasOwnProperty('warned')); -e.on('uno', function() {}); +e.on('uno', common.noop); assert.ok(e._events['uno'].hasOwnProperty('warned')); // chainable diff --git a/test/parallel/test-event-emitter-get-max-listeners.js b/test/parallel/test-event-emitter-get-max-listeners.js index 9acc71fd7920e3..98ac02e87130b5 100644 --- a/test/parallel/test-event-emitter-get-max-listeners.js +++ b/test/parallel/test-event-emitter-get-max-listeners.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const EventEmitter = require('events'); @@ -15,5 +15,5 @@ assert.strictEqual(emitter.getMaxListeners(), 3); // https://github.com/nodejs/node/issues/523 - second call should not throw. const recv = {}; -EventEmitter.prototype.on.call(recv, 'event', function() {}); -EventEmitter.prototype.on.call(recv, 'event', function() {}); +EventEmitter.prototype.on.call(recv, 'event', common.noop); +EventEmitter.prototype.on.call(recv, 'event', common.noop); diff --git a/test/parallel/test-event-emitter-listener-count.js b/test/parallel/test-event-emitter-listener-count.js index ebfed8b2ee33b1..50247f42770ba8 100644 --- a/test/parallel/test-event-emitter-listener-count.js +++ b/test/parallel/test-event-emitter-listener-count.js @@ -1,15 +1,15 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const EventEmitter = require('events'); const emitter = new EventEmitter(); -emitter.on('foo', function() {}); -emitter.on('foo', function() {}); -emitter.on('baz', function() {}); +emitter.on('foo', common.noop); +emitter.on('foo', common.noop); +emitter.on('baz', common.noop); // Allow any type -emitter.on(123, function() {}); +emitter.on(123, common.noop); assert.strictEqual(EventEmitter.listenerCount(emitter, 'foo'), 2); assert.strictEqual(emitter.listenerCount('foo'), 2); diff --git a/test/parallel/test-event-emitter-max-listeners-warning-for-null.js b/test/parallel/test-event-emitter-max-listeners-warning-for-null.js index 62b06f67d92f28..16d9e28bb1eb44 100644 --- a/test/parallel/test-event-emitter-max-listeners-warning-for-null.js +++ b/test/parallel/test-event-emitter-max-listeners-warning-for-null.js @@ -18,5 +18,5 @@ process.on('warning', common.mustCall((warning) => { assert.ok(warning.message.includes('2 null listeners added.')); })); -e.on(null, function() {}); -e.on(null, function() {}); +e.on(null, common.noop); +e.on(null, common.noop); diff --git a/test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js b/test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js index 97bf189270395b..bd1a8bec7758b0 100644 --- a/test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js +++ b/test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js @@ -20,5 +20,5 @@ process.on('warning', common.mustCall((warning) => { assert.ok(warning.message.includes('2 Symbol(symbol) listeners added.')); })); -e.on(symbol, function() {}); -e.on(symbol, function() {}); +e.on(symbol, common.noop); +e.on(symbol, common.noop); diff --git a/test/parallel/test-event-emitter-max-listeners-warning.js b/test/parallel/test-event-emitter-max-listeners-warning.js index 21f4ee0cc6bcde..f0cdac1919d209 100644 --- a/test/parallel/test-event-emitter-max-listeners-warning.js +++ b/test/parallel/test-event-emitter-max-listeners-warning.js @@ -18,6 +18,6 @@ process.on('warning', common.mustCall((warning) => { assert.ok(warning.message.includes('2 event-type listeners added.')); })); -e.on('event-type', function() {}); -e.on('event-type', function() {}); // Trigger warning. -e.on('event-type', function() {}); // Verify that warning is emitted only once. +e.on('event-type', common.noop); +e.on('event-type', common.noop); // Trigger warning. +e.on('event-type', common.noop); // Verify that warning is emitted only once. diff --git a/test/parallel/test-event-emitter-max-listeners.js b/test/parallel/test-event-emitter-max-listeners.js index 2946c48f8fb30e..88156e90a0b347 100644 --- a/test/parallel/test-event-emitter-max-listeners.js +++ b/test/parallel/test-event-emitter-max-listeners.js @@ -4,7 +4,7 @@ const assert = require('assert'); const events = require('events'); const e = new events.EventEmitter(); -e.on('maxListeners', common.mustCall(function() {})); +e.on('maxListeners', common.mustCall()); // Should not corrupt the 'maxListeners' queue. e.setMaxListeners(42); diff --git a/test/parallel/test-event-emitter-once.js b/test/parallel/test-event-emitter-once.js index e304bccb6e2d42..c23a6c6769c0e6 100644 --- a/test/parallel/test-event-emitter-once.js +++ b/test/parallel/test-event-emitter-once.js @@ -24,7 +24,7 @@ e.once('e', common.mustCall(function() { e.emit('e'); })); -e.once('e', common.mustCall(function() {})); +e.once('e', common.mustCall()); e.emit('e'); diff --git a/test/parallel/test-event-emitter-remove-all-listeners.js b/test/parallel/test-event-emitter-remove-all-listeners.js index e793cedb0dd4cf..8c4d2caa74fb58 100644 --- a/test/parallel/test-event-emitter-remove-all-listeners.js +++ b/test/parallel/test-event-emitter-remove-all-listeners.js @@ -70,9 +70,9 @@ function listener() {} ee.on('removeListener', function(name, listener) { assert.strictEqual(expectLength--, this.listeners('baz').length); }); - ee.on('baz', function() {}); - ee.on('baz', function() {}); - ee.on('baz', function() {}); + ee.on('baz', common.noop); + ee.on('baz', common.noop); + ee.on('baz', common.noop); assert.strictEqual(ee.listeners('baz').length, expectLength + 1); ee.removeAllListeners('baz'); assert.strictEqual(ee.listeners('baz').length, 0); diff --git a/test/parallel/test-event-emitter-subclass.js b/test/parallel/test-event-emitter-subclass.js index eb2018e78e4b85..c0ce3392f7298f 100644 --- a/test/parallel/test-event-emitter-subclass.js +++ b/test/parallel/test-event-emitter-subclass.js @@ -13,7 +13,7 @@ function MyEE(cb) { EventEmitter.call(this); } -const myee = new MyEE(common.mustCall(function() {})); +const myee = new MyEE(common.mustCall()); util.inherits(ErrorEE, EventEmitter); @@ -41,6 +41,6 @@ MyEE2.prototype = new EventEmitter(); const ee1 = new MyEE2(); const ee2 = new MyEE2(); -ee1.on('x', function() {}); +ee1.on('x', common.noop); assert.strictEqual(ee2.listenerCount('x'), 0); diff --git a/test/parallel/test-event-emitter-symbols.js b/test/parallel/test-event-emitter-symbols.js index 9a2ae72f64464c..98d44ff3fa2afb 100644 --- a/test/parallel/test-event-emitter-symbols.js +++ b/test/parallel/test-event-emitter-symbols.js @@ -6,7 +6,7 @@ const assert = require('assert'); const ee = new EventEmitter(); const foo = Symbol('foo'); -const listener = common.mustCall(function() {}); +const listener = common.mustCall(); ee.on(foo, listener); assert.deepStrictEqual(ee.listeners(foo), [listener]); diff --git a/test/parallel/test-fs-mkdir.js b/test/parallel/test-fs-mkdir.js index e70880ef981d7e..cf744215a04ea4 100644 --- a/test/parallel/test-fs-mkdir.js +++ b/test/parallel/test-fs-mkdir.js @@ -56,4 +56,4 @@ common.refreshTmpDir(); // Keep the event loop alive so the async mkdir() requests // have a chance to run (since they don't ref the event loop). -process.nextTick(function() {}); +process.nextTick(common.noop); diff --git a/test/parallel/test-fs-read-stream-inherit.js b/test/parallel/test-fs-read-stream-inherit.js index d71dc3d4381272..b0bbde153539cc 100644 --- a/test/parallel/test-fs-read-stream-inherit.js +++ b/test/parallel/test-fs-read-stream-inherit.js @@ -39,7 +39,7 @@ let paused = false; }); - file.on('end', common.mustCall(function() {})); + file.on('end', common.mustCall()); file.on('close', common.mustCall(function() { @@ -139,7 +139,7 @@ let paused = false; let file7 = fs.createReadStream(rangeFile, Object.create({autoClose: false })); assert.strictEqual(file7.autoClose, false); - file7.on('data', function() {}); + file7.on('data', common.noop); file7.on('end', common.mustCall(function() { process.nextTick(common.mustCall(function() { assert(!file7.closed); @@ -169,8 +169,8 @@ let paused = false; { const options = Object.create({fd: 13337, autoClose: false}); const file8 = fs.createReadStream(null, options); - file8.on('data', function() {}); - file8.on('error', common.mustCall(function() {})); + file8.on('data', common.noop); + file8.on('error', common.mustCall()); process.on('exit', function() { assert(!file8.closed); assert(!file8.destroyed); @@ -181,8 +181,8 @@ let paused = false; // Make sure stream is destroyed when file does not exist. { const file9 = fs.createReadStream('/path/to/file/that/does/not/exist'); - file9.on('data', function() {}); - file9.on('error', common.mustCall(function() {})); + file9.on('data', common.noop); + file9.on('error', common.mustCall()); process.on('exit', function() { assert(!file9.closed); diff --git a/test/parallel/test-fs-read-stream.js b/test/parallel/test-fs-read-stream.js index d17703fabe6a27..5948845fcd8cbc 100644 --- a/test/parallel/test-fs-read-stream.js +++ b/test/parallel/test-fs-read-stream.js @@ -138,7 +138,7 @@ pauseRes.pause(); pauseRes.resume(); let file7 = fs.createReadStream(rangeFile, {autoClose: false }); -file7.on('data', function() {}); +file7.on('data', common.noop); file7.on('end', function() { process.nextTick(function() { assert(!file7.closed); @@ -161,13 +161,13 @@ function file7Next() { // Just to make sure autoClose won't close the stream because of error. const file8 = fs.createReadStream(null, {fd: 13337, autoClose: false }); -file8.on('data', function() {}); -file8.on('error', common.mustCall(function() {})); +file8.on('data', common.noop); +file8.on('error', common.mustCall()); // Make sure stream is destroyed when file does not exist. const file9 = fs.createReadStream('/path/to/file/that/does/not/exist'); -file9.on('data', function() {}); -file9.on('error', common.mustCall(function() {})); +file9.on('data', common.noop); +file9.on('error', common.mustCall()); process.on('exit', function() { assert(file7.closed); diff --git a/test/parallel/test-fs-watchfile.js b/test/parallel/test-fs-watchfile.js index fcd28be0c1f126..f583eb8989c06f 100644 --- a/test/parallel/test-fs-watchfile.js +++ b/test/parallel/test-fs-watchfile.js @@ -15,7 +15,7 @@ assert.throws(function() { }, /"watchFile\(\)" requires a listener function/); assert.throws(function() { - fs.watchFile(new Object(), function() {}); + fs.watchFile(new Object(), common.noop); }, /Path must be a string/); const enoentFile = path.join(common.tmpDir, 'non-existent-file'); diff --git a/test/parallel/test-handle-wrap-close-abort.js b/test/parallel/test-handle-wrap-close-abort.js index e9f69195ad29cd..492907ee05540f 100644 --- a/test/parallel/test-handle-wrap-close-abort.js +++ b/test/parallel/test-handle-wrap-close-abort.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../common'); -process.on('uncaughtException', common.mustCall(function() {}, 2)); +process.on('uncaughtException', common.mustCall(common.noop, 2)); setTimeout(function() { process.nextTick(function() { diff --git a/test/parallel/test-http-abort-client.js b/test/parallel/test-http-abort-client.js index 8d3960376761e5..c44681cf9a9884 100644 --- a/test/parallel/test-http-abort-client.js +++ b/test/parallel/test-http-abort-client.js @@ -38,6 +38,6 @@ server.listen(0, common.mustCall(function() { }); // it would be nice if this worked: - res.on('close', common.mustCall(function() {})); + res.on('close', common.mustCall()); })); })); diff --git a/test/parallel/test-http-client-aborted-event.js b/test/parallel/test-http-client-aborted-event.js index 951a128f51b261..a9036a927df1e6 100644 --- a/test/parallel/test-http-client-aborted-event.js +++ b/test/parallel/test-http-client-aborted-event.js @@ -13,6 +13,6 @@ server.listen(0, common.mustCall(function() { headers: { connection: 'keep-alive' } }, common.mustCall(function(res) { server.close(); - res.on('aborted', common.mustCall(function() {})); + res.on('aborted', common.mustCall()); })); })); diff --git a/test/parallel/test-http-invalidheaderfield.js b/test/parallel/test-http-invalidheaderfield.js index aaed46c69cd592..6bae65c86e726f 100644 --- a/test/parallel/test-http-invalidheaderfield.js +++ b/test/parallel/test-http-invalidheaderfield.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const EventEmitter = require('events'); const http = require('http'); @@ -28,7 +28,7 @@ server.listen(0, function() { port: server.address().port, headers: {'testing 123': 123} }; - http.get(options, function() {}); + http.get(options, common.noop); }, function(err) { ee.emit('done'); diff --git a/test/parallel/test-http-pause-resume-one-end.js b/test/parallel/test-http-pause-resume-one-end.js index 6b98246cc271ac..5f5ab4b309e078 100644 --- a/test/parallel/test-http-pause-resume-one-end.js +++ b/test/parallel/test-http-pause-resume-one-end.js @@ -22,6 +22,6 @@ server.listen(0, common.mustCall(function() { }); })); - res.on('end', common.mustCall(function() {})); + res.on('end', common.mustCall()); })); })); diff --git a/test/parallel/test-http-set-timeout-server.js b/test/parallel/test-http-set-timeout-server.js index 8f301af5a9dcc4..314b5f56b2601c 100644 --- a/test/parallel/test-http-set-timeout-server.js +++ b/test/parallel/test-http-set-timeout-server.js @@ -31,7 +31,7 @@ test(function serverTimeout(cb) { // just do nothing, we should get a timeout event. }); server.listen(common.mustCall(function() { - http.get({ port: server.address().port }).on('error', function() {}); + http.get({ port: server.address().port }).on('error', common.noop); })); const s = server.setTimeout(50, function(socket) { caughtTimeout = true; @@ -60,7 +60,7 @@ test(function serverRequestTimeout(cb) { server.listen(common.mustCall(function() { const port = server.address().port; const req = http.request({ port: port, method: 'POST' }); - req.on('error', function() {}); + req.on('error', common.noop); req.write('Hello'); // req is in progress })); @@ -83,7 +83,7 @@ test(function serverResponseTimeout(cb) { }); server.listen(common.mustCall(function() { const port = server.address().port; - http.get({ port: port }).on('error', function() {}); + http.get({ port: port }).on('error', common.noop); })); }); @@ -111,7 +111,7 @@ test(function serverRequestNotTimeoutAfterEnd(cb) { }); server.listen(common.mustCall(function() { const port = server.address().port; - http.get({ port: port }).on('error', function() {}); + http.get({ port: port }).on('error', common.noop); })); }); diff --git a/test/parallel/test-http-upgrade-server.js b/test/parallel/test-http-upgrade-server.js index c641f1576e8703..72c9313b846184 100644 --- a/test/parallel/test-http-upgrade-server.js +++ b/test/parallel/test-http-upgrade-server.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const util = require('util'); @@ -16,7 +16,7 @@ function createTestServer() { } function testServer() { - http.Server.call(this, function() {}); + http.Server.call(this, common.noop); this.on('connection', function() { requests_recv++; diff --git a/test/parallel/test-https-close.js b/test/parallel/test-https-close.js index a9b2a579637408..20f03a591cd992 100644 --- a/test/parallel/test-https-close.js +++ b/test/parallel/test-https-close.js @@ -31,7 +31,7 @@ server.on('connection', function(connection) { }); function shutdown() { - server.close(common.mustCall(function() {})); + server.close(common.mustCall()); for (const key in connections) { connections[key].destroy(); diff --git a/test/parallel/test-net-connect-options-ipv6.js b/test/parallel/test-net-connect-options-ipv6.js index e9d8a78cbbefef..2164f550ce941f 100644 --- a/test/parallel/test-net-connect-options-ipv6.js +++ b/test/parallel/test-net-connect-options-ipv6.js @@ -15,7 +15,7 @@ let localhostTries = 10; const server = net.createServer({allowHalfOpen: true}, function(socket) { socket.resume(); - socket.on('end', common.mustCall(function() {})); + socket.on('end', common.mustCall()); socket.end(); }); diff --git a/test/parallel/test-net-connect-options.js b/test/parallel/test-net-connect-options.js index e794c40859856a..09db7ccea97bfb 100644 --- a/test/parallel/test-net-connect-options.js +++ b/test/parallel/test-net-connect-options.js @@ -7,7 +7,7 @@ const server = net.createServer({ allowHalfOpen: true }, common.mustCall(function(socket) { socket.resume(); - socket.on('end', common.mustCall(function() {})); + socket.on('end', common.mustCall()); socket.end(); })); diff --git a/test/parallel/test-net-listen-close-server-callback-is-not-function.js b/test/parallel/test-net-listen-close-server-callback-is-not-function.js index 243ec038f75aeb..459ca3e5384445 100644 --- a/test/parallel/test-net-listen-close-server-callback-is-not-function.js +++ b/test/parallel/test-net-listen-close-server-callback-is-not-function.js @@ -4,7 +4,7 @@ const net = require('net'); const server = net.createServer(common.mustNotCall()); -server.on('close', common.mustCall(function() {})); +server.on('close', common.mustCall()); server.listen(0, common.mustNotCall()); diff --git a/test/parallel/test-net-socket-destroy-twice.js b/test/parallel/test-net-socket-destroy-twice.js index 749964751b39ad..3763acdf7ce3ed 100644 --- a/test/parallel/test-net-socket-destroy-twice.js +++ b/test/parallel/test-net-socket-destroy-twice.js @@ -11,5 +11,5 @@ conn.on('error', common.mustCall(() => { conn.destroy(); })); -conn.on('close', common.mustCall(function() {})); +conn.on('close', common.mustCall()); server.close(); diff --git a/test/parallel/test-next-tick.js b/test/parallel/test-next-tick.js index 001e8a2e471e03..a57b6444fc9835 100644 --- a/test/parallel/test-next-tick.js +++ b/test/parallel/test-next-tick.js @@ -4,15 +4,15 @@ const assert = require('assert'); process.nextTick(common.mustCall(function() { process.nextTick(common.mustCall(function() { - process.nextTick(common.mustCall(function() {})); + process.nextTick(common.mustCall()); })); })); setTimeout(common.mustCall(function() { - process.nextTick(common.mustCall(function() {})); + process.nextTick(common.mustCall()); }), 50); -process.nextTick(common.mustCall(function() {})); +process.nextTick(common.mustCall()); const obj = {}; diff --git a/test/parallel/test-process-next-tick.js b/test/parallel/test-process-next-tick.js index e67ebae0a29559..383b87a030a0b5 100644 --- a/test/parallel/test-process-next-tick.js +++ b/test/parallel/test-process-next-tick.js @@ -10,7 +10,7 @@ for (let i = 0; i < N; ++i) { process.nextTick(common.mustCall(cb)); } -process.on('uncaughtException', common.mustCall(function() {}, N)); +process.on('uncaughtException', common.mustCall(common.noop, N)); process.on('exit', function() { process.removeAllListeners('uncaughtException'); diff --git a/test/parallel/test-promises-unhandled-rejections.js b/test/parallel/test-promises-unhandled-rejections.js index 87dc743625a0ab..8fe3d46864ee24 100644 --- a/test/parallel/test-promises-unhandled-rejections.js +++ b/test/parallel/test-promises-unhandled-rejections.js @@ -164,7 +164,7 @@ asyncTest('Catching a promise rejection after setImmediate is not' + }); _reject(e); setImmediate(function() { - promise.then(common.fail, function() {}); + promise.then(common.fail, common.noop); }); }); @@ -240,7 +240,7 @@ asyncTest( function(done) { const e = new Error(); onUnhandledFail(done); - Promise.reject(e).then(common.fail, function() {}); + Promise.reject(e).then(common.fail, common.noop); } ); @@ -252,7 +252,7 @@ asyncTest( onUnhandledFail(done); new Promise(function(_, reject) { reject(e); - }).then(common.fail, function() {}); + }).then(common.fail, common.noop); } ); @@ -262,7 +262,7 @@ asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' + onUnhandledFail(done); const promise = Promise.reject(e); process.nextTick(function() { - promise.then(common.fail, function() {}); + promise.then(common.fail, common.noop); }); }); @@ -274,7 +274,7 @@ asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' + reject(e); }); process.nextTick(function() { - promise.then(common.fail, function() {}); + promise.then(common.fail, common.noop); }); }); @@ -385,7 +385,7 @@ asyncTest('Catching the Promise.all() of a collection that includes a' + 'rejected promise prevents unhandledRejection', function(done) { const e = new Error(); onUnhandledFail(done); - Promise.all([Promise.reject(e)]).then(common.fail, function() {}); + Promise.all([Promise.reject(e)]).then(common.fail, common.noop); }); asyncTest( @@ -401,7 +401,7 @@ asyncTest( }); p = Promise.all([p]); process.nextTick(function() { - p.then(common.fail, function() {}); + p.then(common.fail, common.noop); }); } ); @@ -455,7 +455,7 @@ asyncTest('Waiting for some combination of process.nextTick + promise' + Promise.resolve().then(function() { process.nextTick(function() { Promise.resolve().then(function() { - a.catch(function() {}); + a.catch(common.noop); }); }); }); @@ -474,7 +474,7 @@ asyncTest('Waiting for some combination of process.nextTick + promise' + Promise.resolve().then(function() { process.nextTick(function() { Promise.resolve().then(function() { - a.catch(function() {}); + a.catch(common.noop); }); }); }); @@ -494,7 +494,7 @@ asyncTest('Waiting for some combination of process.nextTick + promise ' + Promise.resolve().then(function() { process.nextTick(function() { Promise.resolve().then(function() { - a.catch(function() {}); + a.catch(common.noop); }); }); }); @@ -514,7 +514,7 @@ asyncTest('Waiting for some combination of promise microtasks + ' + process.nextTick(function() { Promise.resolve().then(function() { process.nextTick(function() { - a.catch(function() {}); + a.catch(common.noop); }); }); }); @@ -535,7 +535,7 @@ asyncTest( process.nextTick(function() { Promise.resolve().then(function() { process.nextTick(function() { - a.catch(function() {}); + a.catch(common.noop); }); }); }); @@ -556,7 +556,7 @@ asyncTest('Waiting for some combination of promise microtasks +' + process.nextTick(function() { Promise.resolve().then(function() { process.nextTick(function() { - a.catch(function() {}); + a.catch(common.noop); }); }); }); @@ -575,7 +575,7 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' + let p = Promise.reject(e); setImmediate(function() { Promise.resolve().then(function() { - p.catch(function() {}); + p.catch(common.noop); }); }); }); @@ -592,7 +592,7 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' + Promise.resolve().then(function() { Promise.resolve().then(function() { Promise.resolve().then(function() { - p.catch(function() {}); + p.catch(common.noop); }); }); }); @@ -614,7 +614,7 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' + Promise.resolve().then(function() { Promise.resolve().then(function() { Promise.resolve().then(function() { - p.catch(function() {}); + p.catch(common.noop); }); }); }); @@ -682,7 +682,7 @@ asyncTest('Throwing an error inside a rejectionHandled handler goes to' + const p = Promise.reject(e); setTimeout(function() { try { - p.catch(function() {}); + p.catch(common.noop); } catch (e) { done(new Error('fail')); } diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js index bc28eddd2a8a3a..6b636c337927de 100644 --- a/test/parallel/test-querystring.js +++ b/test/parallel/test-querystring.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); // test using assert @@ -72,7 +72,7 @@ extendedFunction.prototype = {a: 'b'}; const qsWeirdObjects = [ [{regexp: /./g}, 'regexp=', {'regexp': ''}], [{regexp: new RegExp('.', 'g')}, 'regexp=', {'regexp': ''}], - [{fn: function() {}}, 'fn=', {'fn': ''}], + [{fn: common.noop}, 'fn=', {'fn': ''}], [{fn: new Function('')}, 'fn=', {'fn': ''}], [{math: Math}, 'math=', {'math': ''}], [{e: extendedFunction}, 'e=', {'e': ''}], diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index e89da72a6fb738..ddabc20b39026f 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -11,10 +11,10 @@ function FakeInput() { EventEmitter.call(this); } inherits(FakeInput, EventEmitter); -FakeInput.prototype.resume = function() {}; -FakeInput.prototype.pause = function() {}; -FakeInput.prototype.write = function() {}; -FakeInput.prototype.end = function() {}; +FakeInput.prototype.resume = common.noop; +FakeInput.prototype.pause = common.noop; +FakeInput.prototype.write = common.noop; +FakeInput.prototype.end = common.noop; function isWarned(emitter) { for (const name in emitter) { diff --git a/test/parallel/test-regress-GH-5051.js b/test/parallel/test-regress-GH-5051.js index ecaf55d625b815..f0a2d7aa7f1825 100644 --- a/test/parallel/test-regress-GH-5051.js +++ b/test/parallel/test-regress-GH-5051.js @@ -1,11 +1,11 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const agent = require('http').globalAgent; // small stub just so we can call addRequest directly const req = { - getHeader: function() {} + getHeader: common.noop }; agent.maxSockets = 0; diff --git a/test/parallel/test-repl-.save.load.js b/test/parallel/test-repl-.save.load.js index 449dd28e90d59e..283fc142f9650a 100644 --- a/test/parallel/test-repl-.save.load.js +++ b/test/parallel/test-repl-.save.load.js @@ -77,7 +77,7 @@ putIn.write = function(data) { // make sure I get a failed to load message and not some crazy error assert.strictEqual(data, 'Failed to load:' + loadFile + '\n'); // eat me to avoid work - putIn.write = function() {}; + putIn.write = common.noop; }; putIn.run(['.load ' + loadFile]); @@ -86,7 +86,7 @@ loadFile = common.tmpDir; putIn.write = function(data) { assert.strictEqual(data, 'Failed to load:' + loadFile + ' is not a valid file\n'); - putIn.write = function() {}; + putIn.write = common.noop; }; putIn.run(['.load ' + loadFile]); @@ -102,7 +102,7 @@ putIn.write = function(data) { // make sure I get a failed to save message and not some other error assert.strictEqual(data, 'Failed to save:' + invalidFileName + '\n'); // reset to no-op - putIn.write = function() {}; + putIn.write = common.noop; }; // save it to a file diff --git a/test/parallel/test-repl-history-perm.js b/test/parallel/test-repl-history-perm.js index 69b973db2b79bc..4ccb139f6da738 100644 --- a/test/parallel/test-repl-history-perm.js +++ b/test/parallel/test-repl-history-perm.js @@ -19,7 +19,7 @@ const Duplex = require('stream').Duplex; // and mode 600. const stream = new Duplex(); -stream.pause = stream.resume = function() {}; +stream.pause = stream.resume = common.noop; // ends immediately stream._read = function() { this.push(null); diff --git a/test/parallel/test-repl-mode.js b/test/parallel/test-repl-mode.js index 7c113e2fc620c5..cf492a7e4b3f93 100644 --- a/test/parallel/test-repl-mode.js +++ b/test/parallel/test-repl-mode.js @@ -52,7 +52,7 @@ function testAutoMode() { function initRepl(mode) { const input = new Stream(); - input.write = input.pause = input.resume = function() {}; + input.write = input.pause = input.resume = common.noop; input.readable = true; const output = new Stream(); diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 2fc888de67b1f8..6fc9d020185c77 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -200,7 +200,7 @@ function error_test() { { client: client_unix, send: 'blah()', expect: `1\n${prompt_unix}` }, // Functions should not evaluate twice (#2773) - { client: client_unix, send: 'var I = [1,2,3,function() {}]; I.pop()', + { client: client_unix, send: 'var I = [1,2,3,common.noop]; I.pop()', expect: '[Function]' }, // Multiline object { client: client_unix, send: '{ a: ', diff --git a/test/parallel/test-signal-handler.js b/test/parallel/test-signal-handler.js index 004878ac741595..a040d7cc4c2145 100644 --- a/test/parallel/test-signal-handler.js +++ b/test/parallel/test-signal-handler.js @@ -9,7 +9,7 @@ if (common.isWindows) { console.log(`process.pid: ${process.pid}`); -process.on('SIGUSR1', common.mustCall(function() {})); +process.on('SIGUSR1', common.mustCall()); process.on('SIGUSR1', common.mustCall(function() { setTimeout(function() { @@ -31,5 +31,5 @@ setInterval(function() { // has been previously registered, and `process.listeners(SIGNAL).length === 1` process.on('SIGHUP', common.mustNotCall()); process.removeAllListeners('SIGHUP'); -process.on('SIGHUP', common.mustCall(function() {})); +process.on('SIGHUP', common.mustCall()); process.kill(process.pid, 'SIGHUP'); diff --git a/test/parallel/test-stream-big-push.js b/test/parallel/test-stream-big-push.js index 9083820d42b546..849014ad707823 100644 --- a/test/parallel/test-stream-big-push.js +++ b/test/parallel/test-stream-big-push.js @@ -28,7 +28,7 @@ function _read() { r._read = common.mustCall(_read, 3); -r.on('end', common.mustCall(function() {})); +r.on('end', common.mustCall()); // push some data in to start. // we've never gotten any read event at this point. diff --git a/test/parallel/test-stream-end-paused.js b/test/parallel/test-stream-end-paused.js index 4b585fdb999890..007066242b00d1 100644 --- a/test/parallel/test-stream-end-paused.js +++ b/test/parallel/test-stream-end-paused.js @@ -19,7 +19,7 @@ stream.on('data', function() { stream.pause(); setTimeout(common.mustCall(function() { - stream.on('end', common.mustCall(function() {})); + stream.on('end', common.mustCall()); stream.resume(); }), 1); diff --git a/test/parallel/test-stream-events-prepend.js b/test/parallel/test-stream-events-prepend.js index 63d9a32807c5d5..254d9a3690aee5 100644 --- a/test/parallel/test-stream-events-prepend.js +++ b/test/parallel/test-stream-events-prepend.js @@ -23,7 +23,7 @@ Readable.prototype._read = function() { }; const w = new Writable(); -w.on('pipe', common.mustCall(function() {})); +w.on('pipe', common.mustCall()); const r = new Readable(); r.pipe(w); diff --git a/test/parallel/test-stream-pipe-after-end.js b/test/parallel/test-stream-pipe-after-end.js index 79ebb2c0e0990d..fe41d54cabc5f0 100644 --- a/test/parallel/test-stream-pipe-after-end.js +++ b/test/parallel/test-stream-pipe-after-end.js @@ -42,11 +42,11 @@ const piper = new TestReadable(); piper.read(); setTimeout(common.mustCall(function() { - ender.on('end', common.mustCall(function() {})); + ender.on('end', common.mustCall()); const c = ender.read(); assert.strictEqual(c, null); const w = new TestWritable(); - w.on('finish', common.mustCall(function() {})); + w.on('finish', common.mustCall()); piper.pipe(w); }), 1); diff --git a/test/parallel/test-stream-pipe-error-handling.js b/test/parallel/test-stream-pipe-error-handling.js index db79f6e5f36c70..0f6f855a43ae80 100644 --- a/test/parallel/test-stream-pipe-error-handling.js +++ b/test/parallel/test-stream-pipe-error-handling.js @@ -79,11 +79,11 @@ const Stream = require('stream').Stream; }), 1); }); - w.on('error', common.mustCall(function() {})); - w._write = function() {}; + w.on('error', common.mustCall()); + w._write = common.noop; r.pipe(w); // Removing some OTHER random listener should not do anything - w.removeListener('error', function() {}); + w.removeListener('error', common.noop); removed = true; } diff --git a/test/parallel/test-stream-readable-event.js b/test/parallel/test-stream-readable-event.js index 626858ab914857..422c79d1c1b35d 100644 --- a/test/parallel/test-stream-readable-event.js +++ b/test/parallel/test-stream-readable-event.js @@ -19,7 +19,7 @@ const Readable = require('stream').Readable; setTimeout(function() { // we're testing what we think we are assert(!r._readableState.reading); - r.on('readable', common.mustCall(function() {})); + r.on('readable', common.mustCall()); }, 1); } @@ -39,7 +39,7 @@ const Readable = require('stream').Readable; setTimeout(function() { // assert we're testing what we think we are assert(r._readableState.reading); - r.on('readable', common.mustCall(function() {})); + r.on('readable', common.mustCall()); }, 1); } @@ -59,6 +59,6 @@ const Readable = require('stream').Readable; setTimeout(function() { // assert we're testing what we think we are assert(!r._readableState.reading); - r.on('readable', common.mustCall(function() {})); + r.on('readable', common.mustCall()); }, 1); } diff --git a/test/parallel/test-stream-wrap.js b/test/parallel/test-stream-wrap.js index dbcb58a98cd8b2..5312596afac40d 100644 --- a/test/parallel/test-stream-wrap.js +++ b/test/parallel/test-stream-wrap.js @@ -28,4 +28,4 @@ function testShutdown(callback) { req.handle.shutdown(req); } -testShutdown(common.mustCall(function() {})); +testShutdown(common.mustCall()); diff --git a/test/parallel/test-stream2-read-sync-stack.js b/test/parallel/test-stream2-read-sync-stack.js index d4e11af3b8f7c1..314dc375f20b3b 100644 --- a/test/parallel/test-stream2-read-sync-stack.js +++ b/test/parallel/test-stream2-read-sync-stack.js @@ -20,6 +20,6 @@ r.on('readable', function onReadable() { r.read(N * 2); }); -r.on('end', common.mustCall(function() {})); +r.on('end', common.mustCall()); r.read(0); diff --git a/test/parallel/test-stream2-readable-legacy-drain.js b/test/parallel/test-stream2-readable-legacy-drain.js index d6db6ba232c693..ebacbc3939c4f1 100644 --- a/test/parallel/test-stream2-readable-legacy-drain.js +++ b/test/parallel/test-stream2-readable-legacy-drain.js @@ -12,7 +12,7 @@ r._read = function(n) { return r.push(++reads === N ? null : Buffer.allocUnsafe(1)); }; -r.on('end', common.mustCall(function() {})); +r.on('end', common.mustCall()); const w = new Stream(); w.writable = true; @@ -29,7 +29,7 @@ function drain() { w.emit('drain'); } -w.end = common.mustCall(function() {}); +w.end = common.mustCall(); // Just for kicks, let's mess with the drain count. // This verifies that even if it gets negative in the diff --git a/test/parallel/test-stream2-readable-non-empty-end.js b/test/parallel/test-stream2-readable-non-empty-end.js index 46481fe1dcda4c..0df461eb5f2919 100644 --- a/test/parallel/test-stream2-readable-non-empty-end.js +++ b/test/parallel/test-stream2-readable-non-empty-end.js @@ -40,7 +40,7 @@ test.read(0); function next() { // now let's make 'end' happen test.removeListener('end', thrower); - test.on('end', common.mustCall(function() {})); + test.on('end', common.mustCall()); // one to get the last byte let r = test.read(); diff --git a/test/parallel/test-stream2-readable-wrap-empty.js b/test/parallel/test-stream2-readable-wrap-empty.js index 5b2dae3c5327fa..3282f5da6cfae1 100644 --- a/test/parallel/test-stream2-readable-wrap-empty.js +++ b/test/parallel/test-stream2-readable-wrap-empty.js @@ -5,13 +5,13 @@ const Readable = require('_stream_readable'); const EE = require('events').EventEmitter; const oldStream = new EE(); -oldStream.pause = function() {}; -oldStream.resume = function() {}; +oldStream.pause = common.noop; +oldStream.resume = common.noop; const newStream = new Readable().wrap(oldStream); newStream - .on('readable', function() {}) - .on('end', common.mustCall(function() {})); + .on('readable', common.noop) + .on('end', common.mustCall()); oldStream.emit('end'); diff --git a/test/parallel/test-stream2-readable-wrap.js b/test/parallel/test-stream2-readable-wrap.js index aa091dc3d806f0..f7ae81c4ba83b5 100644 --- a/test/parallel/test-stream2-readable-wrap.js +++ b/test/parallel/test-stream2-readable-wrap.js @@ -12,7 +12,7 @@ function runTest(highWaterMark, objectMode, produce) { objectMode: objectMode }); assert.strictEqual(r, r.wrap(old)); - r.on('end', common.mustCall(function() {})); + r.on('end', common.mustCall()); old.pause = function() { old.emit('pause'); diff --git a/test/parallel/test-stream2-writable.js b/test/parallel/test-stream2-writable.js index dd470db9624050..136d4dc3dcef7e 100644 --- a/test/parallel/test-stream2-writable.js +++ b/test/parallel/test-stream2-writable.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const W = require('_stream_writable'); const D = require('_stream_duplex'); const assert = require('assert'); @@ -283,7 +283,7 @@ test('encoding should be ignored for buffers', function(t) { test('writables are not pipable', function(t) { const w = new W(); - w._write = function() {}; + w._write = common.noop; let gotError = false; w.on('error', function() { gotError = true; @@ -295,8 +295,8 @@ test('writables are not pipable', function(t) { test('duplexes are pipable', function(t) { const d = new D(); - d._read = function() {}; - d._write = function() {}; + d._read = common.noop; + d._write = common.noop; let gotError = false; d.on('error', function() { gotError = true; @@ -308,7 +308,7 @@ test('duplexes are pipable', function(t) { test('end(chunk) two times is an error', function(t) { const w = new W(); - w._write = function() {}; + w._write = common.noop; let gotError = false; w.on('error', function(er) { gotError = true; diff --git a/test/parallel/test-timers-uncaught-exception.js b/test/parallel/test-timers-uncaught-exception.js index 4304a984189b81..75d264a1ec86fa 100644 --- a/test/parallel/test-timers-uncaught-exception.js +++ b/test/parallel/test-timers-uncaught-exception.js @@ -10,7 +10,7 @@ setTimeout(common.mustCall(function() { }), 1); // ...but the second one should still run -setTimeout(common.mustCall(function() {}), 1); +setTimeout(common.mustCall(), 1); function uncaughtException(err) { assert.strictEqual(err.message, errorMsg); diff --git a/test/parallel/test-timers-unref-call.js b/test/parallel/test-timers-unref-call.js index 5384441838763a..8dfda0c5a85e39 100644 --- a/test/parallel/test-timers-unref-call.js +++ b/test/parallel/test-timers-unref-call.js @@ -1,11 +1,11 @@ 'use strict'; -require('../common'); +const common = require('../common'); const Timer = process.binding('timer_wrap').Timer; Timer.now = function() { return ++Timer.now.ticks; }; Timer.now.ticks = 0; -const t = setInterval(function() {}, 1); +const t = setInterval(common.noop, 1); const o = { _idleStart: 0, _idleTimeout: 1 }; t.unref.call(o); diff --git a/test/parallel/test-timers-unref-remove-other-unref-timers.js b/test/parallel/test-timers-unref-remove-other-unref-timers.js index 7b4f55abe79a82..221f5bb6fd93ab 100644 --- a/test/parallel/test-timers-unref-remove-other-unref-timers.js +++ b/test/parallel/test-timers-unref-remove-other-unref-timers.js @@ -29,4 +29,4 @@ timers.enroll(foo, 50); timers._unrefActive(foo); // Keep the process open. -setTimeout(function() {}, 100); +setTimeout(common.noop, 100); diff --git a/test/parallel/test-timers-unref.js b/test/parallel/test-timers-unref.js index 2bde08f914d790..aeccacece885a4 100644 --- a/test/parallel/test-timers-unref.js +++ b/test/parallel/test-timers-unref.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); let interval_fired = false; @@ -13,11 +13,11 @@ const LONG_TIME = 10 * 1000; const SHORT_TIME = 100; assert.doesNotThrow(function() { - setTimeout(function() {}, 10).unref().ref().unref(); + setTimeout(common.noop, 10).unref().ref().unref(); }, 'ref and unref are chainable'); assert.doesNotThrow(function() { - setInterval(function() {}, 10).unref().ref().unref(); + setInterval(common.noop, 10).unref().ref().unref(); }, 'ref and unref are chainable'); setInterval(function() { @@ -56,7 +56,7 @@ setInterval(function() { // Should not assert on args.Holder()->InternalFieldCount() > 0. See #4261. { - const t = setInterval(function() {}, 1); + const t = setInterval(common.noop, 1); process.nextTick(t.unref.bind({})); process.nextTick(t.unref.bind(t)); } diff --git a/test/parallel/test-timers-zero-timeout.js b/test/parallel/test-timers-zero-timeout.js index 5d72cfe85fb870..c3edd92260e2db 100644 --- a/test/parallel/test-timers-zero-timeout.js +++ b/test/parallel/test-timers-zero-timeout.js @@ -5,7 +5,7 @@ const assert = require('assert'); // https://github.com/joyent/node/issues/2079 - zero timeout drops extra args { setTimeout(common.mustCall(f), 0, 'foo', 'bar', 'baz'); - setTimeout(function() {}, 0); + setTimeout(common.noop, 0); function f(a, b, c) { assert.strictEqual(a, 'foo'); diff --git a/test/parallel/test-timers.js b/test/parallel/test-timers.js index 7ace816c2ceaeb..daabfcf29ddf19 100644 --- a/test/parallel/test-timers.js +++ b/test/parallel/test-timers.js @@ -56,5 +56,5 @@ setTimeout(common.mustCall(function() { }), 2); // Test 10 ms timeout separately. -setTimeout(common.mustCall(function() {}), 10); +setTimeout(common.mustCall(), 10); setInterval(common.mustCall(function() { clearInterval(this); }), 10); diff --git a/test/parallel/test-tls-cert-regression.js b/test/parallel/test-tls-cert-regression.js index ff5827bcf844ee..3cf7423b7d9807 100644 --- a/test/parallel/test-tls-cert-regression.js +++ b/test/parallel/test-tls-cert-regression.js @@ -42,5 +42,5 @@ function test(cert, key, cb) { } test(cert, key, common.mustCall(function() { - test(Buffer.from(cert), Buffer.from(key), common.mustCall(function() {})); + test(Buffer.from(cert), Buffer.from(key), common.mustCall()); })); diff --git a/test/parallel/test-tls-connect-simple.js b/test/parallel/test-tls-connect-simple.js index f169773c77a26e..84cbe633eda7c8 100644 --- a/test/parallel/test-tls-connect-simple.js +++ b/test/parallel/test-tls-connect-simple.js @@ -18,8 +18,8 @@ const options = { const server = tls.Server(options, common.mustCall(function(socket) { if (++serverConnected === 2) { - server.close(common.mustCall(function() {})); - server.on('close', common.mustCall(function() {})); + server.close(common.mustCall()); + server.on('close', common.mustCall()); } }, 2)); diff --git a/test/parallel/test-tls-connect.js b/test/parallel/test-tls-connect.js index 082e2e48a9dcc0..0a6af35e7d1f5a 100644 --- a/test/parallel/test-tls-connect.js +++ b/test/parallel/test-tls-connect.js @@ -20,7 +20,7 @@ const path = require('path'); const options = {cert: cert, key: key, port: common.PORT}; const conn = tls.connect(options, common.fail); - conn.on('error', common.mustCall(function() {})); + conn.on('error', common.mustCall()); } // SSL_accept/SSL_connect error handling @@ -37,5 +37,5 @@ const path = require('path'); assert.ok(false); // callback should never be executed }); - conn.on('error', common.mustCall(function() {})); + conn.on('error', common.mustCall()); } diff --git a/test/parallel/test-tls-delayed-attach-error.js b/test/parallel/test-tls-delayed-attach-error.js index c7b6bf33127a5e..35da6d0e42efed 100644 --- a/test/parallel/test-tls-delayed-attach-error.js +++ b/test/parallel/test-tls-delayed-attach-error.js @@ -23,7 +23,7 @@ const server = net.createServer(common.mustCall(function(c) { secureContext: tls.createSecureContext(options) }); - s.on('_tlsError', common.mustCall(function() {})); + s.on('_tlsError', common.mustCall()); s.on('close', function() { server.close(); diff --git a/test/parallel/test-tls-env-extra-ca.js b/test/parallel/test-tls-env-extra-ca.js index 8c561d921cb802..4580f1579f6213 100644 --- a/test/parallel/test-tls-env-extra-ca.js +++ b/test/parallel/test-tls-env-extra-ca.js @@ -16,7 +16,7 @@ const fs = require('fs'); if (process.env.CHILD) { const copts = { port: process.env.PORT, - checkServerIdentity: function() {}, + checkServerIdentity: common.noop, }; const client = tls.connect(copts, function() { client.end('hi'); diff --git a/test/parallel/test-tls-invoke-queued.js b/test/parallel/test-tls-invoke-queued.js index 08053e026249e6..2a8037c8d74119 100644 --- a/test/parallel/test-tls-invoke-queued.js +++ b/test/parallel/test-tls-invoke-queued.js @@ -21,7 +21,7 @@ const server = tls.createServer({ c._write('world!', null, function() { c.destroy(); }); - c._write(' gosh', null, function() {}); + c._write(' gosh', null, common.noop); }); server.close(); diff --git a/test/parallel/test-tls-legacy-onselect.js b/test/parallel/test-tls-legacy-onselect.js index 9af65c43a0661c..6540639cc93e7c 100644 --- a/test/parallel/test-tls-legacy-onselect.js +++ b/test/parallel/test-tls-legacy-onselect.js @@ -10,7 +10,7 @@ const net = require('net'); const server = net.Server(common.mustCall(function(raw) { const pair = tls.createSecurePair(null, true, false, false); - pair.on('error', function() {}); + pair.on('error', common.noop); pair.ssl.setSNICallback(common.mustCall(function() { raw.destroy(); server.close(); diff --git a/test/parallel/test-tls-passphrase.js b/test/parallel/test-tls-passphrase.js index f2f6f5ccdacda8..f8fc4c9313d9da 100644 --- a/test/parallel/test-tls-passphrase.js +++ b/test/parallel/test-tls-passphrase.js @@ -39,14 +39,14 @@ server.listen(0, common.mustCall(function() { passphrase: 'passphrase', cert: cert, rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, key: rawKey, cert: cert, rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, @@ -54,7 +54,7 @@ server.listen(0, common.mustCall(function() { passphrase: 'ignored', cert: cert, rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); // Buffer[] tls.connect({ @@ -63,14 +63,14 @@ server.listen(0, common.mustCall(function() { passphrase: 'passphrase', cert: [cert], rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, key: [rawKey], cert: [cert], rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, @@ -78,7 +78,7 @@ server.listen(0, common.mustCall(function() { passphrase: 'ignored', cert: [cert], rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); // string tls.connect({ @@ -87,14 +87,14 @@ server.listen(0, common.mustCall(function() { passphrase: 'passphrase', cert: cert.toString(), rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, key: rawKey.toString(), cert: cert.toString(), rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, @@ -102,7 +102,7 @@ server.listen(0, common.mustCall(function() { passphrase: 'ignored', cert: cert.toString(), rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); // String[] tls.connect({ @@ -111,14 +111,14 @@ server.listen(0, common.mustCall(function() { passphrase: 'passphrase', cert: [cert.toString()], rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, key: [rawKey.toString()], cert: [cert.toString()], rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, @@ -126,7 +126,7 @@ server.listen(0, common.mustCall(function() { passphrase: 'ignored', cert: [cert.toString()], rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); // Object[] tls.connect({ @@ -134,7 +134,7 @@ server.listen(0, common.mustCall(function() { key: [{pem: passKey, passphrase: 'passphrase'}], cert: cert, rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, @@ -142,7 +142,7 @@ server.listen(0, common.mustCall(function() { passphrase: 'ignored', cert: cert, rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, @@ -150,28 +150,28 @@ server.listen(0, common.mustCall(function() { passphrase: 'passphrase', cert: cert, rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, key: [{pem: passKey.toString(), passphrase: 'passphrase'}], cert: cert, rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, key: [{pem: rawKey, passphrase: 'ignored'}], cert: cert, rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, key: [{pem: rawKey.toString(), passphrase: 'ignored'}], cert: cert, rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, @@ -179,7 +179,7 @@ server.listen(0, common.mustCall(function() { passphrase: 'ignored', cert: cert, rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, @@ -187,21 +187,21 @@ server.listen(0, common.mustCall(function() { passphrase: 'ignored', cert: cert, rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, key: [{pem: rawKey}], cert: cert, rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); tls.connect({ port: this.address().port, key: [{pem: rawKey.toString()}], cert: cert, rejectUnauthorized: false - }, common.mustCall(function() {})); + }, common.mustCall()); })).unref(); const errMessagePassword = /bad password read/; diff --git a/test/parallel/test-url.js b/test/parallel/test-url.js index 4e123305b5fddb..251557f8ac98af 100644 --- a/test/parallel/test-url.js +++ b/test/parallel/test-url.js @@ -1,6 +1,6 @@ /* eslint-disable max-len */ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const url = require('url'); @@ -1684,7 +1684,7 @@ const throws = [ true, false, 0, - function() {} + common.noop ]; for (let i = 0; i < throws.length; i++) { assert.throws(function() { url.format(throws[i]); }, TypeError); diff --git a/test/parallel/test-util.js b/test/parallel/test-util.js index 3b7e78ea1e464e..867cae95935caf 100644 --- a/test/parallel/test-util.js +++ b/test/parallel/test-util.js @@ -12,7 +12,7 @@ assert.strictEqual(true, util.isArray(new Array(5))); assert.strictEqual(true, util.isArray(new Array('with', 'some', 'entries'))); assert.strictEqual(true, util.isArray(context('Array')())); assert.strictEqual(false, util.isArray({})); -assert.strictEqual(false, util.isArray({ push: function() {} })); +assert.strictEqual(false, util.isArray({ push: common.noop })); assert.strictEqual(false, util.isArray(/regexp/)); assert.strictEqual(false, util.isArray(new Error())); assert.strictEqual(false, util.isArray(Object.create(Array.prototype))); @@ -61,7 +61,7 @@ assert.strictEqual(false, util.isPrimitive(new Error())); assert.strictEqual(false, util.isPrimitive(new Date())); assert.strictEqual(false, util.isPrimitive([])); assert.strictEqual(false, util.isPrimitive(/regexp/)); -assert.strictEqual(false, util.isPrimitive(function() {})); +assert.strictEqual(false, util.isPrimitive(common.noop)); assert.strictEqual(false, util.isPrimitive(new Number(1))); assert.strictEqual(false, util.isPrimitive(new String('bla'))); assert.strictEqual(false, util.isPrimitive(new Boolean(true))); @@ -117,7 +117,7 @@ assert.strictEqual(util.isSymbol(), false); assert.strictEqual(util.isSymbol('string'), false); assert.strictEqual(util.isFunction(() => {}), true); -assert.strictEqual(util.isFunction(function() {}), true); +assert.strictEqual(util.isFunction(common.noop), true); assert.strictEqual(util.isFunction(), false); assert.strictEqual(util.isFunction('string'), false); diff --git a/test/parallel/test-vm-function-declaration.js b/test/parallel/test-vm-function-declaration.js index c2aff80f02b524..ff594644c68de0 100644 --- a/test/parallel/test-vm-function-declaration.js +++ b/test/parallel/test-vm-function-declaration.js @@ -7,7 +7,7 @@ const o = vm.createContext({ console: console }); // Function declaration and expression should both be copied to the // sandboxed context. -let code = 'var a = function() {};\n'; +let code = 'var a = function () {};\n'; code += 'function b(){}\n'; // Grab the global b function as the completion value, to ensure that diff --git a/test/parallel/test-zlib-close-after-write.js b/test/parallel/test-zlib-close-after-write.js index d25ccfe381f113..8977fd36add703 100644 --- a/test/parallel/test-zlib-close-after-write.js +++ b/test/parallel/test-zlib-close-after-write.js @@ -5,5 +5,5 @@ const zlib = require('zlib'); zlib.gzip('hello', common.mustCall(function(err, out) { const unzip = zlib.createGunzip(); unzip.write(out); - unzip.close(common.mustCall(function() {})); + unzip.close(common.mustCall()); })); diff --git a/test/parallel/test-zlib-write-after-close.js b/test/parallel/test-zlib-write-after-close.js index fdad1708c81ff0..e169a06639917f 100644 --- a/test/parallel/test-zlib-write-after-close.js +++ b/test/parallel/test-zlib-write-after-close.js @@ -5,6 +5,6 @@ const zlib = require('zlib'); zlib.gzip('hello', common.mustCall(function(err, out) { const unzip = zlib.createGunzip(); - unzip.close(common.mustCall(function() {})); + unzip.close(common.mustCall()); assert.throws(() => unzip.write(out), /^Error: zlib binding closed$/); })); diff --git a/test/parallel/test-zlib-zero-byte.js b/test/parallel/test-zlib-zero-byte.js index cd4cf41f98ac07..95b75e739fd115 100644 --- a/test/parallel/test-zlib-zero-byte.js +++ b/test/parallel/test-zlib-zero-byte.js @@ -13,6 +13,6 @@ gz.on('data', function(c) { gz.on('end', common.mustCall(function() { assert.strictEqual(received, 20); })); -gz.on('finish', common.mustCall(function() {})); +gz.on('finish', common.mustCall()); gz.write(emptyBuffer); gz.end(); diff --git a/test/pummel/test-http-client-reconnect-bug.js b/test/pummel/test-http-client-reconnect-bug.js index ae29a11fa83d49..cb376fe3dac49c 100644 --- a/test/pummel/test-http-client-reconnect-bug.js +++ b/test/pummel/test-http-client-reconnect-bug.js @@ -11,7 +11,7 @@ server.on('listening', common.mustCall(function() { const client = http.createClient(common.PORT); client.on('error', common.mustCall(function(err) {})); - client.on('end', common.mustCall(function() {})); + client.on('end', common.mustCall()); const request = client.request('GET', '/', {'host': 'localhost'}); request.end(); diff --git a/test/pummel/test-net-connect-memleak.js b/test/pummel/test-net-connect-memleak.js index f16034e4773510..6799b412b693a0 100644 --- a/test/pummel/test-net-connect-memleak.js +++ b/test/pummel/test-net-connect-memleak.js @@ -10,7 +10,7 @@ assert.strictEqual( 'function', 'Run this test with --expose-gc' ); -net.createServer(function() {}).listen(common.PORT); +net.createServer(common.noop).listen(common.PORT); let before = 0; { diff --git a/test/pummel/test-stream2-basic.js b/test/pummel/test-stream2-basic.js index 46cc2f63086fbe..d15030cd9d94d9 100644 --- a/test/pummel/test-stream2-basic.js +++ b/test/pummel/test-stream2-basic.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const R = require('_stream_readable'); const assert = require('assert'); @@ -451,7 +451,7 @@ test('adding readable triggers data flow', function(t) { test('chainable', function(t) { const r = new R(); - r._read = function() {}; + r._read = common.noop; const r2 = r.setEncoding('utf8').pause().resume().pause(); t.equal(r, r2); t.end(); diff --git a/test/sequential/test-child-process-pass-fd.js b/test/sequential/test-child-process-pass-fd.js index 404ae854a15953..2d05407e67b99f 100644 --- a/test/sequential/test-child-process-pass-fd.js +++ b/test/sequential/test-child-process-pass-fd.js @@ -45,7 +45,7 @@ if (process.argv[2] !== 'child') { // the only thing keeping this worker alive will be IPC. This is important, // because it means a worker with no parent will have no referenced handles, // thus no work to do, and will exit immediately, preventing process leaks. - process.on('message', function() {}); + process.on('message', common.noop); const server = net.createServer((c) => { process.once('message', function(msg) { diff --git a/test/sequential/test-fs-watch.js b/test/sequential/test-fs-watch.js index 1780099eba4f9b..b99e86a7e65e4f 100644 --- a/test/sequential/test-fs-watch.js +++ b/test/sequential/test-fs-watch.js @@ -117,7 +117,7 @@ assert.throws(function() { oldhandle.close(); // clean up assert.throws(function() { - const w = fs.watchFile(__filename, {persistent: false}, function() {}); + const w = fs.watchFile(__filename, {persistent: false}, common.noop); oldhandle = w._handle; w._handle = { stop: w._handle.stop }; w.stop(); diff --git a/test/sequential/test-https-set-timeout-server.js b/test/sequential/test-https-set-timeout-server.js index 6c7afa5df9b304..b1a597e34de345 100644 --- a/test/sequential/test-https-set-timeout-server.js +++ b/test/sequential/test-https-set-timeout-server.js @@ -48,7 +48,7 @@ test(function serverTimeout(cb) { https.get({ port: this.address().port, rejectUnauthorized: false - }).on('error', function() {}); + }).on('error', common.noop); })); }); @@ -69,7 +69,7 @@ test(function serverRequestTimeout(cb) { method: 'POST', rejectUnauthorized: false }); - req.on('error', function() {}); + req.on('error', common.noop); req.write('Hello'); // req is in progress }); @@ -90,7 +90,7 @@ test(function serverResponseTimeout(cb) { https.get({ port: this.address().port, rejectUnauthorized: false - }).on('error', function() {}); + }).on('error', common.noop); }); }); @@ -110,7 +110,7 @@ test(function serverRequestNotTimeoutAfterEnd(cb) { https.get({ port: this.address().port, rejectUnauthorized: false - }).on('error', function() {}); + }).on('error', common.noop); }); });