mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
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 <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
1 parent
40a61e1399
commit
688e5ed6fd
62 files changed
+153
-159
No files matched your search
+4
-17
@@ -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,
|
||||
|
||||
<!-- eslint-disable strict, no-undef -->
|
||||
```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)
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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 }');
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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(() => {});
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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' });
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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', () => {});
|
||||
@@ -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);
|
||||
|
||||
@@ -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, () => {});
|
||||
@@ -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, () => {});
|
||||
@@ -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.
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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(() => {});
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
}));
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
|
||||
@@ -20,7 +20,7 @@ function connectThrows(input) {
|
||||
}, expectedError);
|
||||
}
|
||||
|
||||
[() => {}].forEach((input) => connectDoesNotThrow(input));
|
||||
connectDoesNotThrow(() => {});
|
||||
|
||||
function connectDoesNotThrow(input) {
|
||||
const opts = {
|
||||
|
||||
@@ -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], () => {});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -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');
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
|
||||
@@ -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': ''}],
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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: ',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
const stream = require('stream');
|
||||
const assert = require('assert');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const Duplex = require('stream').Duplex;
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
const stream = require('stream');
|
||||
const assert = require('assert');
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
@@ -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');
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -29,4 +29,4 @@ timers.enroll(foo, 50);
|
||||
timers._unrefActive(foo);
|
||||
|
||||
// Keep the process open.
|
||||
setTimeout(common.noop, 100);
|
||||
setTimeout(() => {}, 100);
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 { <pending> }');
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user