diff --git a/test/common/README.md b/test/common/README.md index f418115ce3..0502cacaf6 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -209,7 +209,7 @@ Gets IP of localhost Array of IPV6 hosts. ### mustCall([fn][, exact]) -* `fn` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) default = `common.noop` +* `fn` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) default = () => {} * `exact` [<Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) default = 1 * return [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) @@ -217,10 +217,10 @@ Returns a function that calls `fn`. If the returned function has not been called exactly `expected` number of times when the test is complete, then the test will fail. -If `fn` is not provided, `common.noop` will be used. +If `fn` is not provided, an empty function will be used. ### mustCallAtLeast([fn][, minimum]) -* `fn` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) default = `common.noop` +* `fn` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) default = () => {} * `minimum` [<Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) default = 1 * return [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) @@ -228,7 +228,7 @@ Returns a function that calls `fn`. If the returned function has not been called at least `minimum` number of times when the test is complete, then the test will fail. -If `fn` is not provided, `common.noop` will be used. +If `fn` is not provided, an empty function will be used. ### mustNotCall([msg]) * `msg` [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) default = 'function should not have been called' @@ -243,19 +243,6 @@ Returns a function that triggers an `AssertionError` if it is invoked. `msg` is 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, `false` otherwise. -### noop - -A non-op `Function` that can be used for a variety of scenarios. - -For instance, - - -```js -const common = require('../common'); - -someAsyncAPI('foo', common.mustCall(common.noop)); -``` - ### opensslCli * return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) diff --git a/test/common/index.js b/test/common/index.js index 5c820211d7..e3e53f4574 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -37,7 +37,6 @@ const testRoot = process.env.NODE_TEST_DIR ? const noop = () => {}; -exports.noop = noop; exports.fixturesDir = path.join(__dirname, '..', 'fixtures'); exports.tmpDirName = 'tmp'; // PORT should match the definition in test/testpy/__init__.py. diff --git a/test/message/unhandled_promise_trace_warnings.js b/test/message/unhandled_promise_trace_warnings.js index 8aad957fb5..48450fb21e 100644 --- a/test/message/unhandled_promise_trace_warnings.js +++ b/test/message/unhandled_promise_trace_warnings.js @@ -1,5 +1,5 @@ // Flags: --trace-warnings 'use strict'; -const common = require('../common'); +require('../common'); const p = Promise.reject(new Error('This was rejected')); -setImmediate(() => p.catch(common.noop)); +setImmediate(() => p.catch(() => {})); diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 0054705df4..382123ef87 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -571,29 +571,30 @@ a.throws(makeBlock(a.deepEqual, args, [])); // check messages from assert.throws() { + const noop = () => {}; assert.throws( - () => { a.throws(common.noop); }, + () => { a.throws((noop)); }, common.expectsError({ code: 'ERR_ASSERTION', message: /^Missing expected exception\.$/ })); assert.throws( - () => { a.throws(common.noop, TypeError); }, + () => { a.throws(noop, TypeError); }, common.expectsError({ code: 'ERR_ASSERTION', message: /^Missing expected exception \(TypeError\)\.$/ })); assert.throws( - () => { a.throws(common.noop, 'fhqwhgads'); }, + () => { a.throws(noop, 'fhqwhgads'); }, common.expectsError({ code: 'ERR_ASSERTION', message: /^Missing expected exception: fhqwhgads$/ })); assert.throws( - () => { a.throws(common.noop, TypeError, 'fhqwhgads'); }, + () => { a.throws(noop, TypeError, 'fhqwhgads'); }, common.expectsError({ code: 'ERR_ASSERTION', message: /^Missing expected exception \(TypeError\): fhqwhgads$/ diff --git a/test/parallel/test-buffer-includes.js b/test/parallel/test-buffer-includes.js index 9ce9578b3a..a114ad264e 100644 --- a/test/parallel/test-buffer-includes.js +++ b/test/parallel/test-buffer-includes.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const b = Buffer.from('abcdef'); @@ -274,7 +274,7 @@ for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) { const expectedError = /^TypeError: "val" argument must be string, number, Buffer or Uint8Array$/; assert.throws(() => { - b.includes(common.noop); + b.includes(() => {}); }, expectedError); assert.throws(() => { b.includes({}); diff --git a/test/parallel/test-child-process-bad-stdio.js b/test/parallel/test-child-process-bad-stdio.js index 2e06f4e2b1..45294d7d82 100644 --- a/test/parallel/test-child-process-bad-stdio.js +++ b/test/parallel/test-child-process-bad-stdio.js @@ -5,7 +5,7 @@ const assert = require('assert'); const cp = require('child_process'); if (process.argv[2] === 'child') { - setTimeout(common.noop, common.platformTimeout(100)); + setTimeout(() => {}, common.platformTimeout(100)); return; } diff --git a/test/parallel/test-child-process-spawnsync-kill-signal.js b/test/parallel/test-child-process-spawnsync-kill-signal.js index 90d6225223..73063e7f38 100644 --- a/test/parallel/test-child-process-spawnsync-kill-signal.js +++ b/test/parallel/test-child-process-spawnsync-kill-signal.js @@ -5,7 +5,7 @@ const assert = require('assert'); const cp = require('child_process'); if (process.argv[2] === 'child') { - setInterval(common.noop, 1000); + setInterval(() => {}, 1000); } else { const internalCp = require('internal/child_process'); const oldSpawnSync = internalCp.spawnSync; diff --git a/test/parallel/test-cluster-rr-domain-listen.js b/test/parallel/test-cluster-rr-domain-listen.js index 4b511d0d20..45e1200a3d 100644 --- a/test/parallel/test-cluster-rr-domain-listen.js +++ b/test/parallel/test-cluster-rr-domain-listen.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -const common = require('../common'); +require('../common'); const cluster = require('cluster'); const domain = require('domain'); @@ -29,10 +29,10 @@ const domain = require('domain'); if (cluster.isWorker) { const d = domain.create(); - d.run(common.noop); + d.run(() => {}); const http = require('http'); - http.Server(common.noop).listen(0, '127.0.0.1'); + http.Server(() => {}).listen(0, '127.0.0.1'); } else if (cluster.isMaster) { diff --git a/test/parallel/test-cluster-worker-wait-server-close.js b/test/parallel/test-cluster-worker-wait-server-close.js index a563d52beb..b8183afb06 100644 --- a/test/parallel/test-cluster-worker-wait-server-close.js +++ b/test/parallel/test-cluster-worker-wait-server-close.js @@ -11,7 +11,7 @@ if (cluster.isWorker) { const server = net.createServer(function(socket) { // Wait for any data, then close connection socket.write('.'); - socket.on('data', common.noop); + socket.on('data', () => {}); }).listen(0, common.localhostIPv4); server.once('close', function() { @@ -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(common.noop, 9999); + const keepOpen = setInterval(() => {}, 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 47ed7d9f31..819cd81553 100644 --- a/test/parallel/test-common.js +++ b/test/parallel/test-common.js @@ -101,7 +101,7 @@ const HIJACK_TEST_ARRAY = [ 'foo\n', 'bar\n', 'baz\n' ]; assert.notStrictEqual(originalWrite, stream.write); HIJACK_TEST_ARRAY.forEach((val) => { - stream.write(val, common.mustCall(common.noop)); + stream.write(val, common.mustCall()); }); assert.strictEqual(HIJACK_TEST_ARRAY.length, stream.writeTimes); diff --git a/test/parallel/test-console-instance.js b/test/parallel/test-console-instance.js index 1e68de3f6e..20ac2ceb72 100644 --- a/test/parallel/test-console-instance.js +++ b/test/parallel/test-console-instance.js @@ -49,7 +49,7 @@ assert.throws( // Console constructor should throw if stderr exists but is not writable assert.throws( () => { - out.write = common.noop; + out.write = () => {}; err.write = undefined; new Console(out, err); }, diff --git a/test/parallel/test-event-emitter-get-max-listeners.js b/test/parallel/test-event-emitter-get-max-listeners.js index 98ac02e871..43f9f0cebc 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'; -const common = require('../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', common.noop); -EventEmitter.prototype.on.call(recv, 'event', common.noop); +EventEmitter.prototype.on.call(recv, 'event', () => {}); +EventEmitter.prototype.on.call(recv, 'event', () => {}); diff --git a/test/parallel/test-event-emitter-listener-count.js b/test/parallel/test-event-emitter-listener-count.js index 50247f4277..117d38f575 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'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const EventEmitter = require('events'); const emitter = new EventEmitter(); -emitter.on('foo', common.noop); -emitter.on('foo', common.noop); -emitter.on('baz', common.noop); +emitter.on('foo', () => {}); +emitter.on('foo', () => {}); +emitter.on('baz', () => {}); // Allow any type -emitter.on(123, common.noop); +emitter.on(123, () => {}); 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 c8a904b9bb..2929e1c709 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, common.noop); -e.on(null, common.noop); +e.on(null, () => {}); +e.on(null, () => {}); 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 551c1276b8..51c31ba0cf 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, common.noop); -e.on(symbol, common.noop); +e.on(symbol, () => {}); +e.on(symbol, () => {}); diff --git a/test/parallel/test-event-emitter-max-listeners-warning.js b/test/parallel/test-event-emitter-max-listeners-warning.js index 1a4a1b8bf2..0be7fc84bc 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', common.noop); -e.on('event-type', common.noop); // Trigger warning. -e.on('event-type', common.noop); // Verify that warning is emitted only once. +e.on('event-type', () => {}); +e.on('event-type', () => {}); // Trigger warning. +e.on('event-type', () => {}); // Verify that warning is emitted only once. diff --git a/test/parallel/test-event-emitter-remove-listeners.js b/test/parallel/test-event-emitter-remove-listeners.js index 01ed014135..d1c01e0bc3 100644 --- a/test/parallel/test-event-emitter-remove-listeners.js +++ b/test/parallel/test-event-emitter-remove-listeners.js @@ -140,7 +140,7 @@ function listener2() {} { const ee = new EventEmitter(); - assert.deepStrictEqual(ee, ee.removeListener('foo', common.noop)); + assert.deepStrictEqual(ee, ee.removeListener('foo', () => {})); } // Verify that the removed listener must be a function @@ -152,7 +152,7 @@ assert.throws(() => { { const ee = new EventEmitter(); - const listener = common.noop; + const listener = () => {}; ee._events = undefined; const e = ee.removeListener('foo', listener); assert.strictEqual(e, ee); diff --git a/test/parallel/test-event-emitter-special-event-names.js b/test/parallel/test-event-emitter-special-event-names.js index 116cdfcc16..7ff781f0f9 100644 --- a/test/parallel/test-event-emitter-special-event-names.js +++ b/test/parallel/test-event-emitter-special-event-names.js @@ -5,7 +5,7 @@ const EventEmitter = require('events'); const assert = require('assert'); const ee = new EventEmitter(); -const handler = common.noop; +const handler = () => {}; assert.deepStrictEqual(ee.eventNames(), []); diff --git a/test/parallel/test-event-emitter-subclass.js b/test/parallel/test-event-emitter-subclass.js index 00ebd1e356..5189c3aa13 100644 --- a/test/parallel/test-event-emitter-subclass.js +++ b/test/parallel/test-event-emitter-subclass.js @@ -62,6 +62,6 @@ MyEE2.prototype = new EventEmitter(); const ee1 = new MyEE2(); const ee2 = new MyEE2(); -ee1.on('x', common.noop); +ee1.on('x', () => {}); assert.strictEqual(ee2.listenerCount('x'), 0); diff --git a/test/parallel/test-events-list.js b/test/parallel/test-events-list.js index 5d2e8c019a..4e589b07f2 100644 --- a/test/parallel/test-events-list.js +++ b/test/parallel/test-events-list.js @@ -5,7 +5,6 @@ const EventEmitter = require('events'); const assert = require('assert'); const EE = new EventEmitter(); -// Do not use common.noop here, these need to be separate listener functions const m = () => {}; EE.on('foo', () => {}); assert.deepStrictEqual(['foo'], EE.eventNames()); diff --git a/test/parallel/test-fs-buffertype-writesync.js b/test/parallel/test-fs-buffertype-writesync.js index 02d2cb58f8..73a6f21189 100644 --- a/test/parallel/test-fs-buffertype-writesync.js +++ b/test/parallel/test-fs-buffertype-writesync.js @@ -9,7 +9,7 @@ const fs = require('fs'); const path = require('path'); const filePath = path.join(common.tmpDir, 'test_buffer_type'); -const v = [true, false, 0, 1, Infinity, common.noop, {}, [], undefined, null]; +const v = [true, false, 0, 1, Infinity, () => {}, {}, [], undefined, null]; common.refreshTmpDir(); diff --git a/test/parallel/test-fs-mkdir.js b/test/parallel/test-fs-mkdir.js index 17a945c975..679e0b255a 100644 --- a/test/parallel/test-fs-mkdir.js +++ b/test/parallel/test-fs-mkdir.js @@ -77,4 +77,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(common.noop); +process.nextTick(() => {}); diff --git a/test/parallel/test-handle-wrap-isrefed.js b/test/parallel/test-handle-wrap-isrefed.js index c027b6f2d1..66353fcc03 100644 --- a/test/parallel/test-handle-wrap-isrefed.js +++ b/test/parallel/test-handle-wrap-isrefed.js @@ -87,7 +87,7 @@ const strictEqual = require('assert').strictEqual; // tcp { const net = require('net'); - const server = net.createServer(common.noop).listen(0); + const server = net.createServer(() => {}).listen(0); strictEqual(Object.getPrototypeOf(server._handle).hasOwnProperty('hasRef'), true, 'tcp_wrap: hasRef() missing'); strictEqual(server._handle.hasRef(), @@ -112,7 +112,7 @@ const strictEqual = require('assert').strictEqual; // timers { - const timer = setTimeout(common.noop, 500); + const timer = setTimeout(() => {}, 500); timer.unref(); strictEqual(Object.getPrototypeOf(timer._handle).hasOwnProperty('hasRef'), true, 'timer_wrap: hasRef() missing'); diff --git a/test/parallel/test-http-client-defaults.js b/test/parallel/test-http-client-defaults.js index 57ac0e99d6..43419d1dfd 100644 --- a/test/parallel/test-http-client-defaults.js +++ b/test/parallel/test-http-client-defaults.js @@ -1,23 +1,23 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const ClientRequest = require('http').ClientRequest; { - const req = new ClientRequest({ createConnection: common.noop }); + const req = new ClientRequest({ createConnection: () => {} }); assert.strictEqual(req.path, '/'); assert.strictEqual(req.method, 'GET'); } { - const req = new ClientRequest({ method: '', createConnection: common.noop }); + const req = new ClientRequest({ method: '', createConnection: () => {} }); assert.strictEqual(req.path, '/'); assert.strictEqual(req.method, 'GET'); } { - const req = new ClientRequest({ path: '', createConnection: common.noop }); + const req = new ClientRequest({ path: '', createConnection: () => {} }); assert.strictEqual(req.path, '/'); assert.strictEqual(req.method, 'GET'); } diff --git a/test/parallel/test-http-parser-bad-ref.js b/test/parallel/test-http-parser-bad-ref.js index 70c6a1e515..6e9fb2f9ac 100644 --- a/test/parallel/test-http-parser-bad-ref.js +++ b/test/parallel/test-http-parser-bad-ref.js @@ -4,7 +4,7 @@ // Flags: --expose_gc -const common = require('../common'); +require('../common'); const assert = require('assert'); const HTTPParser = process.binding('http_parser').HTTPParser; @@ -39,7 +39,7 @@ function demoBug(part1, part2) { console.log('url', info.url); }; - parser[kOnBody] = common.noop; + parser[kOnBody] = () => {}; parser[kOnMessageComplete] = function() { messagesComplete++; diff --git a/test/parallel/test-http-upgrade-server.js b/test/parallel/test-http-upgrade-server.js index 11c0aba5b4..3b91afc03f 100644 --- a/test/parallel/test-http-upgrade-server.js +++ b/test/parallel/test-http-upgrade-server.js @@ -21,7 +21,7 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const util = require('util'); @@ -38,7 +38,7 @@ function createTestServer() { } function testServer() { - http.Server.call(this, common.noop); + http.Server.call(this, () => {}); this.on('connection', function() { requests_recv++; diff --git a/test/parallel/test-https-close.js b/test/parallel/test-https-close.js index e32e253147..4c4dea577c 100644 --- a/test/parallel/test-https-close.js +++ b/test/parallel/test-https-close.js @@ -49,7 +49,7 @@ server.listen(0, function() { }; const req = https.request(requestOptions, function(res) { - res.on('data', common.noop); + res.on('data', () => {}); setImmediate(shutdown); }); req.end(); diff --git a/test/parallel/test-https-socket-options.js b/test/parallel/test-https-socket-options.js index 3718d3809c..d6f6aaae7a 100644 --- a/test/parallel/test-https-socket-options.js +++ b/test/parallel/test-https-socket-options.js @@ -58,7 +58,7 @@ server_http.listen(0, function() { }); // These methods should exist on the request and get passed down to the socket req.setNoDelay(true); - req.setTimeout(1000, common.noop); + req.setTimeout(1000, () => {}); req.setSocketKeepAlive(true, 1000); req.end(); }); @@ -82,7 +82,7 @@ server_https.listen(0, function() { }); // These methods should exist on the request and get passed down to the socket req.setNoDelay(true); - req.setTimeout(1000, common.noop); + req.setTimeout(1000, () => {}); req.setSocketKeepAlive(true, 1000); req.end(); }); diff --git a/test/parallel/test-instanceof.js b/test/parallel/test-instanceof.js index c3d4ece42a..658f1e29c7 100644 --- a/test/parallel/test-instanceof.js +++ b/test/parallel/test-instanceof.js @@ -1,11 +1,11 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); // Regression test for instanceof, see // https://github.com/nodejs/node/issues/7592 -const F = common.noop; +const F = () => {}; F.prototype = {}; assert(Object.create(F.prototype) instanceof F); diff --git a/test/parallel/test-net-listen-exclusive-random-ports.js b/test/parallel/test-net-listen-exclusive-random-ports.js index 9ca023cfa4..00d5e73cb1 100644 --- a/test/parallel/test-net-listen-exclusive-random-ports.js +++ b/test/parallel/test-net-listen-exclusive-random-ports.js @@ -1,6 +1,6 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const cluster = require('cluster'); const net = require('net'); @@ -20,7 +20,7 @@ if (cluster.isMaster) { }); }); } else { - const server = net.createServer(common.noop); + const server = net.createServer(() => {}); server.on('error', function(err) { process.send(err.code); diff --git a/test/parallel/test-net-options-lookup.js b/test/parallel/test-net-options-lookup.js index c61f338b70..f0e8b34c80 100644 --- a/test/parallel/test-net-options-lookup.js +++ b/test/parallel/test-net-options-lookup.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const net = require('net'); @@ -20,7 +20,7 @@ function connectThrows(input) { }, expectedError); } -connectDoesNotThrow(common.noop); +connectDoesNotThrow(() => {}); function connectDoesNotThrow(input) { const opts = { diff --git a/test/parallel/test-net-socket-timeout.js b/test/parallel/test-net-socket-timeout.js index 0319e18173..de4a7ed37c 100644 --- a/test/parallel/test-net-socket-timeout.js +++ b/test/parallel/test-net-socket-timeout.js @@ -27,7 +27,7 @@ const assert = require('assert'); // Verify that invalid delays throw const s = new net.Socket(); const nonNumericDelays = [ - '100', true, false, undefined, null, '', {}, common.noop, [] + '100', true, false, undefined, null, '', {}, () => {}, [] ]; const badRangeDelays = [-0.001, -1, -Infinity, Infinity, NaN]; const validDelays = [0, 0.001, 1, 1e6]; @@ -35,19 +35,19 @@ const validDelays = [0, 0.001, 1, 1e6]; for (let i = 0; i < nonNumericDelays.length; i++) { assert.throws(function() { - s.setTimeout(nonNumericDelays[i], common.noop); + s.setTimeout(nonNumericDelays[i], () => {}); }, TypeError); } for (let i = 0; i < badRangeDelays.length; i++) { assert.throws(function() { - s.setTimeout(badRangeDelays[i], common.noop); + s.setTimeout(badRangeDelays[i], () => {}); }, RangeError); } for (let i = 0; i < validDelays.length; i++) { assert.doesNotThrow(function() { - s.setTimeout(validDelays[i], common.noop); + s.setTimeout(validDelays[i], () => {}); }); } diff --git a/test/parallel/test-net-stream.js b/test/parallel/test-net-stream.js index 1eb984936c..4690cf7c90 100644 --- a/test/parallel/test-net-stream.js +++ b/test/parallel/test-net-stream.js @@ -21,7 +21,7 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const net = require('net'); @@ -54,7 +54,7 @@ const server = net.createServer(function(socket) { }); for (let i = 0; i < N; ++i) { - socket.write(buf, common.noop); + socket.write(buf, () => {}); } socket.end(); diff --git a/test/parallel/test-no-enter-tickcallback.js b/test/parallel/test-no-enter-tickcallback.js index 34c7eb8e08..aab22c5f3e 100644 --- a/test/parallel/test-no-enter-tickcallback.js +++ b/test/parallel/test-no-enter-tickcallback.js @@ -27,6 +27,6 @@ setImmediate(common.mustCall(() => { require('domain'); setImmediate(common.mustCall(() => setImmediate(common.mustCall(() => { allsGood = true; - process.nextTick(common.noop); + process.nextTick(() => {}); })))); })); diff --git a/test/parallel/test-process-getactiverequests.js b/test/parallel/test-process-getactiverequests.js index 2885eb8613..f55f298298 100644 --- a/test/parallel/test-process-getactiverequests.js +++ b/test/parallel/test-process-getactiverequests.js @@ -1,10 +1,10 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const fs = require('fs'); for (let i = 0; i < 12; i++) - fs.open(__filename, 'r', common.noop); + fs.open(__filename, 'r', () => {}); assert.strictEqual(12, process._getActiveRequests().length); diff --git a/test/parallel/test-promises-warning-on-unhandled-rejection.js b/test/parallel/test-promises-warning-on-unhandled-rejection.js index f3c7a8771e..10f95162a0 100644 --- a/test/parallel/test-promises-warning-on-unhandled-rejection.js +++ b/test/parallel/test-promises-warning-on-unhandled-rejection.js @@ -26,4 +26,4 @@ process.on('warning', common.mustCall((warning) => { }, 3)); const p = Promise.reject('This was rejected'); -setImmediate(common.mustCall(() => p.catch(common.noop))); +setImmediate(common.mustCall(() => p.catch(() => {}))); diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index 5d77119cdd..9acfb5421d 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -34,10 +34,10 @@ function FakeInput() { EventEmitter.call(this); } inherits(FakeInput, EventEmitter); -FakeInput.prototype.resume = common.noop; -FakeInput.prototype.pause = common.noop; -FakeInput.prototype.write = common.noop; -FakeInput.prototype.end = common.noop; +FakeInput.prototype.resume = () => {}; +FakeInput.prototype.pause = () => {}; +FakeInput.prototype.write = () => {}; +FakeInput.prototype.end = () => {}; function isWarned(emitter) { for (const name in emitter) { diff --git a/test/parallel/test-readline-keys.js b/test/parallel/test-readline-keys.js index 6b46874f72..1b05b06f58 100644 --- a/test/parallel/test-readline-keys.js +++ b/test/parallel/test-readline-keys.js @@ -298,7 +298,7 @@ const runKeyIntervalTests = [ { name: 'escape', sequence: '\x1b', meta: true }, { name: 'escape', sequence: '\x1b', meta: true } ]) -].reverse().reduce((acc, fn) => fn(acc), common.noop); +].reverse().reduce((acc, fn) => fn(acc), () => {}); // run key interval tests one after another runKeyIntervalTests(); diff --git a/test/parallel/test-regress-GH-4948.js b/test/parallel/test-regress-GH-4948.js index bdf60e2e53..5ec79b8685 100644 --- a/test/parallel/test-regress-GH-4948.js +++ b/test/parallel/test-regress-GH-4948.js @@ -1,7 +1,7 @@ 'use strict'; // https://github.com/joyent/node/issues/4948 -const common = require('../common'); +require('../common'); const http = require('http'); let reqCount = 0; @@ -22,10 +22,10 @@ const server = http.createServer(function(serverReq, serverRes) { serverRes.end(); // required for test to fail - res.on('data', common.noop); + res.on('data', () => {}); }); - r.on('error', common.noop); + r.on('error', () => {}); r.end(); serverRes.write('some data'); diff --git a/test/parallel/test-regress-GH-5051.js b/test/parallel/test-regress-GH-5051.js index f0a2d7aa7f..0fef879c6f 100644 --- a/test/parallel/test-regress-GH-5051.js +++ b/test/parallel/test-regress-GH-5051.js @@ -1,11 +1,11 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const agent = require('http').globalAgent; // small stub just so we can call addRequest directly const req = { - getHeader: common.noop + getHeader: () => {} }; agent.maxSockets = 0; diff --git a/test/parallel/test-repl-function-definition-edge-case.js b/test/parallel/test-repl-function-definition-edge-case.js index 90234eb131..1e3063e3db 100644 --- a/test/parallel/test-repl-function-definition-edge-case.js +++ b/test/parallel/test-repl-function-definition-edge-case.js @@ -19,7 +19,7 @@ assert.strictEqual(got, expected); function initRepl() { const input = new stream(); - input.write = input.pause = input.resume = common.noop; + input.write = input.pause = input.resume = () => {}; input.readable = true; const output = new stream(); diff --git a/test/parallel/test-repl-history-perm.js b/test/parallel/test-repl-history-perm.js index ebca7c9725..1a98999c3b 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 = common.noop; +stream.pause = stream.resume = () => {}; // 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 cf492a7e4b..5606200859 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 = common.noop; + input.write = input.pause = input.resume = () => {}; input.readable = true; const output = new Stream(); diff --git a/test/parallel/test-repl-save-load.js b/test/parallel/test-repl-save-load.js index 746f6f2b6c..4ef2a63354 100644 --- a/test/parallel/test-repl-save-load.js +++ b/test/parallel/test-repl-save-load.js @@ -98,7 +98,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 = common.noop; + putIn.write = () => {}; }; putIn.run([`.load ${loadFile}`]); @@ -106,7 +106,7 @@ putIn.run([`.load ${loadFile}`]); loadFile = common.tmpDir; putIn.write = function(data) { assert.strictEqual(data, `Failed to load:${loadFile} is not a valid file\n`); - putIn.write = common.noop; + putIn.write = () => {}; }; putIn.run([`.load ${loadFile}`]); @@ -122,7 +122,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 = common.noop; + putIn.write = () => {}; }; // save it to a file diff --git a/test/parallel/test-repl-tab-complete-crash.js b/test/parallel/test-repl-tab-complete-crash.js index fe9c157366..ba8de7888e 100644 --- a/test/parallel/test-repl-tab-complete-crash.js +++ b/test/parallel/test-repl-tab-complete-crash.js @@ -4,7 +4,7 @@ const common = require('../common'); const assert = require('assert'); const repl = require('repl'); -common.ArrayStream.prototype.write = common.noop; +common.ArrayStream.prototype.write = () => {}; const putIn = new common.ArrayStream(); const testMe = repl.start('', putIn); diff --git a/test/parallel/test-stream-decoder-objectmode.js b/test/parallel/test-stream-decoder-objectmode.js index b536fbc4e8..4c572fed6b 100644 --- a/test/parallel/test-stream-decoder-objectmode.js +++ b/test/parallel/test-stream-decoder-objectmode.js @@ -1,11 +1,11 @@ 'use strict'; -const common = require('../common'); +require('../common'); const stream = require('stream'); const assert = require('assert'); const readable = new stream.Readable({ - read: common.noop, + read: () => {}, encoding: 'utf16le', objectMode: true }); diff --git a/test/parallel/test-stream-duplex.js b/test/parallel/test-stream-duplex.js index f0c8a47a50..1cc54db052 100644 --- a/test/parallel/test-stream-duplex.js +++ b/test/parallel/test-stream-duplex.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const Duplex = require('stream').Duplex; @@ -38,7 +38,7 @@ stream._write = (obj, _, cb) => { cb(); }; -stream._read = common.noop; +stream._read = () => {}; stream.on('data', (obj) => { read = obj; diff --git a/test/parallel/test-stream-pipe-await-drain.js b/test/parallel/test-stream-pipe-await-drain.js index b90a9d0edd..5bdf480084 100644 --- a/test/parallel/test-stream-pipe-await-drain.js +++ b/test/parallel/test-stream-pipe-await-drain.js @@ -15,7 +15,7 @@ const writer3 = new stream.Writable(); // See: https://github.com/nodejs/node/issues/5820 const buffer = Buffer.allocUnsafe(560000); -reader._read = common.noop; +reader._read = () => {}; writer1._write = common.mustCall(function(chunk, encoding, cb) { this.emit('chunk-received'); diff --git a/test/parallel/test-stream-pipe-cleanup-pause.js b/test/parallel/test-stream-pipe-cleanup-pause.js index 2f3754de3e..3cdab94648 100644 --- a/test/parallel/test-stream-pipe-cleanup-pause.js +++ b/test/parallel/test-stream-pipe-cleanup-pause.js @@ -11,7 +11,7 @@ const writer2 = new stream.Writable(); // See: https://github.com/nodejs/node/issues/2323 const buffer = Buffer.allocUnsafe(560000); -reader._read = common.noop; +reader._read = () => {}; writer1._write = common.mustCall(function(chunk, encoding, cb) { this.emit('chunk-received'); diff --git a/test/parallel/test-stream-pipe-error-handling.js b/test/parallel/test-stream-pipe-error-handling.js index e7eca593e7..e725465e07 100644 --- a/test/parallel/test-stream-pipe-error-handling.js +++ b/test/parallel/test-stream-pipe-error-handling.js @@ -101,10 +101,10 @@ const Stream = require('stream').Stream; }); w.on('error', common.mustCall()); - w._write = common.noop; + w._write = () => {}; r.pipe(w); // Removing some OTHER random listener should not do anything - w.removeListener('error', common.noop); + w.removeListener('error', () => {}); removed = true; } diff --git a/test/parallel/test-stream-pipe-multiple-pipes.js b/test/parallel/test-stream-pipe-multiple-pipes.js index d89dcbd947..890c274b9d 100644 --- a/test/parallel/test-stream-pipe-multiple-pipes.js +++ b/test/parallel/test-stream-pipe-multiple-pipes.js @@ -4,7 +4,7 @@ const stream = require('stream'); const assert = require('assert'); const readable = new stream.Readable({ - read: common.noop + read: () => {} }); const writables = []; diff --git a/test/parallel/test-stream-pipe-unpipe-streams.js b/test/parallel/test-stream-pipe-unpipe-streams.js index 067b7f4482..916bd2cdfa 100644 --- a/test/parallel/test-stream-pipe-unpipe-streams.js +++ b/test/parallel/test-stream-pipe-unpipe-streams.js @@ -4,9 +4,9 @@ const assert = require('assert'); const { Readable, Writable } = require('stream'); -const source = Readable({read: common.noop}); -const dest1 = Writable({write: common.noop}); -const dest2 = Writable({write: common.noop}); +const source = Readable({read: () => {}}); +const dest1 = Writable({write: () => {}}); +const dest2 = Writable({write: () => {}}); source.pipe(dest1); source.pipe(dest2); diff --git a/test/parallel/test-stream-readable-emittedReadable.js b/test/parallel/test-stream-readable-emittedReadable.js index 82d8b645ef..65b6b5b15a 100644 --- a/test/parallel/test-stream-readable-emittedReadable.js +++ b/test/parallel/test-stream-readable-emittedReadable.js @@ -4,7 +4,7 @@ const assert = require('assert'); const Readable = require('stream').Readable; const readable = new Readable({ - read: common.noop + read: () => {} }); // Initialized to false. @@ -37,7 +37,7 @@ process.nextTick(common.mustCall(() => { })); const noRead = new Readable({ - read: common.noop + read: () => {} }); noRead.on('readable', common.mustCall(() => { @@ -52,7 +52,7 @@ noRead.push('foo'); noRead.push(null); const flowing = new Readable({ - read: common.noop + read: () => {} }); flowing.on('data', common.mustCall(() => { diff --git a/test/parallel/test-stream-readable-invalid-chunk.js b/test/parallel/test-stream-readable-invalid-chunk.js index 990154144a..f528dfe693 100644 --- a/test/parallel/test-stream-readable-invalid-chunk.js +++ b/test/parallel/test-stream-readable-invalid-chunk.js @@ -1,11 +1,11 @@ 'use strict'; -const common = require('../common'); +require('../common'); const stream = require('stream'); const assert = require('assert'); const readable = new stream.Readable({ - read: common.noop + read: () => {} }); const errMessage = /Invalid non-string\/buffer chunk/; diff --git a/test/parallel/test-stream-readable-needReadable.js b/test/parallel/test-stream-readable-needReadable.js index dba188c572..be397dc5dc 100644 --- a/test/parallel/test-stream-readable-needReadable.js +++ b/test/parallel/test-stream-readable-needReadable.js @@ -4,7 +4,7 @@ const assert = require('assert'); const Readable = require('stream').Readable; const readable = new Readable({ - read: common.noop + read: () => {} }); // Initialized to false. @@ -28,7 +28,7 @@ readable.on('end', common.mustCall(() => { })); const asyncReadable = new Readable({ - read: common.noop + read: () => {} }); asyncReadable.on('readable', common.mustCall(() => { @@ -51,7 +51,7 @@ process.nextTick(common.mustCall(() => { })); const flowing = new Readable({ - read: common.noop + read: () => {} }); // Notice this must be above the on('data') call. @@ -69,7 +69,7 @@ flowing.on('data', common.mustCall(function(data) { }, 3)); const slowProducer = new Readable({ - read: common.noop + read: () => {} }); slowProducer.on('readable', common.mustCall(() => { diff --git a/test/parallel/test-stream-readableListening-state.js b/test/parallel/test-stream-readableListening-state.js index 84e09aabca..5e3071faf3 100644 --- a/test/parallel/test-stream-readableListening-state.js +++ b/test/parallel/test-stream-readableListening-state.js @@ -5,7 +5,7 @@ const assert = require('assert'); const stream = require('stream'); const r = new stream.Readable({ - read: common.noop + read: () => {} }); // readableListening state should start in `false`. @@ -19,7 +19,7 @@ r.on('readable', common.mustCall(() => { r.push(Buffer.from('Testing readableListening state')); const r2 = new stream.Readable({ - read: common.noop + read: () => {} }); // readableListening state should start in `false`. diff --git a/test/parallel/test-stream2-pipe-error-once-listener.js b/test/parallel/test-stream2-pipe-error-once-listener.js index de65c2469e..71ce19b360 100644 --- a/test/parallel/test-stream2-pipe-error-once-listener.js +++ b/test/parallel/test-stream2-pipe-error-once-listener.js @@ -21,7 +21,7 @@ 'use strict'; -const common = require('../common'); +require('../common'); const util = require('util'); const stream = require('stream'); @@ -50,7 +50,7 @@ Write.prototype._write = function(buffer, encoding, cb) { const read = new Read(); const write = new Write(); -write.once('error', common.noop); +write.once('error', () => {}); write.once('alldone', function(err) { console.log('ok'); }); diff --git a/test/parallel/test-stream2-readable-wrap-empty.js b/test/parallel/test-stream2-readable-wrap-empty.js index 39bc509a39..1489717f3e 100644 --- a/test/parallel/test-stream2-readable-wrap-empty.js +++ b/test/parallel/test-stream2-readable-wrap-empty.js @@ -26,13 +26,13 @@ const Readable = require('_stream_readable'); const EE = require('events').EventEmitter; const oldStream = new EE(); -oldStream.pause = common.noop; -oldStream.resume = common.noop; +oldStream.pause = () => {}; +oldStream.resume = () => {}; const newStream = new Readable().wrap(oldStream); newStream - .on('readable', common.noop) + .on('readable', () => {}) .on('end', common.mustCall()); oldStream.emit('end'); diff --git a/test/parallel/test-timers-unref-call.js b/test/parallel/test-timers-unref-call.js index 45263f6178..0015318c4b 100644 --- a/test/parallel/test-timers-unref-call.js +++ b/test/parallel/test-timers-unref-call.js @@ -1,12 +1,12 @@ 'use strict'; -const common = require('../common'); +require('../common'); const Timer = process.binding('timer_wrap').Timer; Timer.now = function() { return ++Timer.now.ticks; }; Timer.now.ticks = 0; -const t = setInterval(common.noop, 1); +const t = setInterval(() => {}, 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 221f5bb6fd..84dd75025d 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(common.noop, 100); +setTimeout(() => {}, 100); diff --git a/test/parallel/test-timers-unref.js b/test/parallel/test-timers-unref.js index f0d0a27536..7f66a364e3 100644 --- a/test/parallel/test-timers-unref.js +++ b/test/parallel/test-timers-unref.js @@ -21,7 +21,7 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); let interval_fired = false; @@ -35,11 +35,11 @@ const LONG_TIME = 10 * 1000; const SHORT_TIME = 100; assert.doesNotThrow(function() { - setTimeout(common.noop, 10).unref().ref().unref(); + setTimeout(() => {}, 10).unref().ref().unref(); }, 'ref and unref are chainable'); assert.doesNotThrow(function() { - setInterval(common.noop, 10).unref().ref().unref(); + setInterval(() => {}, 10).unref().ref().unref(); }, 'ref and unref are chainable'); setInterval(function() { @@ -78,7 +78,7 @@ setInterval(function() { // Should not assert on args.Holder()->InternalFieldCount() > 0. See #4261. { - const t = setInterval(common.noop, 1); + const t = setInterval(() => {}, 1); process.nextTick(t.unref.bind({})); process.nextTick(t.unref.bind(t)); } diff --git a/test/parallel/test-timers-unrefed-in-beforeexit.js b/test/parallel/test-timers-unrefed-in-beforeexit.js index 487a4ecef5..530d97674d 100644 --- a/test/parallel/test-timers-unrefed-in-beforeexit.js +++ b/test/parallel/test-timers-unrefed-in-beforeexit.js @@ -1,6 +1,6 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); let once = 0; @@ -9,7 +9,7 @@ process.on('beforeExit', () => { if (once > 1) throw new RangeError('beforeExit should only have been called once!'); - setTimeout(common.noop, 1).unref(); + setTimeout(() => {}, 1).unref(); once++; }); diff --git a/test/parallel/test-timers-zero-timeout.js b/test/parallel/test-timers-zero-timeout.js index 4e1eefb40d..7feb01854e 100644 --- a/test/parallel/test-timers-zero-timeout.js +++ b/test/parallel/test-timers-zero-timeout.js @@ -26,7 +26,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(common.noop, 0); + setTimeout(() => {}, 0); function f(a, b, c) { assert.strictEqual(a, 'foo'); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 2d05a55e2c..3b3b93dc00 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -785,9 +785,9 @@ if (typeof Symbol !== 'undefined') { const rejected = Promise.reject(3); assert.strictEqual(util.inspect(rejected), 'Promise { 3 }'); // squelch UnhandledPromiseRejection - rejected.catch(common.noop); + rejected.catch(() => {}); - const pending = new Promise(common.noop); + const pending = new Promise(() => {}); assert.strictEqual(util.inspect(pending), 'Promise { }'); const promiseWithProperty = Promise.resolve('foo'); @@ -885,7 +885,7 @@ if (typeof Symbol !== 'undefined') { 'SetSubclass { 1, 2, 3 }'); assert.strictEqual(util.inspect(new MapSubclass([['foo', 42]])), 'MapSubclass { \'foo\' => 42 }'); - assert.strictEqual(util.inspect(new PromiseSubclass(common.noop)), + assert.strictEqual(util.inspect(new PromiseSubclass(() => {})), 'PromiseSubclass { }'); } diff --git a/test/parallel/test-vm-sigint-existing-handler.js b/test/parallel/test-vm-sigint-existing-handler.js index 9bd5d33879..cbd91bef06 100644 --- a/test/parallel/test-vm-sigint-existing-handler.js +++ b/test/parallel/test-vm-sigint-existing-handler.js @@ -44,7 +44,7 @@ if (process.argv[2] === 'child') { assert.strictEqual(onceHandlerCalled, 0); // Keep the process alive for a while so that the second SIGINT can be caught. - const timeout = setTimeout(common.noop, 1000); + const timeout = setTimeout(() => {}, 1000); let afterHandlerCalled = 0; diff --git a/test/parallel/test-whatwg-url-parsing.js b/test/parallel/test-whatwg-url-parsing.js index 0e8f3b6d77..6c95a5e913 100644 --- a/test/parallel/test-whatwg-url-parsing.js +++ b/test/parallel/test-whatwg-url-parsing.js @@ -23,7 +23,7 @@ const failureTests = tests.filter((test) => test.failure).concat([ { input: null }, { input: new Date() }, { input: new RegExp() }, - { input: common.noop } + { input: () => {} } ]); const expectedError = common.expectsError( diff --git a/test/pseudo-tty/ref_keeps_node_running.js b/test/pseudo-tty/ref_keeps_node_running.js index 7eb2d1a60a..7832e9ee21 100644 --- a/test/pseudo-tty/ref_keeps_node_running.js +++ b/test/pseudo-tty/ref_keeps_node_running.js @@ -1,6 +1,6 @@ 'use strict'; -const common = require('../common'); +require('../common'); const { TTY, isTTY } = process.binding('tty_wrap'); const strictEqual = require('assert').strictEqual; @@ -9,7 +9,7 @@ strictEqual(isTTY(0), true, 'fd 0 is not a TTY'); const handle = new TTY(0); handle.readStart(); -handle.onread = common.noop; +handle.onread = () => {}; function isHandleActive(handle) { return process._getActiveHandles().some((active) => active === handle);