File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 44 ArrayPrototypePush,
55 Error,
66 FunctionPrototype,
7+ ObjectDefineProperty,
78 ReflectApply,
89 SafeSet,
910} = primordials ;
@@ -46,7 +47,7 @@ class CallTracker {
4647 const callChecks = this . #callChecks;
4748 callChecks . add ( context ) ;
4849
49- return function ( ) {
50+ function callsFn ( ) {
5051 context . actual ++ ;
5152 if ( context . actual === context . exact ) {
5253 // Once function has reached its call count remove it from
@@ -59,7 +60,13 @@ class CallTracker {
5960 callChecks . add ( context ) ;
6061 }
6162 return ReflectApply ( fn , this , arguments ) ;
62- } ;
63+ }
64+
65+ ObjectDefineProperty ( callsFn , 'length' , {
66+ value : fn . length
67+ } ) ;
68+
69+ return callsFn ;
6370 }
6471
6572 report ( ) {
Original file line number Diff line number Diff line change @@ -78,3 +78,17 @@ assert.throws(
7878 callsNoop ( ) ;
7979 tracker . verify ( ) ;
8080}
81+
82+ {
83+ function func ( ) { }
84+ const tracker = new assert . CallTracker ( ) ;
85+ const callsfunc = tracker . calls ( func ) ;
86+ assert . strictEqual ( func . length , callsfunc . length ) ;
87+ }
88+
89+ {
90+ function func ( a , b , c = 2 ) { }
91+ const tracker = new assert . CallTracker ( ) ;
92+ const callsfunc = tracker . calls ( func ) ;
93+ assert . strictEqual ( func . length , callsfunc . length ) ;
94+ }
You can’t perform that action at this time.
0 commit comments