| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e408f0a commit dbb7727
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -398,7 +398,10 @@ function runCallChecks(exitCode) { | |||
| 398 | 398 | ||
| 399 | 399 | ||
| 400 | 400 | exports.mustCall = function(fn, expected) { | |
| 401 | - if (typeof expected !== 'number') expected = 1; | ||
| 401 | + if (expected === undefined) | ||
| 402 | + expected = 1; | ||
| 403 | + else if (typeof expected !== 'number') | ||
| 404 | + throw new TypeError(`Invalid expected value: ${expected}`); | ||
| 402 | 405 | ||
| 403 | 406 | const context = { | |
| 404 | 407 | expected: expected, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,3 +5,11 @@ var assert = require('assert'); | |||
| 5 | 5 | common.globalCheck = false; | |
| 6 | 6 | global.gc = 42; // Not a valid global unless --expose_gc is set. | |
| 7 | 7 | assert.deepStrictEqual(common.leakedGlobals(), ['gc']); | |
| 8 | + | ||
| 9 | + assert.throws(function() { | ||
| 10 | + common.mustCall(function() {}, 'foo'); | ||
| 11 | + }, /^TypeError: Invalid expected value: foo$/); | ||
| 12 | + | ||
| 13 | + assert.throws(function() { | ||
| 14 | + common.mustCall(function() {}, /foo/); | ||
| 15 | + }, /^TypeError: Invalid expected value: \/foo\/$/); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments