Browse Source

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 <fishrock123@rocketmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
v6.x
James M Snell 8 years ago
committed by Myles Borins
parent
commit
a7b94500f2
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 2
      test/addons/async-hello-world/test.js
  2. 16
      test/common/index.js
  3. 4
      test/debugger/test-debugger-client.js
  4. 3
      test/parallel/test-assert.js
  5. 2
      test/parallel/test-child-process-disconnect.js
  6. 4
      test/parallel/test-child-process-kill.js
  7. 4
      test/parallel/test-child-process-stdin.js
  8. 4
      test/parallel/test-cluster-eaccess.js
  9. 2
      test/parallel/test-cluster-setup-master-emit.js
  10. 4
      test/parallel/test-cluster-worker-destroy.js
  11. 2
      test/parallel/test-cluster-worker-wait-server-close.js
  12. 4
      test/parallel/test-common.js
  13. 2
      test/parallel/test-crypto-random.js
  14. 2
      test/parallel/test-dgram-close-is-not-callback.js
  15. 4
      test/parallel/test-dgram-close.js
  16. 2
      test/parallel/test-dgram-send-empty-buffer.js
  17. 6
      test/parallel/test-domain-crypto.js
  18. 2
      test/parallel/test-domain-exit-dispose.js
  19. 2
      test/parallel/test-domain-timers.js
  20. 4
      test/parallel/test-domain.js
  21. 2
      test/parallel/test-env-var-no-warnings.js
  22. 32
      test/parallel/test-event-emitter-check-listener-leaks.js
  23. 6
      test/parallel/test-event-emitter-get-max-listeners.js
  24. 10
      test/parallel/test-event-emitter-listener-count.js
  25. 4
      test/parallel/test-event-emitter-max-listeners-warning-for-null.js
  26. 4
      test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js
  27. 6
      test/parallel/test-event-emitter-max-listeners-warning.js
  28. 2
      test/parallel/test-event-emitter-max-listeners.js
  29. 2
      test/parallel/test-event-emitter-once.js
  30. 6
      test/parallel/test-event-emitter-remove-all-listeners.js
  31. 4
      test/parallel/test-event-emitter-subclass.js
  32. 2
      test/parallel/test-event-emitter-symbols.js
  33. 2
      test/parallel/test-fs-mkdir.js
  34. 12
      test/parallel/test-fs-read-stream-inherit.js
  35. 10
      test/parallel/test-fs-read-stream.js
  36. 2
      test/parallel/test-fs-watchfile.js
  37. 2
      test/parallel/test-handle-wrap-close-abort.js
  38. 2
      test/parallel/test-http-abort-client.js
  39. 2
      test/parallel/test-http-client-aborted-event.js
  40. 4
      test/parallel/test-http-invalidheaderfield.js
  41. 2
      test/parallel/test-http-pause-resume-one-end.js
  42. 8
      test/parallel/test-http-set-timeout-server.js
  43. 4
      test/parallel/test-http-upgrade-server.js
  44. 2
      test/parallel/test-https-close.js
  45. 2
      test/parallel/test-net-connect-options-ipv6.js
  46. 2
      test/parallel/test-net-connect-options.js
  47. 2
      test/parallel/test-net-listen-close-server-callback-is-not-function.js
  48. 2
      test/parallel/test-net-socket-destroy-twice.js
  49. 6
      test/parallel/test-next-tick.js
  50. 2
      test/parallel/test-process-next-tick.js
  51. 34
      test/parallel/test-promises-unhandled-rejections.js
  52. 4
      test/parallel/test-querystring.js
  53. 8
      test/parallel/test-readline-interface.js
  54. 4
      test/parallel/test-regress-GH-5051.js
  55. 6
      test/parallel/test-repl-.save.load.js
  56. 2
      test/parallel/test-repl-history-perm.js
  57. 2
      test/parallel/test-repl-mode.js
  58. 2
      test/parallel/test-repl.js
  59. 4
      test/parallel/test-signal-handler.js
  60. 2
      test/parallel/test-stream-big-push.js
  61. 2
      test/parallel/test-stream-end-paused.js
  62. 2
      test/parallel/test-stream-events-prepend.js
  63. 4
      test/parallel/test-stream-pipe-after-end.js
  64. 6
      test/parallel/test-stream-pipe-error-handling.js
  65. 6
      test/parallel/test-stream-readable-event.js
  66. 2
      test/parallel/test-stream-wrap.js
  67. 2
      test/parallel/test-stream2-read-sync-stack.js
  68. 4
      test/parallel/test-stream2-readable-legacy-drain.js
  69. 2
      test/parallel/test-stream2-readable-non-empty-end.js
  70. 8
      test/parallel/test-stream2-readable-wrap-empty.js
  71. 2
      test/parallel/test-stream2-readable-wrap.js
  72. 10
      test/parallel/test-stream2-writable.js
  73. 2
      test/parallel/test-timers-uncaught-exception.js
  74. 4
      test/parallel/test-timers-unref-call.js
  75. 2
      test/parallel/test-timers-unref-remove-other-unref-timers.js
  76. 8
      test/parallel/test-timers-unref.js
  77. 2
      test/parallel/test-timers-zero-timeout.js
  78. 2
      test/parallel/test-timers.js
  79. 2
      test/parallel/test-tls-cert-regression.js
  80. 4
      test/parallel/test-tls-connect-simple.js
  81. 4
      test/parallel/test-tls-connect.js
  82. 2
      test/parallel/test-tls-delayed-attach-error.js
  83. 2
      test/parallel/test-tls-env-extra-ca.js
  84. 2
      test/parallel/test-tls-invoke-queued.js
  85. 2
      test/parallel/test-tls-legacy-onselect.js
  86. 44
      test/parallel/test-tls-passphrase.js
  87. 4
      test/parallel/test-url.js
  88. 6
      test/parallel/test-util.js
  89. 2
      test/parallel/test-vm-function-declaration.js
  90. 2
      test/parallel/test-zlib-close-after-write.js
  91. 2
      test/parallel/test-zlib-write-after-close.js
  92. 2
      test/parallel/test-zlib-zero-byte.js
  93. 2
      test/pummel/test-http-client-reconnect-bug.js
  94. 2
      test/pummel/test-net-connect-memleak.js
  95. 4
      test/pummel/test-stream2-basic.js
  96. 2
      test/sequential/test-child-process-pass-fd.js
  97. 2
      test/sequential/test-fs-watch.js
  98. 8
      test/sequential/test-https-set-timeout-server.js

