From 688e5ed6fd9aee2ecab576282dfd131db0a4711e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 3 May 2017 21:07:54 -0700 Subject: [PATCH] test: remove common.noop This change removes `common.noop` from the Node.js internal testing common module. Over the last few weeks, I've grown to dislike the `common.noop` abstraction. First, new (and experienced) contributors are unaware of it and so it results in a large number of low-value nits on PRs. It also increases the number of things newcomers and infrequent contributors have to be aware of to be effective on the project. Second, it is confusing. Is it a singleton/property or a getter? Which should be expected? This can lead to subtle and hard-to-find bugs. (To my knowledge, none have landed on master. But I also think it's only a matter of time.) Third, the abstraction is low-value in my opinion. What does it really get us? A case could me made that it is without value at all. Lastly, and this is minor, but the abstraction is wordier than not using the abstraction. `common.noop` doesn't save anything over `() => {}`. So, I propose removing it. PR-URL: https://github.com/nodejs/node/pull/12822 Backport-PR-URL: https://github.com/nodejs/node/pull/14174 Reviewed-By: Anna Henningsen Reviewed-By: Refael Ackermann --- test/common/README.md | 21 +++--------- test/common/index.js | 1 - test/debugger/test-debugger-client.js | 4 +-- test/parallel/test-assert.js | 4 +-- .../parallel/test-cluster-rr-domain-listen.js | 4 +-- .../test-cluster-worker-wait-server-close.js | 4 +-- test/parallel/test-common.js | 4 +-- test/parallel/test-crypto-random.js | 2 +- test/parallel/test-env-var-no-warnings.js | 2 +- ...test-event-emitter-check-listener-leaks.js | 32 ++++++++--------- .../test-event-emitter-get-max-listeners.js | 6 ++-- .../test-event-emitter-listener-count.js | 10 +++--- ...-emitter-max-listeners-warning-for-null.js | 4 +-- ...mitter-max-listeners-warning-for-symbol.js | 4 +-- ...est-event-emitter-max-listeners-warning.js | 6 ++-- ...test-event-emitter-remove-all-listeners.js | 6 ++-- test/parallel/test-event-emitter-subclass.js | 2 +- test/parallel/test-fs-buffertype-writesync.js | 2 +- test/parallel/test-fs-mkdir.js | 2 +- test/parallel/test-fs-read-stream-inherit.js | 6 ++-- test/parallel/test-fs-read-stream.js | 6 ++-- test/parallel/test-handle-wrap-close-abort.js | 2 +- test/parallel/test-http-parser-bad-ref.js | 2 +- test/parallel/test-http-upgrade-server.js | 5 +-- test/parallel/test-https-close.js | 2 +- .../parallel/test-https-set-timeout-server.js | 4 +-- test/parallel/test-https-socket-options.js | 4 +-- test/parallel/test-instanceof.js | 4 +++ .../test-net-listen-exclusive-random-ports.js | 5 ++- test/parallel/test-net-options-lookup.js | 2 +- test/parallel/test-net-socket-timeout.js | 9 +++-- test/parallel/test-net-stream.js | 3 +- .../test-process-getactiverequests.js | 2 +- test/parallel/test-process-next-tick.js | 2 +- .../test-promises-unhandled-rejections.js | 34 +++++++++---------- test/parallel/test-querystring.js | 4 +-- test/parallel/test-readline-interface.js | 8 ++--- test/parallel/test-regress-GH-4948.js | 4 +-- test/parallel/test-regress-GH-5051.js | 4 +-- test/parallel/test-repl-.save.load.js | 9 +++-- test/parallel/test-repl-history-perm.js | 2 +- test/parallel/test-repl-mode.js | 2 +- test/parallel/test-repl-tab-complete-crash.js | 2 +- test/parallel/test-repl.js | 2 +- .../test-stream-decoder-objectmode.js | 1 + test/parallel/test-stream-duplex.js | 1 + test/parallel/test-stream-pipe-await-drain.js | 2 +- .../test-stream-pipe-cleanup-pause.js | 2 +- .../test-stream-pipe-error-handling.js | 4 +-- .../test-stream-readable-invalid-chunk.js | 1 + .../test-stream2-pipe-error-once-listener.js | 2 +- .../test-stream2-readable-wrap-empty.js | 6 ++-- test/parallel/test-stream2-writable.js | 10 +++--- test/parallel/test-timers-unref-call.js | 5 +-- ...-timers-unref-remove-other-unref-timers.js | 2 +- test/parallel/test-timers-unref.js | 9 ++--- test/parallel/test-timers-zero-timeout.js | 2 +- test/parallel/test-tls-legacy-onselect.js | 2 +- test/parallel/test-url.js | 4 +-- test/parallel/test-util-inspect.js | 2 +- test/parallel/test-util.js | 6 ++-- test/pummel/test-net-connect-memleak.js | 2 +- 62 files changed, 153 insertions(+), 159 deletions(-) diff --git a/test/common/README.md b/test/common/README.md index 61802f9c70e..ca8613796f3 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -183,7 +183,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) @@ -191,10 +191,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) @@ -202,7 +202,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' @@ -217,19 +217,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 a256a6afb17..9932a6daf2b 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -14,7 +14,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/debugger/test-debugger-client.js b/test/debugger/test-debugger-client.js index 7ebf3c7a432..330802e2574 100644 --- a/test/debugger/test-debugger-client.js +++ b/test/debugger/test-debugger-client.js @@ -129,7 +129,7 @@ addTest(function(client, done) { let connectCount = 0; const script = 'setTimeout(function() { console.log("blah"); });' + - 'setInterval(common.noop, 1000000);'; + 'setInterval(() => {}, 1000000);'; let nodeProcess; @@ -172,7 +172,7 @@ function doTest(cb, done) { console.error('>>> connecting...'); c.connect(debug.port); c.on('break', function() { - c.reqContinue(common.noop); + c.reqContinue(() => {}); }); c.on('ready', function() { connectCount++; diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 145760dfa35..30ab10a1283 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const a = require('assert'); @@ -515,7 +515,7 @@ testAssertionMessage(/a/, '/a/'); testAssertionMessage(/abc/gim, '/abc/gim'); testAssertionMessage(function f() {}, '[Function: f]'); testAssertionMessage(function() {}, '[Function]'); -testAssertionMessage(common.noop, '[Function: noop]'); +testAssertionMessage(() => {}, '[Function]'); testAssertionMessage({}, '{}'); testAssertionMessage(circular, '{ y: 1, x: [Circular] }'); testAssertionMessage({a: undefined, b: null}, '{ a: undefined, b: null }'); diff --git a/test/parallel/test-cluster-rr-domain-listen.js b/test/parallel/test-cluster-rr-domain-listen.js index 44d6aea560d..6680c997984 100644 --- a/test/parallel/test-cluster-rr-domain-listen.js +++ b/test/parallel/test-cluster-rr-domain-listen.js @@ -8,10 +8,10 @@ const domain = require('domain'); if (cluster.isWorker) { const d = domain.create(); - d.run(function() { }); + d.run(() => {}); const http = require('http'); - http.Server(function() { }).listen(0, '127.0.0.1'); + http.Server(() => {}).listen(0, '127.0.0.1'); } else if (cluster.isMaster) { let worker; diff --git a/test/parallel/test-cluster-worker-wait-server-close.js b/test/parallel/test-cluster-worker-wait-server-close.js index f91003e9a5c..b8183afb06a 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', function discard() {}); + 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 f9555851435..583a5272c6f 100644 --- a/test/parallel/test-common.js +++ b/test/parallel/test-common.js @@ -10,11 +10,11 @@ global.gc = 42; // Not a valid global unless --expose_gc is set. assert.deepStrictEqual(common.leakedGlobals(), ['gc']); assert.throws(function() { - common.mustCall(common.noop, 'foo'); + common.mustCall(() => {}, 'foo'); }, /^TypeError: Invalid exact value: foo$/); assert.throws(function() { - common.mustCall(common.noop, /foo/); + common.mustCall(() => {}, /foo/); }, /^TypeError: Invalid exact value: \/foo\/$/); const fnOnce = common.mustCall(() => {}); diff --git a/test/parallel/test-crypto-random.js b/test/parallel/test-crypto-random.js index 0a9c594654b..7fa5c71c3ce 100644 --- a/test/parallel/test-crypto-random.js +++ b/test/parallel/test-crypto-random.js @@ -16,7 +16,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, common.noop); }, expectedErrorRegexp); + assert.throws(function() { f(value, () => {}); }, expectedErrorRegexp); }); [0, 1, 2, 4, 16, 256, 1024].forEach(function(len) { diff --git a/test/parallel/test-env-var-no-warnings.js b/test/parallel/test-env-var-no-warnings.js index 37774f2a161..f829443888b 100644 --- a/test/parallel/test-env-var-no-warnings.js +++ b/test/parallel/test-env-var-no-warnings.js @@ -29,7 +29,7 @@ if (process.argv[2] === 'child') { test({ NODE_NO_WARNINGS: false }); test({ NODE_NO_WARNINGS: {} }); test({ NODE_NO_WARNINGS: [] }); - test({ NODE_NO_WARNINGS: common.noop }); + test({ NODE_NO_WARNINGS: () => {} }); test({ NODE_NO_WARNINGS: 0 }); test({ NODE_NO_WARNINGS: -1 }); test({ NODE_NO_WARNINGS: '0' }); diff --git a/test/parallel/test-event-emitter-check-listener-leaks.js b/test/parallel/test-event-emitter-check-listener-leaks.js index 0f5f3757c64..ceaf1b54884 100644 --- a/test/parallel/test-event-emitter-check-listener-leaks.js +++ b/test/parallel/test-event-emitter-check-listener-leaks.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../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', common.noop); + e.on('default', () => {}); } assert.ok(!e._events['default'].hasOwnProperty('warned')); -e.on('default', common.noop); +e.on('default', () => {}); assert.ok(e._events['default'].warned); // symbol const symbol = Symbol('symbol'); e.setMaxListeners(1); -e.on(symbol, common.noop); +e.on(symbol, () => {}); assert.ok(!e._events[symbol].hasOwnProperty('warned')); -e.on(symbol, common.noop); +e.on(symbol, () => {}); assert.ok(e._events[symbol].hasOwnProperty('warned')); // specific e.setMaxListeners(5); for (let i = 0; i < 5; i++) { - e.on('specific', common.noop); + e.on('specific', () => {}); } assert.ok(!e._events['specific'].hasOwnProperty('warned')); -e.on('specific', common.noop); +e.on('specific', () => {}); assert.ok(e._events['specific'].warned); // only one e.setMaxListeners(1); -e.on('only one', common.noop); +e.on('only one', () => {}); assert.ok(!e._events['only one'].hasOwnProperty('warned')); -e.on('only one', common.noop); +e.on('only one', () => {}); assert.ok(e._events['only one'].hasOwnProperty('warned')); // unlimited e.setMaxListeners(0); for (let i = 0; i < 1000; i++) { - e.on('unlimited', common.noop); + e.on('unlimited', () => {}); } 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', common.noop); + e.on('fortytwo', () => {}); } assert.ok(!e._events['fortytwo'].hasOwnProperty('warned')); -e.on('fortytwo', common.noop); +e.on('fortytwo', () => {}); assert.ok(e._events['fortytwo'].hasOwnProperty('warned')); delete e._events['fortytwo'].warned; events.EventEmitter.defaultMaxListeners = 44; -e.on('fortytwo', common.noop); +e.on('fortytwo', () => {}); assert.ok(!e._events['fortytwo'].hasOwnProperty('warned')); -e.on('fortytwo', common.noop); +e.on('fortytwo', () => {}); 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', common.noop); +e.on('uno', () => {}); assert.ok(!e._events['uno'].hasOwnProperty('warned')); -e.on('uno', common.noop); +e.on('uno', () => {}); assert.ok(e._events['uno'].hasOwnProperty('warned')); // chainable diff --git a/test/parallel/test-event-emitter-get-max-listeners.js b/test/parallel/test-event-emitter-get-max-listeners.js index 98ac02e8713..43f9f0cebc4 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 50247f42770..117d38f575d 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 16d9e28bb1e..b879091e11f 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 bd1a8bec775..74819e95d68 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 f0cdac1919d..0487535ece7 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-all-listeners.js b/test/parallel/test-event-emitter-remove-all-listeners.js index 8c4d2caa74f..f69ff551045 100644 --- a/test/parallel/test-event-emitter-remove-all-listeners.js +++ b/test/parallel/test-event-emitter-remove-all-listeners.js @@ -70,9 +70,9 @@ function listener() {} ee.on('removeListener', function(name, listener) { assert.strictEqual(expectLength--, this.listeners('baz').length); }); - ee.on('baz', common.noop); - ee.on('baz', common.noop); - ee.on('baz', common.noop); + ee.on('baz', () => {}); + ee.on('baz', () => {}); + ee.on('baz', () => {}); assert.strictEqual(ee.listeners('baz').length, expectLength + 1); ee.removeAllListeners('baz'); assert.strictEqual(ee.listeners('baz').length, 0); diff --git a/test/parallel/test-event-emitter-subclass.js b/test/parallel/test-event-emitter-subclass.js index c0ce3392f72..4b8bb5b3814 100644 --- a/test/parallel/test-event-emitter-subclass.js +++ b/test/parallel/test-event-emitter-subclass.js @@ -41,6 +41,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-fs-buffertype-writesync.js b/test/parallel/test-fs-buffertype-writesync.js index 02d2cb58f83..73a6f211893 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 cf744215a04..eb70640be46 100644 --- a/test/parallel/test-fs-mkdir.js +++ b/test/parallel/test-fs-mkdir.js @@ -56,4 +56,4 @@ common.refreshTmpDir(); // Keep the event loop alive so the async mkdir() requests // have a chance to run (since they don't ref the event loop). -process.nextTick(common.noop); +process.nextTick(() => {}); diff --git a/test/parallel/test-fs-read-stream-inherit.js b/test/parallel/test-fs-read-stream-inherit.js index b0bbde15353..10bf800960b 100644 --- a/test/parallel/test-fs-read-stream-inherit.js +++ b/test/parallel/test-fs-read-stream-inherit.js @@ -139,7 +139,7 @@ let paused = false; let file7 = fs.createReadStream(rangeFile, Object.create({autoClose: false })); assert.strictEqual(file7.autoClose, false); - file7.on('data', common.noop); + file7.on('data', () => {}); file7.on('end', common.mustCall(function() { process.nextTick(common.mustCall(function() { assert(!file7.closed); @@ -169,7 +169,7 @@ let paused = false; { const options = Object.create({fd: 13337, autoClose: false}); const file8 = fs.createReadStream(null, options); - file8.on('data', common.noop); + file8.on('data', () => {}); file8.on('error', common.mustCall()); process.on('exit', function() { assert(!file8.closed); @@ -181,7 +181,7 @@ 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', common.noop); + file9.on('data', () => {}); file9.on('error', common.mustCall()); process.on('exit', function() { diff --git a/test/parallel/test-fs-read-stream.js b/test/parallel/test-fs-read-stream.js index 5948845fcd8..629f2ff0033 100644 --- a/test/parallel/test-fs-read-stream.js +++ b/test/parallel/test-fs-read-stream.js @@ -138,7 +138,7 @@ pauseRes.pause(); pauseRes.resume(); let file7 = fs.createReadStream(rangeFile, {autoClose: false }); -file7.on('data', common.noop); +file7.on('data', () => {}); file7.on('end', function() { process.nextTick(function() { assert(!file7.closed); @@ -161,12 +161,12 @@ 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', common.noop); +file8.on('data', () => {}); 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', common.noop); +file9.on('data', () => {}); file9.on('error', common.mustCall()); process.on('exit', function() { diff --git a/test/parallel/test-handle-wrap-close-abort.js b/test/parallel/test-handle-wrap-close-abort.js index 492907ee055..9b8489578a7 100644 --- a/test/parallel/test-handle-wrap-close-abort.js +++ b/test/parallel/test-handle-wrap-close-abort.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../common'); -process.on('uncaughtException', common.mustCall(common.noop, 2)); +process.on('uncaughtException', common.mustCall(() => {}, 2)); setTimeout(function() { process.nextTick(function() { diff --git a/test/parallel/test-http-parser-bad-ref.js b/test/parallel/test-http-parser-bad-ref.js index c4ab1db8659..6e9fb2f9ac6 100644 --- a/test/parallel/test-http-parser-bad-ref.js +++ b/test/parallel/test-http-parser-bad-ref.js @@ -39,7 +39,7 @@ function demoBug(part1, part2) { console.log('url', info.url); }; - parser[kOnBody] = function(b, start, len) { }; + 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 72c9313b846..72106ad1c12 100644 --- a/test/parallel/test-http-upgrade-server.js +++ b/test/parallel/test-http-upgrade-server.js @@ -1,5 +1,6 @@ 'use strict'; -const common = require('../common'); + +require('../common'); const assert = require('assert'); const util = require('util'); @@ -16,7 +17,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 797ca6041e4..1590f3cb5b3 100644 --- a/test/parallel/test-https-close.js +++ b/test/parallel/test-https-close.js @@ -47,7 +47,7 @@ server.listen(0, function() { }; const req = https.request(requestOptions, function(res) { - res.on('data', function(d) {}); + res.on('data', () => {}); setImmediate(shutdown); }); req.end(); diff --git a/test/parallel/test-https-set-timeout-server.js b/test/parallel/test-https-set-timeout-server.js index dfa880f9108..b27471e15ca 100644 --- a/test/parallel/test-https-set-timeout-server.js +++ b/test/parallel/test-https-set-timeout-server.js @@ -43,7 +43,7 @@ test(function serverTimeout(cb) { https.get({ port: server.address().port, rejectUnauthorized: false - }).on('error', common.noop); + }).on('error', () => {}); })); }); @@ -65,7 +65,7 @@ test(function serverRequestTimeout(cb) { method: 'POST', rejectUnauthorized: false }); - req.on('error', common.noop); + req.on('error', () => {}); req.write('Hello'); // req is in progress })); diff --git a/test/parallel/test-https-socket-options.js b/test/parallel/test-https-socket-options.js index 824c0f3a5ae..0e3d386ea12 100644 --- a/test/parallel/test-https-socket-options.js +++ b/test/parallel/test-https-socket-options.js @@ -34,7 +34,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, function() { }); + req.setTimeout(1000, () => {}); req.setSocketKeepAlive(true, 1000); req.end(); }); @@ -58,7 +58,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, function() { }); + req.setTimeout(1000, () => {}); req.setSocketKeepAlive(true, 1000); req.end(); }); diff --git a/test/parallel/test-instanceof.js b/test/parallel/test-instanceof.js index 498962ef86c..658f1e29c7a 100644 --- a/test/parallel/test-instanceof.js +++ b/test/parallel/test-instanceof.js @@ -1,7 +1,11 @@ 'use strict'; + require('../common'); const assert = require('assert'); + +// Regression test for instanceof, see +// https://github.com/nodejs/node/issues/7592 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 1909af067ce..00d5e73cb17 100644 --- a/test/parallel/test-net-listen-exclusive-random-ports.js +++ b/test/parallel/test-net-listen-exclusive-random-ports.js @@ -1,11 +1,10 @@ 'use strict'; + require('../common'); const assert = require('assert'); const cluster = require('cluster'); const net = require('net'); -function noop() {} - if (cluster.isMaster) { const worker1 = cluster.fork(); @@ -21,7 +20,7 @@ if (cluster.isMaster) { }); }); } else { - const server = net.createServer(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 d3cecc6f947..f0e8b34c807 100644 --- a/test/parallel/test-net-options-lookup.js +++ b/test/parallel/test-net-options-lookup.js @@ -20,7 +20,7 @@ function connectThrows(input) { }, expectedError); } -[() => {}].forEach((input) => connectDoesNotThrow(input)); +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 841c1e5f134..15351637b3a 100644 --- a/test/parallel/test-net-socket-timeout.js +++ b/test/parallel/test-net-socket-timeout.js @@ -4,10 +4,9 @@ const net = require('net'); const assert = require('assert'); // Verify that invalid delays throw -const noop = () => {}; const s = new net.Socket(); const nonNumericDelays = [ - '100', true, false, undefined, null, '', {}, noop, [] + '100', true, false, undefined, null, '', {}, () => {}, [] ]; const badRangeDelays = [-0.001, -1, -Infinity, Infinity, NaN]; const validDelays = [0, 0.001, 1, 1e6]; @@ -15,19 +14,19 @@ const validDelays = [0, 0.001, 1, 1e6]; for (let i = 0; i < nonNumericDelays.length; i++) { assert.throws(function() { - s.setTimeout(nonNumericDelays[i], noop); + s.setTimeout(nonNumericDelays[i], () => {}); }, TypeError); } for (let i = 0; i < badRangeDelays.length; i++) { assert.throws(function() { - s.setTimeout(badRangeDelays[i], noop); + s.setTimeout(badRangeDelays[i], () => {}); }, RangeError); } for (let i = 0; i < validDelays.length; i++) { assert.doesNotThrow(function() { - s.setTimeout(validDelays[i], noop); + s.setTimeout(validDelays[i], () => {}); }); } diff --git a/test/parallel/test-net-stream.js b/test/parallel/test-net-stream.js index 2d3cdd76be7..6b6684f1b9b 100644 --- a/test/parallel/test-net-stream.js +++ b/test/parallel/test-net-stream.js @@ -1,4 +1,5 @@ 'use strict'; + require('../common'); const assert = require('assert'); const net = require('net'); @@ -32,7 +33,7 @@ const server = net.createServer(function(socket) { }); for (let i = 0; i < N; ++i) { - socket.write(buf, function() { }); + socket.write(buf, () => {}); } socket.end(); diff --git a/test/parallel/test-process-getactiverequests.js b/test/parallel/test-process-getactiverequests.js index f1874e4ad09..f55f298298d 100644 --- a/test/parallel/test-process-getactiverequests.js +++ b/test/parallel/test-process-getactiverequests.js @@ -5,6 +5,6 @@ const assert = require('assert'); const fs = require('fs'); for (let i = 0; i < 12; i++) - fs.open(__filename, 'r', function() { }); + fs.open(__filename, 'r', () => {}); assert.strictEqual(12, process._getActiveRequests().length); diff --git a/test/parallel/test-process-next-tick.js b/test/parallel/test-process-next-tick.js index 383b87a030a..01dcca9e925 100644 --- a/test/parallel/test-process-next-tick.js +++ b/test/parallel/test-process-next-tick.js @@ -10,7 +10,7 @@ for (let i = 0; i < N; ++i) { process.nextTick(common.mustCall(cb)); } -process.on('uncaughtException', common.mustCall(common.noop, N)); +process.on('uncaughtException', common.mustCall(() => {}, N)); process.on('exit', function() { process.removeAllListeners('uncaughtException'); diff --git a/test/parallel/test-promises-unhandled-rejections.js b/test/parallel/test-promises-unhandled-rejections.js index d976493e87c..b38d16a40f0 100644 --- a/test/parallel/test-promises-unhandled-rejections.js +++ b/test/parallel/test-promises-unhandled-rejections.js @@ -164,7 +164,7 @@ asyncTest('Catching a promise rejection after setImmediate is not' + }); _reject(e); setImmediate(function() { - promise.then(common.fail, common.noop); + promise.then(common.fail, () => {}); }); }); @@ -240,7 +240,7 @@ asyncTest( function(done) { const e = new Error(); onUnhandledFail(done); - Promise.reject(e).then(common.fail, common.noop); + Promise.reject(e).then(common.fail, () => {}); } ); @@ -252,7 +252,7 @@ asyncTest( onUnhandledFail(done); new Promise(function(_, reject) { reject(e); - }).then(common.fail, common.noop); + }).then(common.fail, () => {}); } ); @@ -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, common.noop); + promise.then(common.fail, () => {}); }); }); @@ -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, common.noop); + promise.then(common.fail, () => {}); }); }); @@ -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, common.noop); + Promise.all([Promise.reject(e)]).then(common.fail, () => {}); }); asyncTest( @@ -401,7 +401,7 @@ asyncTest( }); p = Promise.all([p]); process.nextTick(function() { - p.then(common.fail, common.noop); + p.then(common.fail, () => {}); }); } ); @@ -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(common.noop); + a.catch(() => {}); }); }); }); @@ -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(common.noop); + a.catch(() => {}); }); }); }); @@ -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(common.noop); + a.catch(() => {}); }); }); }); @@ -514,7 +514,7 @@ asyncTest('Waiting for some combination of promise microtasks + ' + process.nextTick(function() { Promise.resolve().then(function() { process.nextTick(function() { - a.catch(common.noop); + a.catch(() => {}); }); }); }); @@ -535,7 +535,7 @@ asyncTest( process.nextTick(function() { Promise.resolve().then(function() { process.nextTick(function() { - a.catch(common.noop); + a.catch(() => {}); }); }); }); @@ -556,7 +556,7 @@ asyncTest('Waiting for some combination of promise microtasks +' + process.nextTick(function() { Promise.resolve().then(function() { process.nextTick(function() { - a.catch(common.noop); + a.catch(() => {}); }); }); }); @@ -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(common.noop); + p.catch(() => {}); }); }); }); @@ -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(common.noop); + p.catch(() => {}); }); }); }); @@ -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(common.noop); + p.catch(() => {}); }); }); }); @@ -682,7 +682,7 @@ asyncTest('Throwing an error inside a rejectionHandled handler goes to' + const p = Promise.reject(e); setTimeout(function() { try { - p.catch(common.noop); + p.catch(() => {}); } catch (e) { done(new Error('fail')); } diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js index bee4030ea1d..8ec635f7d3a 100644 --- a/test/parallel/test-querystring.js +++ b/test/parallel/test-querystring.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../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: common.noop}, 'fn=', {'fn': ''}], + [{fn: () => {}}, 'fn=', {'fn': ''}], [{fn: new Function('')}, 'fn=', {'fn': ''}], [{math: Math}, 'math=', {'math': ''}], [{e: extendedFunction}, 'e=', {'e': ''}], diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index 0e7e96a565a..d101a4582df 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -11,10 +11,10 @@ function FakeInput() { EventEmitter.call(this); } inherits(FakeInput, EventEmitter); -FakeInput.prototype.resume = 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-regress-GH-4948.js b/test/parallel/test-regress-GH-4948.js index 196c973cd09..5ec79b8685b 100644 --- a/test/parallel/test-regress-GH-4948.js +++ b/test/parallel/test-regress-GH-4948.js @@ -22,10 +22,10 @@ const server = http.createServer(function(serverReq, serverRes) { serverRes.end(); // required for test to fail - res.on('data', function(data) { }); + res.on('data', () => {}); }); - r.on('error', function(e) {}); + 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 f0a2d7aa7f1..0fef879c6f1 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-.save.load.js b/test/parallel/test-repl-.save.load.js index 283fc142f96..b7a763de5c4 100644 --- a/test/parallel/test-repl-.save.load.js +++ b/test/parallel/test-repl-.save.load.js @@ -77,16 +77,15 @@ 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]); // throw error on loading directory loadFile = common.tmpDir; putIn.write = function(data) { - assert.strictEqual(data, 'Failed to load:' + loadFile + - ' is not a valid file\n'); - putIn.write = common.noop; + assert.strictEqual(data, `Failed to load:${loadFile} is not a valid file\n`); + putIn.write = () => {}; }; putIn.run(['.load ' + loadFile]); @@ -102,7 +101,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-history-perm.js b/test/parallel/test-repl-history-perm.js index 76e371ab51c..81c4b50d6a1 100644 --- a/test/parallel/test-repl-history-perm.js +++ b/test/parallel/test-repl-history-perm.js @@ -18,7 +18,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 9a0773153b5..60b430d8c7e 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-tab-complete-crash.js b/test/parallel/test-repl-tab-complete-crash.js index 0874ba41f07..ba8de7888e3 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 = function(msg) {}; +common.ArrayStream.prototype.write = () => {}; const putIn = new common.ArrayStream(); const testMe = repl.start('', putIn); diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 5baa2cd5fbb..c471b185dd6 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -200,7 +200,7 @@ function error_test() { { client: client_unix, send: 'blah()', expect: `1\n${prompt_unix}` }, // Functions should not evaluate twice (#2773) - { client: client_unix, send: 'var I = [1,2,3,common.noop]; I.pop()', + { client: client_unix, send: 'var I = [1,2,3,() => {}]; I.pop()', expect: '[Function]' }, // Multiline object { client: client_unix, send: '{ a: ', diff --git a/test/parallel/test-stream-decoder-objectmode.js b/test/parallel/test-stream-decoder-objectmode.js index d6b0784430d..4c572fed6b6 100644 --- a/test/parallel/test-stream-decoder-objectmode.js +++ b/test/parallel/test-stream-decoder-objectmode.js @@ -1,4 +1,5 @@ 'use strict'; + require('../common'); const stream = require('stream'); const assert = require('assert'); diff --git a/test/parallel/test-stream-duplex.js b/test/parallel/test-stream-duplex.js index f36c711fa3b..8f89aff36e5 100644 --- a/test/parallel/test-stream-duplex.js +++ b/test/parallel/test-stream-duplex.js @@ -1,4 +1,5 @@ 'use strict'; + require('../common'); const assert = require('assert'); const Duplex = require('stream').Duplex; diff --git a/test/parallel/test-stream-pipe-await-drain.js b/test/parallel/test-stream-pipe-await-drain.js index fc822bb60b7..5bdf4800847 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 = function(n) {}; +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 3085ed5f9a9..3cdab94648d 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 = function(n) {}; +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 0f6f855a43a..9bd8c1f2a8e 100644 --- a/test/parallel/test-stream-pipe-error-handling.js +++ b/test/parallel/test-stream-pipe-error-handling.js @@ -80,10 +80,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-readable-invalid-chunk.js b/test/parallel/test-stream-readable-invalid-chunk.js index 62cd103b025..f528dfe6933 100644 --- a/test/parallel/test-stream-readable-invalid-chunk.js +++ b/test/parallel/test-stream-readable-invalid-chunk.js @@ -1,4 +1,5 @@ 'use strict'; + require('../common'); const stream = require('stream'); const assert = require('assert'); diff --git a/test/parallel/test-stream2-pipe-error-once-listener.js b/test/parallel/test-stream2-pipe-error-once-listener.js index c36a48dcbd6..c4230619526 100644 --- a/test/parallel/test-stream2-pipe-error-once-listener.js +++ b/test/parallel/test-stream2-pipe-error-once-listener.js @@ -29,7 +29,7 @@ Write.prototype._write = function(buffer, encoding, cb) { const read = new Read(); const write = new Write(); -write.once('error', function(err) {}); +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 3282f5da6cf..e3052e4af7e 100644 --- a/test/parallel/test-stream2-readable-wrap-empty.js +++ b/test/parallel/test-stream2-readable-wrap-empty.js @@ -5,13 +5,13 @@ const Readable = require('_stream_readable'); const EE = require('events').EventEmitter; const oldStream = new EE(); -oldStream.pause = 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-stream2-writable.js b/test/parallel/test-stream2-writable.js index 136d4dc3dce..ebfc61f9f67 100644 --- a/test/parallel/test-stream2-writable.js +++ b/test/parallel/test-stream2-writable.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../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 = common.noop; + w._write = () => {}; 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 = common.noop; - d._write = common.noop; + d._read = () => {}; + d._write = () => {}; 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 = common.noop; + w._write = () => {}; let gotError = false; w.on('error', function(er) { gotError = true; diff --git a/test/parallel/test-timers-unref-call.js b/test/parallel/test-timers-unref-call.js index 8dfda0c5a85..0015318c4ba 100644 --- a/test/parallel/test-timers-unref-call.js +++ b/test/parallel/test-timers-unref-call.js @@ -1,11 +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 221f5bb6fd9..84dd75025d6 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 aeccacece88..aaa43720f66 100644 --- a/test/parallel/test-timers-unref.js +++ b/test/parallel/test-timers-unref.js @@ -1,5 +1,6 @@ 'use strict'; -const common = require('../common'); + +require('../common'); const assert = require('assert'); let interval_fired = false; @@ -13,11 +14,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() { @@ -56,7 +57,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-zero-timeout.js b/test/parallel/test-timers-zero-timeout.js index c3edd92260e..9728685c432 100644 --- a/test/parallel/test-timers-zero-timeout.js +++ b/test/parallel/test-timers-zero-timeout.js @@ -5,7 +5,7 @@ const assert = require('assert'); // https://github.com/joyent/node/issues/2079 - zero timeout drops extra args { setTimeout(common.mustCall(f), 0, 'foo', 'bar', 'baz'); - setTimeout(common.noop, 0); + setTimeout(() => {}, 0); function f(a, b, c) { assert.strictEqual(a, 'foo'); diff --git a/test/parallel/test-tls-legacy-onselect.js b/test/parallel/test-tls-legacy-onselect.js index e66e0dd4b4a..4b66f316599 100644 --- a/test/parallel/test-tls-legacy-onselect.js +++ b/test/parallel/test-tls-legacy-onselect.js @@ -9,7 +9,7 @@ const net = require('net'); const server = net.Server(common.mustCall(function(raw) { const pair = tls.createSecurePair(null, true, false, false); - pair.on('error', common.noop); + pair.on('error', () => {}); pair.ssl.setSNICallback(common.mustCall(function() { raw.destroy(); server.close(); diff --git a/test/parallel/test-url.js b/test/parallel/test-url.js index 251557f8ac9..67cbee6a0fe 100644 --- a/test/parallel/test-url.js +++ b/test/parallel/test-url.js @@ -1,6 +1,6 @@ /* eslint-disable max-len */ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const url = require('url'); @@ -1684,7 +1684,7 @@ const throws = [ true, false, 0, - common.noop + () => {} ]; for (let i = 0; i < throws.length; i++) { assert.throws(function() { url.format(throws[i]); }, TypeError); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index df35ec3a001..7ef53e562c4 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -800,7 +800,7 @@ checkAlignment(new Map(big_array.map(function(y) { return [y, null]; }))); 'SetSubclass { 1, 2, 3 }'); assert.strictEqual(util.inspect(new MapSubclass([['foo', 42]])), 'MapSubclass { \'foo\' => 42 }'); - assert.strictEqual(util.inspect(new PromiseSubclass(function() {})), + assert.strictEqual(util.inspect(new PromiseSubclass(() => {})), 'PromiseSubclass { }'); } diff --git a/test/parallel/test-util.js b/test/parallel/test-util.js index 867cae95935..814e503ed3b 100644 --- a/test/parallel/test-util.js +++ b/test/parallel/test-util.js @@ -12,7 +12,7 @@ assert.strictEqual(true, util.isArray(new Array(5))); assert.strictEqual(true, util.isArray(new Array('with', 'some', 'entries'))); assert.strictEqual(true, util.isArray(context('Array')())); assert.strictEqual(false, util.isArray({})); -assert.strictEqual(false, util.isArray({ push: common.noop })); +assert.strictEqual(false, util.isArray({ push: () => {} })); 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(common.noop)); +assert.strictEqual(false, util.isPrimitive(() => {})); 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(common.noop), true); +assert.strictEqual(util.isFunction(() => {}), true); assert.strictEqual(util.isFunction(), false); assert.strictEqual(util.isFunction('string'), false); diff --git a/test/pummel/test-net-connect-memleak.js b/test/pummel/test-net-connect-memleak.js index 6799b412b69..8179625210e 100644 --- a/test/pummel/test-net-connect-memleak.js +++ b/test/pummel/test-net-connect-memleak.js @@ -10,7 +10,7 @@ assert.strictEqual( 'function', 'Run this test with --expose-gc' ); -net.createServer(common.noop).listen(common.PORT); +net.createServer(() => {}).listen(common.PORT); let before = 0; {