3
3
const common = require ( '../common' ) ;
4
4
5
5
const fixtures = require ( '../common/fixtures' ) ;
6
- const file = fixtures . path ( 'get-call-site .js' ) ;
6
+ const file = fixtures . path ( 'get-call-sites .js' ) ;
7
7
8
- const { getCallSite } = require ( 'node:util' ) ;
8
+ const { getCallSites } = require ( 'node:util' ) ;
9
9
const { spawnSync } = require ( 'node:child_process' ) ;
10
10
const assert = require ( 'node:assert' ) ;
11
11
12
12
{
13
- const callsite = getCallSite ( ) ;
14
- assert . ok ( callsite . length > 1 ) ;
13
+ const callSites = getCallSites ( ) ;
14
+ assert . ok ( callSites . length > 1 ) ;
15
15
assert . match (
16
- callsite [ 0 ] . scriptName ,
17
- / t e s t - u t i l - g e t C a l l S i t e / ,
16
+ callSites [ 0 ] . scriptName ,
17
+ / t e s t - u t i l - g e t c a l l s i t e s / ,
18
18
'node:util should be ignored' ,
19
19
) ;
20
20
}
21
21
22
22
{
23
- const callsite = getCallSite ( 3 ) ;
24
- assert . strictEqual ( callsite . length , 3 ) ;
23
+ const callSites = getCallSites ( 3 ) ;
24
+ assert . strictEqual ( callSites . length , 3 ) ;
25
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 / ,
26
+ callSites [ 0 ] . scriptName ,
27
+ / t e s t - u t i l - g e t c a l l s i t e s / ,
28
28
'node:util should be ignored' ,
29
29
) ;
30
30
}
31
31
32
32
// Guarantee dot-left numbers are ignored
33
33
{
34
- const callsite = getCallSite ( 3.6 ) ;
35
- assert . strictEqual ( callsite . length , 3 ) ;
34
+ const callSites = getCallSites ( 3.6 ) ;
35
+ assert . strictEqual ( callSites . length , 3 ) ;
36
36
}
37
37
38
38
{
39
- const callsite = getCallSite ( 3.4 ) ;
40
- assert . strictEqual ( callsite . length , 3 ) ;
39
+ const callSites = getCallSites ( 3.4 ) ;
40
+ assert . strictEqual ( callSites . length , 3 ) ;
41
41
}
42
42
43
43
{
44
44
assert . throws ( ( ) => {
45
45
// Max than kDefaultMaxCallStackSizeToCapture
46
- getCallSite ( 201 ) ;
46
+ getCallSites ( 201 ) ;
47
47
} , common . expectsError ( {
48
48
code : 'ERR_OUT_OF_RANGE'
49
49
} ) ) ;
50
50
assert . throws ( ( ) => {
51
- getCallSite ( - 1 ) ;
51
+ getCallSites ( - 1 ) ;
52
52
} , common . expectsError ( {
53
53
code : 'ERR_OUT_OF_RANGE'
54
54
} ) ) ;
55
55
assert . throws ( ( ) => {
56
- getCallSite ( { } ) ;
56
+ getCallSites ( { } ) ;
57
57
} , common . expectsError ( {
58
58
code : 'ERR_INVALID_ARG_TYPE'
59
59
} ) ) ;
60
60
}
61
61
62
62
{
63
- const callsite = getCallSite ( 1 ) ;
64
- assert . strictEqual ( callsite . length , 1 ) ;
63
+ const callSites = getCallSites ( 1 ) ;
64
+ assert . strictEqual ( callSites . length , 1 ) ;
65
65
assert . match (
66
- callsite [ 0 ] . scriptName ,
67
- / t e s t - u t i l - g e t C a l l S i t e / ,
66
+ callSites [ 0 ] . scriptName ,
67
+ / t e s t - u t i l - g e t c a l l s i t e s / ,
68
68
'node:util should be ignored' ,
69
69
) ;
70
70
}
@@ -77,8 +77,8 @@ const assert = require('node:assert');
77
77
'-e' ,
78
78
`const util = require('util');
79
79
const assert = require('assert');
80
- assert.ok(util.getCallSite ().length > 1);
81
- process.stdout.write(util.getCallSite ()[0].scriptName);
80
+ assert.ok(util.getCallSites ().length > 1);
81
+ process.stdout.write(util.getCallSites ()[0].scriptName);
82
82
` ,
83
83
] ,
84
84
) ;
@@ -100,7 +100,7 @@ const assert = require('node:assert');
100
100
{
101
101
const originalStackTraceLimit = Error . stackTraceLimit ;
102
102
Error . stackTraceLimit = 0 ;
103
- const callsite = getCallSite ( ) ;
104
- assert . notStrictEqual ( callsite . length , 0 ) ;
103
+ const callSites = getCallSites ( ) ;
104
+ assert . notStrictEqual ( callSites . length , 0 ) ;
105
105
Error . stackTraceLimit = originalStackTraceLimit ;
106
106
}
0 commit comments