File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -397,7 +397,10 @@ function runCallChecks(exitCode) {
397397
398398
399399exports . mustCall = function ( fn , expected ) {
400- if ( typeof expected !== 'number' ) expected = 1 ;
400+ if ( expected === undefined )
401+ expected = 1 ;
402+ else if ( typeof expected !== 'number' )
403+ throw new TypeError ( `Invalid expected value: ${ expected } ` ) ;
401404
402405 const context = {
403406 expected : expected ,
Original file line number Diff line number Diff line change @@ -5,3 +5,11 @@ var assert = require('assert');
55common . globalCheck = false ;
66global . gc = 42 ; // Not a valid global unless --expose_gc is set.
77assert . deepStrictEqual ( common . leakedGlobals ( ) , [ 'gc' ] ) ;
8+
9+ assert . throws ( function ( ) {
10+ common . mustCall ( function ( ) { } , 'foo' ) ;
11+ } , / ^ T y p e E r r o r : I n v a l i d e x p e c t e d v a l u e : f o o $ / ) ;
12+
13+ assert . throws ( function ( ) {
14+ common . mustCall ( function ( ) { } , / f o o / ) ;
15+ } , / ^ T y p e E r r o r : I n v a l i d e x p e c t e d v a l u e : \/ f o o \/ $ / ) ;
You can’t perform that action at this time.
0 commit comments