@@ -406,36 +406,49 @@ function runCallChecks(exitCode) {
406406 if ( exitCode !== 0 ) return ;
407407
408408 const failed = mustCallChecks . filter ( function ( context ) {
409- return context . actual !== context . expected ;
409+ if ( 'minimum' in context ) {
410+ context . messageSegment = `at least ${ context . minimum } ` ;
411+ return context . actual < context . minimum ;
412+ } else {
413+ context . messageSegment = `exactly ${ context . exact } ` ;
414+ return context . actual !== context . exact ;
415+ }
410416 } ) ;
411417
412418 failed . forEach ( function ( context ) {
413- console . log ( 'Mismatched %s function calls. Expected %d , actual %d.' ,
419+ console . log ( 'Mismatched %s function calls. Expected %s , actual %d.' ,
414420 context . name ,
415- context . expected ,
421+ context . messageSegment ,
416422 context . actual ) ;
417423 console . log ( context . stack . split ( '\n' ) . slice ( 2 ) . join ( '\n' ) ) ;
418424 } ) ;
419425
420426 if ( failed . length ) process . exit ( 1 ) ;
421427}
422428
429+ exports . mustCall = function ( fn , exact ) {
430+ return _mustCallInner ( fn , exact , 'exact' ) ;
431+ } ;
423432
424- exports . mustCall = function ( fn , expected ) {
433+ exports . mustCallAtLeast = function ( fn , minimum ) {
434+ return _mustCallInner ( fn , minimum , 'minimum' ) ;
435+ } ;
436+
437+ function _mustCallInner ( fn , criteria , field ) {
425438 if ( typeof fn === 'number' ) {
426- expected = fn ;
439+ criteria = fn ;
427440 fn = noop ;
428441 } else if ( fn === undefined ) {
429442 fn = noop ;
430443 }
431444
432- if ( expected === undefined )
433- expected = 1 ;
434- else if ( typeof expected !== 'number' )
435- throw new TypeError ( `Invalid expected value: ${ expected } ` ) ;
445+ if ( criteria === undefined )
446+ criteria = 1 ;
447+ else if ( typeof criteria !== 'number' )
448+ throw new TypeError ( `Invalid ${ field } value: ${ criteria } ` ) ;
436449
437450 const context = {
438- expected : expected ,
451+ [ field ] : criteria ,
439452 actual : 0 ,
440453 stack : ( new Error ( ) ) . stack ,
441454 name : fn . name || '<anonymous>'
@@ -450,7 +463,7 @@ exports.mustCall = function(fn, expected) {
450463 context . actual ++ ;
451464 return fn . apply ( this , arguments ) ;
452465 } ;
453- } ;
466+ }
454467
455468exports . hasMultiLocalhost = function hasMultiLocalhost ( ) {
456469 const TCP = process . binding ( 'tcp_wrap' ) . TCP ;
0 commit comments