11'use strict' ;
22
3- require ( '../common' ) ;
3+ const common = require ( '../common' ) ;
44
55const fixtures = require ( '../common/fixtures' ) ;
66const file = fixtures . path ( 'get-call-site.js' ) ;
@@ -19,6 +19,54 @@ const assert = require('node:assert');
1919 ) ;
2020}
2121
22+ {
23+ const callsite = getCallSite ( 3 ) ;
24+ assert . strictEqual ( callsite . length , 3 ) ;
25+ assert . match (
26+ callsite [ 0 ] . scriptName ,
27+ / t e s t - u t i l - g e t C a l l S i t e / ,
28+ 'node:util should be ignored' ,
29+ ) ;
30+ }
31+
32+ {
33+ const callsite = getCallSite ( 3.6 ) ;
34+ assert . strictEqual ( callsite . length , 3 ) ;
35+ }
36+
37+ {
38+ const callsite = getCallSite ( 3.4 ) ;
39+ assert . strictEqual ( callsite . length , 3 ) ;
40+ }
41+
42+ {
43+ assert . throws ( ( ) => {
44+ // Max than kDefaultMaxCallStackSizeToCapture
45+ getCallSite ( 201 ) ;
46+ } , common . expectsError ( {
47+ code : 'ERR_OUT_OF_RANGE'
48+ } ) ) ;
49+ assert . throws ( ( ) => {
50+ getCallSite ( - 1 ) ;
51+ } , common . expectsError ( {
52+ code : 'ERR_OUT_OF_RANGE'
53+ } ) ) ;
54+ assert . throws ( ( ) => {
55+ getCallSite ( { } ) ;
56+ } , common . expectsError ( {
57+ code : 'ERR_INVALID_ARG_TYPE'
58+ } ) ) ;
59+ }
60+
61+ {
62+ const callsite = getCallSite ( 1 ) ;
63+ assert . strictEqual ( callsite . length , 1 ) ;
64+ assert . match (
65+ callsite [ 0 ] . scriptName ,
66+ / t e s t - u t i l - g e t C a l l S i t e / ,
67+ 'node:util should be ignored' ,
68+ ) ;
69+ }
2270
2371{
2472 const { status, stderr, stdout } = spawnSync (
0 commit comments