Skip to content

Commit 4f2e372

Browse files
committedMar 26, 2017
test: add common.noop, default for common.mustCall()
Export a new common.noop no-operation function for general use. Allow using common.mustCall() without a fn argument to simplify test cases. Replace various non-op functions throughout tests with common.noop PR-URL: #12027 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
1 parent d13bd4a commit 4f2e372

File tree

184 files changed

+492
-490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+492
-490
lines changed
 

‎test/README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ Gets IP of localhost
324324

325325
Array of IPV6 hosts.
326326

327-
### mustCall(fn[, expected])
327+
### mustCall([fn][, expected])
328328
* fn [&lt;Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
329329
* expected [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) default = 1
330330
* return [&lt;Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
@@ -333,13 +333,27 @@ Returns a function that calls `fn`. If the returned function has not been called
333333
exactly `expected` number of times when the test is complete, then the test will
334334
fail.
335335

336+
If `fn` is not provided, `common.noop` will be used.
337+
336338
### nodeProcessAborted(exitCode, signal)
337339
* `exitCode` [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
338340
* `signal` [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
339341
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
340342

341343
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.
342344

345+
### noop
346+
347+
A non-op `Function` that can be used for a variety of scenarios.
348+
349+
For instance,
350+
351+
```js
352+
const common = require('../common');
353+
354+
someAsyncAPI('foo', common.mustCall(common.noop));
355+
```
356+
343357
### opensslCli
344358
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
345359

‎test/addons/async-hello-world/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ const binding = require(`./build/${common.buildType}/binding`);
66
binding(5, common.mustCall(function(err, val) {
77
assert.strictEqual(err, null);
88
assert.strictEqual(val, 10);
9-
process.nextTick(common.mustCall(function() {}));
9+
process.nextTick(common.mustCall());
1010
}));

0 commit comments

Comments
 (0)
Please sign in to comment.