Skip to content

Commit 2d2388d

Browse files
Trottjasnell
authored andcommitted
test: fix errors in test-buffer-alloc.js
This fixes test code that was mistaken landed by me this morning. (Code & Learn rush gone bad.) Sorry. Please fast track. PR-URL: #23645 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
1 parent 5e68333 commit 2d2388d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

test/parallel/test-buffer-alloc.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ const outOfBoundsError = {
7979
type: RangeError
8080
};
8181

82+
const outOfRangeError = {
83+
code: 'ERR_OUT_OF_RANGE',
84+
type: RangeError
85+
};
86+
8287
// try to write a 0-length string beyond the end of b
8388
common.expectsError(() => b.write('', 2048), outOfBoundsError);
8489

@@ -787,31 +792,31 @@ Buffer.from(Buffer.allocUnsafe(0), 0, 0);
787792
// issue GH-5587
788793
common.expectsError(
789794
() => Buffer.alloc(8).writeFloatLE(0, 5),
790-
outOfBoundsError
795+
outOfRangeError
791796
);
792797
common.expectsError(
793798
() => Buffer.alloc(16).writeDoubleLE(0, 9),
794-
outOfBoundsError
799+
outOfRangeError
795800
);
796801

797802
// attempt to overflow buffers, similar to previous bug in array buffers
798803
common.expectsError(
799804
() => Buffer.allocUnsafe(8).writeFloatLE(0.0, 0xffffffff),
800-
outOfBoundsError
805+
outOfRangeError
801806
);
802807
common.expectsError(
803808
() => Buffer.allocUnsafe(8).writeFloatLE(0.0, 0xffffffff),
804-
outOfBoundsError
809+
outOfRangeError
805810
);
806811

807812
// ensure negative values can't get past offset
808813
common.expectsError(
809814
() => Buffer.allocUnsafe(8).writeFloatLE(0.0, -1),
810-
outOfBoundsError
815+
outOfRangeError
811816
);
812817
common.expectsError(
813818
() => Buffer.allocUnsafe(8).writeFloatLE(0.0, -1),
814-
outOfBoundsError
819+
outOfRangeError
815820
);
816821

817822
// test for common write(U)IntLE/BE
@@ -1005,7 +1010,7 @@ common.expectsError(() => {
10051010
const a = Buffer.alloc(1);
10061011
const b = Buffer.alloc(1);
10071012
a.copy(b, 0, 0x100000000, 0x100000001);
1008-
}, outOfBoundsError);
1013+
}, outOfRangeError);
10091014

10101015
// Unpooled buffer (replaces SlowBuffer)
10111016
{

0 commit comments

Comments
 (0)