22
33const common = require ( '../common' ) ;
44
5- const {
6- deepStrictEqual,
7- ok,
8- strictEqual,
9- throws,
10- } = require ( 'assert' ) ;
5+ const assert = require ( 'assert' ) ;
116
127const {
138 createHistogram,
@@ -19,64 +14,64 @@ const { inspect } = require('util');
1914{
2015 const h = createHistogram ( ) ;
2116
22- strictEqual ( h . min , 9223372036854776000 ) ;
23- strictEqual ( h . minBigInt , 9223372036854775807n ) ;
24- strictEqual ( h . max , 0 ) ;
25- strictEqual ( h . maxBigInt , 0n ) ;
26- strictEqual ( h . exceeds , 0 ) ;
27- strictEqual ( h . exceedsBigInt , 0n ) ;
28- ok ( Number . isNaN ( h . mean ) ) ;
29- ok ( Number . isNaN ( h . stddev ) ) ;
17+ assert . strictEqual ( h . min , 9223372036854776000 ) ;
18+ assert . strictEqual ( h . minBigInt , 9223372036854775807n ) ;
19+ assert . strictEqual ( h . max , 0 ) ;
20+ assert . strictEqual ( h . maxBigInt , 0n ) ;
21+ assert . strictEqual ( h . exceeds , 0 ) ;
22+ assert . strictEqual ( h . exceedsBigInt , 0n ) ;
23+ assert . ok ( Number . isNaN ( h . mean ) ) ;
24+ assert . ok ( Number . isNaN ( h . stddev ) ) ;
3025
31- strictEqual ( h . count , 0 ) ;
32- strictEqual ( h . countBigInt , 0n ) ;
26+ assert . strictEqual ( h . count , 0 ) ;
27+ assert . strictEqual ( h . countBigInt , 0n ) ;
3328
3429 h . record ( 1 ) ;
3530
36- strictEqual ( h . count , 1 ) ;
37- strictEqual ( h . countBigInt , 1n ) ;
31+ assert . strictEqual ( h . count , 1 ) ;
32+ assert . strictEqual ( h . countBigInt , 1n ) ;
3833
3934 [ false , '' , { } , undefined , null ] . forEach ( ( i ) => {
40- throws ( ( ) => h . record ( i ) , {
35+ assert . throws ( ( ) => h . record ( i ) , {
4136 code : 'ERR_INVALID_ARG_TYPE'
4237 } ) ;
4338 } ) ;
4439 [ 0 , Number . MAX_SAFE_INTEGER + 1 ] . forEach ( ( i ) => {
45- throws ( ( ) => h . record ( i ) , {
40+ assert . throws ( ( ) => h . record ( i ) , {
4641 code : 'ERR_OUT_OF_RANGE'
4742 } ) ;
4843 } ) ;
4944
50- strictEqual ( h . min , 1 ) ;
51- strictEqual ( h . minBigInt , 1n ) ;
52- strictEqual ( h . max , 1 ) ;
53- strictEqual ( h . maxBigInt , 1n ) ;
54- strictEqual ( h . exceeds , 0 ) ;
55- strictEqual ( h . mean , 1 ) ;
56- strictEqual ( h . stddev , 0 ) ;
45+ assert . strictEqual ( h . min , 1 ) ;
46+ assert . strictEqual ( h . minBigInt , 1n ) ;
47+ assert . strictEqual ( h . max , 1 ) ;
48+ assert . strictEqual ( h . maxBigInt , 1n ) ;
49+ assert . strictEqual ( h . exceeds , 0 ) ;
50+ assert . strictEqual ( h . mean , 1 ) ;
51+ assert . strictEqual ( h . stddev , 0 ) ;
5752
58- strictEqual ( h . percentile ( 1 ) , 1 ) ;
59- strictEqual ( h . percentile ( 100 ) , 1 ) ;
53+ assert . strictEqual ( h . percentile ( 1 ) , 1 ) ;
54+ assert . strictEqual ( h . percentile ( 100 ) , 1 ) ;
6055
61- strictEqual ( h . percentileBigInt ( 1 ) , 1n ) ;
62- strictEqual ( h . percentileBigInt ( 100 ) , 1n ) ;
56+ assert . strictEqual ( h . percentileBigInt ( 1 ) , 1n ) ;
57+ assert . strictEqual ( h . percentileBigInt ( 100 ) , 1n ) ;
6358
64- deepStrictEqual ( h . percentiles , new Map ( [ [ 0 , 1 ] , [ 100 , 1 ] ] ) ) ;
59+ assert . deepStrictEqual ( h . percentiles , new Map ( [ [ 0 , 1 ] , [ 100 , 1 ] ] ) ) ;
6560
66- deepStrictEqual ( h . percentilesBigInt , new Map ( [ [ 0 , 1n ] , [ 100 , 1n ] ] ) ) ;
61+ assert . deepStrictEqual ( h . percentilesBigInt , new Map ( [ [ 0 , 1n ] , [ 100 , 1n ] ] ) ) ;
6762
6863 const mc = new MessageChannel ( ) ;
6964 mc . port1 . onmessage = common . mustCall ( ( { data } ) => {
70- strictEqual ( h . min , 1 ) ;
71- strictEqual ( h . max , 1 ) ;
72- strictEqual ( h . exceeds , 0 ) ;
73- strictEqual ( h . mean , 1 ) ;
74- strictEqual ( h . stddev , 0 ) ;
65+ assert . strictEqual ( h . min , 1 ) ;
66+ assert . strictEqual ( h . max , 1 ) ;
67+ assert . strictEqual ( h . exceeds , 0 ) ;
68+ assert . strictEqual ( h . mean , 1 ) ;
69+ assert . strictEqual ( h . stddev , 0 ) ;
7570
7671 data . record ( 2n ) ;
7772 data . recordDelta ( ) ;
7873
79- strictEqual ( h . max , 2 ) ;
74+ assert . strictEqual ( h . max , 2 ) ;
8075
8176 mc . port1 . close ( ) ;
8277 } ) ;
@@ -85,15 +80,15 @@ const { inspect } = require('util');
8580
8681{
8782 const e = monitorEventLoopDelay ( ) ;
88- strictEqual ( e . count , 0 ) ;
83+ assert . strictEqual ( e . count , 0 ) ;
8984 e . enable ( ) ;
9085 const mc = new MessageChannel ( ) ;
9186 mc . port1 . onmessage = common . mustCall ( ( { data } ) => {
92- strictEqual ( typeof data . min , 'number' ) ;
93- ok ( data . min > 0 ) ;
94- ok ( data . count > 0 ) ;
95- strictEqual ( data . disable , undefined ) ;
96- strictEqual ( data . enable , undefined ) ;
87+ assert . strictEqual ( typeof data . min , 'number' ) ;
88+ assert . ok ( data . min > 0 ) ;
89+ assert . ok ( data . count > 0 ) ;
90+ assert . strictEqual ( data . disable , undefined ) ;
91+ assert . strictEqual ( data . enable , undefined ) ;
9792 mc . port1 . close ( ) ;
9893 } ) ;
9994 const interval = setInterval ( ( ) => {
@@ -112,19 +107,19 @@ const { inspect } = require('util');
112107 histogram = hi ;
113108 }
114109 // The histogram should already be disabled.
115- strictEqual ( histogram . disable ( ) , false ) ;
110+ assert . strictEqual ( histogram . disable ( ) , false ) ;
116111}
117112
118113{
119114 const h = createHistogram ( ) ;
120- ok ( inspect ( h , { depth : null } ) . startsWith ( 'Histogram' ) ) ;
121- strictEqual ( inspect ( h , { depth : - 1 } ) , '[RecordableHistogram]' ) ;
115+ assert . ok ( inspect ( h , { depth : null } ) . startsWith ( 'Histogram' ) ) ;
116+ assert . strictEqual ( inspect ( h , { depth : - 1 } ) , '[RecordableHistogram]' ) ;
122117}
123118
124119{
125120 // Tests that RecordableHistogram is impossible to construct manually
126121 const h = createHistogram ( ) ;
127- throws ( ( ) => new h . constructor ( ) , { code : 'ERR_ILLEGAL_CONSTRUCTOR' } ) ;
122+ assert . throws ( ( ) => new h . constructor ( ) , { code : 'ERR_ILLEGAL_CONSTRUCTOR' } ) ;
128123}
129124
130125{
@@ -133,7 +128,7 @@ const { inspect } = require('util');
133128 1 ,
134129 null ,
135130 ] . forEach ( ( i ) => {
136- throws ( ( ) => createHistogram ( i ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
131+ assert . throws ( ( ) => createHistogram ( i ) , { code : 'ERR_INVALID_ARG_TYPE' } ) ;
137132 } ) ;
138133
139134 [
@@ -142,20 +137,20 @@ const { inspect } = require('util');
142137 null ,
143138 { } ,
144139 ] . forEach ( ( i ) => {
145- throws ( ( ) => createHistogram ( { lowest : i } ) , {
140+ assert . throws ( ( ) => createHistogram ( { lowest : i } ) , {
146141 code : 'ERR_INVALID_ARG_TYPE' ,
147142 } ) ;
148- throws ( ( ) => createHistogram ( { highest : i } ) , {
143+ assert . throws ( ( ) => createHistogram ( { highest : i } ) , {
149144 code : 'ERR_INVALID_ARG_TYPE' ,
150145 } ) ;
151- throws ( ( ) => createHistogram ( { figures : i } ) , {
146+ assert . throws ( ( ) => createHistogram ( { figures : i } ) , {
152147 code : 'ERR_INVALID_ARG_TYPE' ,
153148 } ) ;
154149 } ) ;
155150
156151 // Number greater than 5 is not allowed
157152 for ( const i of [ 6 , 10 ] ) {
158- throws ( ( ) => createHistogram ( { figures : i } ) , {
153+ assert . throws ( ( ) => createHistogram ( { figures : i } ) , {
159154 code : 'ERR_OUT_OF_RANGE' ,
160155 } ) ;
161156 }
@@ -169,20 +164,20 @@ const { inspect } = require('util');
169164
170165 h1 . record ( 1 ) ;
171166
172- strictEqual ( h2 . count , 0 ) ;
173- strictEqual ( h1 . count , 1 ) ;
167+ assert . strictEqual ( h2 . count , 0 ) ;
168+ assert . strictEqual ( h1 . count , 1 ) ;
174169
175170 h2 . add ( h1 ) ;
176171
177- strictEqual ( h2 . count , 1 ) ;
172+ assert . strictEqual ( h2 . count , 1 ) ;
178173
179174 [
180175 'hello' ,
181176 1 ,
182177 false ,
183178 { } ,
184179 ] . forEach ( ( i ) => {
185- throws ( ( ) => h1 . add ( i ) , {
180+ assert . throws ( ( ) => h1 . add ( i ) , {
186181 code : 'ERR_INVALID_ARG_TYPE' ,
187182 } ) ;
188183 } ) ;
0 commit comments