@@ -49,7 +49,7 @@ testBufs('\u0222aa', 8, 1, 'utf8');
4949testBufs ( 'a\u0234b\u0235c\u0236' , 4 , - 1 , 'utf8' ) ;
5050testBufs ( 'a\u0234b\u0235c\u0236' , 4 , 1 , 'utf8' ) ;
5151testBufs ( 'a\u0234b\u0235c\u0236' , 12 , 1 , 'utf8' ) ;
52- assert . equal ( Buffer . allocUnsafe ( 1 ) . fill ( 0 ) . fill ( '\u0222' ) [ 0 ] , 0xc8 ) ;
52+ assert . strictEqual ( Buffer . allocUnsafe ( 1 ) . fill ( 0 ) . fill ( '\u0222' ) [ 0 ] , 0xc8 ) ;
5353
5454
5555// BINARY
@@ -112,8 +112,8 @@ testBufs('\u0222aa', 8, 1, 'ucs2');
112112testBufs ( 'a\u0234b\u0235c\u0236' , 4 , - 1 , 'ucs2' ) ;
113113testBufs ( 'a\u0234b\u0235c\u0236' , 4 , 1 , 'ucs2' ) ;
114114testBufs ( 'a\u0234b\u0235c\u0236' , 12 , 1 , 'ucs2' ) ;
115- assert . equal ( Buffer . allocUnsafe ( 1 ) . fill ( '\u0222' , 'ucs2' ) [ 0 ] ,
116- os . endianness ( ) === 'LE' ? 0x22 : 0x02 ) ;
115+ assert . strictEqual ( Buffer . allocUnsafe ( 1 ) . fill ( '\u0222' , 'ucs2' ) [ 0 ] ,
116+ os . endianness ( ) === 'LE' ? 0x22 : 0x02 ) ;
117117
118118
119119// HEX
@@ -137,7 +137,8 @@ testBufs('61c8b462c8b563c8b6', 4, 1, 'hex');
137137testBufs ( '61c8b462c8b563c8b6' , 12 , 1 , 'hex' ) ;
138138// Make sure this operation doesn't go on forever
139139buf1 . fill ( 'yKJh' , 'hex' ) ;
140- assert . throws ( ( ) => buf1 . fill ( '\u0222' , 'hex' ) ) ;
140+ assert . throws ( ( ) =>
141+ buf1 . fill ( '\u0222' , 'hex' ) , / ^ T y p e E r r o r : I n v a l i d h e x s t r i n g $ / ) ;
141142
142143
143144// BASE64
@@ -183,14 +184,25 @@ deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, -1]), [0, 0, 0, 0]);
183184
184185
185186// Check exceptions
186- assert . throws ( ( ) => buf1 . fill ( 0 , - 1 ) ) ;
187- assert . throws ( ( ) => buf1 . fill ( 0 , 0 , buf1 . length + 1 ) ) ;
188- assert . throws ( ( ) => buf1 . fill ( '' , - 1 ) ) ;
189- assert . throws ( ( ) => buf1 . fill ( '' , 0 , buf1 . length + 1 ) ) ;
190- assert . throws ( ( ) => buf1 . fill ( 'a' , 0 , buf1 . length , 'node rocks!' ) ) ;
191- assert . throws ( ( ) => buf1 . fill ( 'a' , 0 , 0 , NaN ) ) ;
192- assert . throws ( ( ) => buf1 . fill ( 'a' , 0 , 0 , null ) ) ;
193- assert . throws ( ( ) => buf1 . fill ( 'a' , 0 , 0 , 'foo' ) ) ;
187+ assert . throws ( ( ) => buf1 . fill ( 0 , - 1 ) , / ^ R a n g e E r r o r : O u t o f r a n g e i n d e x $ / ) ;
188+ assert . throws ( ( ) =>
189+ buf1 . fill ( 0 , 0 , buf1 . length + 1 ) ,
190+ / ^ R a n g e E r r o r : O u t o f r a n g e i n d e x $ / ) ;
191+ assert . throws ( ( ) => buf1 . fill ( '' , - 1 ) , / ^ R a n g e E r r o r : O u t o f r a n g e i n d e x $ / ) ;
192+ assert . throws ( ( ) =>
193+ buf1 . fill ( '' , 0 , buf1 . length + 1 ) ,
194+ / ^ R a n g e E r r o r : O u t o f r a n g e i n d e x $ / ) ;
195+ assert . throws ( ( ) =>
196+ buf1 . fill ( 'a' , 0 , buf1 . length , 'node rocks!' ) ,
197+ / ^ T y p e E r r o r : U n k n o w n e n c o d i n g : n o d e r o c k s ! $ / ) ;
198+ assert . throws ( ( ) =>
199+ buf1 . fill ( 'a' , 0 , 0 , NaN ) ,
200+ / ^ T y p e E r r o r : e n c o d i n g m u s t b e a s t r i n g $ / ) ;
201+ assert . throws ( ( ) =>
202+ buf1 . fill ( 'a' , 0 , 0 , null ) ,
203+ / ^ T y p e E r r o r : e n c o d i n g m u s t b e a s t r i n g $ / ) ;
204+ assert . throws ( ( ) =>
205+ buf1 . fill ( 'a' , 0 , 0 , 'foo' ) , / ^ T y p e E r r o r : U n k n o w n e n c o d i n g : f o o $ / ) ;
194206
195207
196208function genBuffer ( size , args ) {
@@ -269,8 +281,12 @@ function testBufs(string, offset, length, encoding) {
269281}
270282
271283// Make sure these throw.
272- assert . throws ( ( ) => Buffer . allocUnsafe ( 8 ) . fill ( 'a' , - 1 ) ) ;
273- assert . throws ( ( ) => Buffer . allocUnsafe ( 8 ) . fill ( 'a' , 0 , 9 ) ) ;
284+ assert . throws ( ( ) =>
285+ Buffer . allocUnsafe ( 8 ) . fill ( 'a' , - 1 ) ,
286+ / ^ R a n g e E r r o r : O u t o f r a n g e i n d e x $ / ) ;
287+ assert . throws ( ( ) =>
288+ Buffer . allocUnsafe ( 8 ) . fill ( 'a' , 0 , 9 ) ,
289+ / ^ R a n g e E r r o r : O u t o f r a n g e i n d e x $ / ) ;
274290
275291// Make sure this doesn't hang indefinitely.
276292Buffer . allocUnsafe ( 8 ) . fill ( '' ) ;
@@ -369,7 +385,7 @@ assert.throws(() => {
369385 }
370386 } ;
371387 Buffer . alloc ( 1 ) . fill ( Buffer . alloc ( 1 ) , 0 , end ) ;
372- } ) ;
388+ } , / ^ R a n g e E r r o r : o u t o f r a n g e i n d e x $ / ) ;
373389 // Make sure -1 is making it to Buffer::Fill().
374390 assert . ok ( elseWasLast ,
375391 'internal API changed, -1 no longer in correct location' ) ;
@@ -389,4 +405,4 @@ assert.throws(() => {
389405 enumerable : true
390406 } ) ;
391407 buf . fill ( '' ) ;
392- } ) ;
408+ } , / ^ R a n g e E r r o r : o u t o f r a n g e i n d e x $ / ) ;
0 commit comments