aboutsummaryrefslogtreecommitdiff
path: root/test/js/node
diff options
context:
space:
mode:
authorGravatar Ai Hoshino <ambiguous404@gmail.com> 2023-10-19 05:30:53 +0800
committerGravatar GitHub <noreply@github.com> 2023-10-18 14:30:53 -0700
commit0173571b19780ab71772b1efcb9c4e623cab0aca (patch)
treee6223b4ce6e110d0cc5c9403d7b4193247608a9c /test/js/node
parent35259c0c1d54f03691d95e7646e7cf368d780652 (diff)
downloadbun-0173571b19780ab71772b1efcb9c4e623cab0aca.tar.gz
bun-0173571b19780ab71772b1efcb9c4e623cab0aca.tar.zst
bun-0173571b19780ab71772b1efcb9c4e623cab0aca.zip
fix(node:buffer): fix the behavior of `totalLength` in `Buffer.concat` (#6574)
* fix(node:buffer): fix the behavior of `totalLength` in `Buffer.concat` Close: #6570 Close: #3639 * fix buffer totalLength type --------- Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
Diffstat (limited to 'test/js/node')
-rw-r--r--test/js/node/buffer.test.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/js/node/buffer.test.js b/test/js/node/buffer.test.js
index 0256934ce..450129b0e 100644
--- a/test/js/node/buffer.test.js
+++ b/test/js/node/buffer.test.js
@@ -1327,6 +1327,20 @@ it("Buffer.concat", () => {
expect(Buffer.concat([array1, array2, array3], 222).length).toBe(222);
expect(Buffer.concat([array1, array2, array3], 222).subarray(0, 128).join("")).toBe("100".repeat(128));
expect(Buffer.concat([array1, array2, array3], 222).subarray(129, 222).join("")).toBe("200".repeat(222 - 129));
+ expect(() => {
+ Buffer.concat([array1], -1);
+ }).toThrow(RangeError);
+ expect(() => {
+ Buffer.concat([array1], "1");
+ }).toThrow(TypeError);
+ // issue#6570
+ expect(Buffer.concat([array1, array2, array3], undefined).join("")).toBe(
+ array1.join("") + array2.join("") + array3.join(""),
+ );
+ // issue#3639
+ expect(Buffer.concat([array1, array2, array3], 128 * 4).join("")).toBe(
+ array1.join("") + array2.join("") + array3.join("") + Buffer.alloc(128).join(""),
+ );
});
it("read", () => {