2
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());
}));

16
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,

4
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++;

3
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 }');

2
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) {

4
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);

4
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);

4
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

2
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());
}));

4
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) {

2
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() {

4
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\/$/);

2
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) {

2
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());
}));

4
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

2
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);
}));

6
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);

2
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

2
test/parallel/test-domain-timers.js

@ -32,4 +32,4 @@ immediated.run(function() {
});
});
timeout = setTimeout(function() {}, 10 * 1000);
timeout = setTimeout(common.noop, 10 * 1000);

4
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() {

2
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' });

32
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

6
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);

10
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);

4
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);

4
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);

6
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.

2
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);

2
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');

6
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);

4
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);

2
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]);

2
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);

12
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);

10
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);

2
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');

2
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() {

2
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());
}));
}));

2
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());
}));
}));

4
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');

2
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());
}));
}));

8
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);
}));
});

4
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++;

2
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();

2
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();
});

2
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();
}));

2
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());

2
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();

6
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 = {};

2
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');

34
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'));
}

4
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': ''}],

8
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) {

4
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;

6
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

2
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);

2
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();

2
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: ',

4
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');

2
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.

2
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);

2
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);

4
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);

6
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;
}

6
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);
}

2
test/parallel/test-stream-wrap.js

@ -28,4 +28,4 @@ function testShutdown(callback) {
req.handle.shutdown(req);
}
testShutdown(common.mustCall(function() {}));
testShutdown(common.mustCall());

2
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);

4
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

2
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();

8
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');

2
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');

10
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;

2
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);

4
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);

2
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);

8
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));
}

2
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');

2
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);

2
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());
}));

4
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));

4
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());
}

2
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();

2
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');

2
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();

2
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();

44
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/;

4
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);

6
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);

2
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

2
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());
}));

2
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$/);
}));

2
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();

2
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();

2
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;
{

4
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();

2
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) {

2
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();

8
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);
});
});

Loading…
Cancel
Save