@@ -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'), /^TypeError: Invalid hex string$/);
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), /^RangeError: Out of range index$/);
188+ assert.throws(() =>
189+ buf1.fill(0, 0, buf1.length + 1),
190+ /^RangeError: Out of range index$/);
191+ assert.throws(() => buf1.fill('', -1), /^RangeError: Out of range index$/);
192+ assert.throws(() =>
193+ buf1.fill('', 0, buf1.length + 1),
194+ /^RangeError: Out of range index$/);
195+ assert.throws(() =>
196+ buf1.fill('a', 0, buf1.length, 'node rocks!'),
197+ /^TypeError: Unknown encoding: node rocks!$/);
198+ assert.throws(() =>
199+ buf1.fill('a', 0, 0, NaN),
200+ /^TypeError: encoding must be a string$/);
201+ assert.throws(() =>
202+ buf1.fill('a', 0, 0, null),
203+ /^TypeError: encoding must be a string$/);
204+ assert.throws(() =>
205+ buf1.fill('a', 0, 0, 'foo'), /^TypeError: Unknown encoding: foo$/);
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+ /^RangeError: Out of range index$/);
287+ assert.throws(() =>
288+ Buffer.allocUnsafe(8).fill('a', 0, 9),
289+ /^RangeError: Out of range index$/);
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+ }, /^RangeError: out of range index$/ );
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+ }, /^RangeError: out of range index$/ );
0 commit comments