aboutsummaryrefslogtreecommitdiff
path: root/integration
diff options
context:
space:
mode:
Diffstat (limited to 'integration')
-rw-r--r--integration/bunjs-only-snippets/buffer.test.js42
1 files changed, 40 insertions, 2 deletions
diff --git a/integration/bunjs-only-snippets/buffer.test.js b/integration/bunjs-only-snippets/buffer.test.js
index 19502b285..c934f872d 100644
--- a/integration/bunjs-only-snippets/buffer.test.js
+++ b/integration/bunjs-only-snippets/buffer.test.js
@@ -1,22 +1,32 @@
+import { gc } from "bun";
import { describe, it, expect } from "bun:test";
it("buffer", () => {
var buf = new Buffer(20);
+ gc();
// if this fails or infinitely loops, it means there is a memory issue with the JSC::Structure object
expect(Object.keys(buf).length > 0).toBe(true);
-
+ gc();
expect(buf.write("hello world ")).toBe(12);
+ gc();
expect(buf.toString("utf8", 0, "hello world ".length)).toBe("hello world ");
+ gc();
expect(buf.toString("base64url", 0, "hello world ".length)).toBe(
btoa("hello world ")
);
-
+ gc();
expect(buf instanceof Uint8Array).toBe(true);
+ gc();
expect(buf instanceof Buffer).toBe(true);
+ gc();
expect(buf.slice() instanceof Uint8Array).toBe(true);
+ gc();
expect(buf.slice(0, 1) instanceof Buffer).toBe(true);
+ gc();
expect(buf.slice(0, 1) instanceof Uint8Array).toBe(true);
+ gc();
expect(buf.slice(0, 1) instanceof Buffer).toBe(true);
+ gc();
});
it("Buffer", () => {
@@ -29,10 +39,31 @@ it("Buffer", () => {
for (let i = 0; i < inputs.length; i++) {
var input = inputs[i];
expect(new Buffer(input).toString("utf8")).toBe(inputs[i]);
+ gc();
expect(Array.from(new Buffer(input)).join(",")).toBe(good[i].join(","));
+ gc();
}
});
+it("Buffer.isBuffer", () => {
+ expect(Buffer.isBuffer(new Buffer(1))).toBe(true);
+ gc();
+ expect(Buffer.isBuffer(new Buffer(0))).toBe(true);
+ gc();
+ expect(Buffer.isBuffer(new Uint8Array(0))).toBe(false);
+ gc();
+ expect(Buffer.isBuffer(new Uint8Array(1))).toBe(false);
+ gc();
+ var a = new Uint8Array(1);
+ gc();
+ expect(Buffer.isBuffer(a)).toBe(false);
+ gc();
+ Buffer.toBuffer(a);
+ gc();
+ expect(Buffer.isBuffer(a)).toBe(true);
+ gc();
+});
+
it("Buffer.toBuffer throws", () => {
const checks = [
[],
@@ -61,10 +92,13 @@ it("Buffer.toBuffer works", () => {
expect(Object.keys(buf).length > 0).toBe(true);
expect(buf.write("hello world ")).toBe(12);
+ gc();
expect(buf.toString("utf8", 0, "hello world ".length)).toBe("hello world ");
+ gc();
expect(buf.toString("base64url", 0, "hello world ".length)).toBe(
btoa("hello world ")
);
+ gc();
expect(buf instanceof Uint8Array).toBe(true);
expect(buf instanceof Buffer).toBe(true);
@@ -96,6 +130,7 @@ it("Buffer.from", () => {
expect(Buffer.from("hello world", "latin1").toString("utf8")).toBe(
"hello world"
);
+ gc();
expect(Buffer.from([254]).join(",")).toBe("254");
expect(Buffer.from(123).join(",")).toBe(Uint8Array.from(123).join(","));
expect(Buffer.from({ length: 124 }).join(",")).toBe(
@@ -109,6 +144,7 @@ it("Buffer.from", () => {
expect(Buffer.from(new Buffer(new ArrayBuffer(1024), 0, 512)).join(",")).toBe(
new Uint8Array(512).join(",")
);
+ gc();
});
it("Buffer.copy", () => {
@@ -120,6 +156,7 @@ it("Buffer.copy", () => {
Buffer.toBuffer(array2);
var array3 = new Uint8Array(128);
Buffer.toBuffer(array3);
+ gc();
expect(array1.copy(array2)).toBe(128);
expect(array1.join("")).toBe(array2.join(""));
});
@@ -131,6 +168,7 @@ it("Buffer.concat", () => {
array2.fill(200);
var array3 = new Uint8Array(128);
array3.fill(300);
+ gc();
expect(Buffer.concat([array1, array2, array3]).join("")).toBe(
array1.join("") + array2.join("") + array3.join("")
);
ss='logsubject'>Remove support for simple objects in endpoints (#9181)Gravatar Bjorn Lu 56-529/+206 * Deprecate simple object from endpoints * Update changeset * Add missing Response return Co-authored-by: Happydev <81974850+MoustaphaDev@users.noreply.github.com> * Update .changeset/clever-beds-notice.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> --------- Co-authored-by: Happydev <81974850+MoustaphaDev@users.noreply.github.com> Co-authored-by: Matthew Phillips <matthew@skypack.dev> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> 2023-11-28Remove shiki lang path property support (#9196)Gravatar Bjorn Lu 7-427/+22 2023-11-28Remove deprecated features from Astro 3.0 (#9168)Gravatar Bjorn Lu 47-398/+95 2023-11-28Remove deprecated markdown-remark APIs (#9182)Gravatar Bjorn Lu 4-59/+7 2023-11-27[ci] release (#9180)astro@3.6.1Gravatar Houston (Bot) 32-65/+63 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> 2023-11-24Remove vercel deprecated analytics option (#9184)Gravatar Bjorn Lu 3-30/+12 2023-11-24[ci] formatGravatar Guspan Tanadi 1-2/+1 2023-11-24style: highlight markdown Tip Note section CONTRIBUTING (#9123)Gravatar Guspan Tanadi 1-5/+7 2023-11-23fix scroll restoration issue on webKit browsers (#9186)Gravatar Martin Trapp 2-1/+7 * fix scroll restoration issue on webKit browsers * add changeset * Update .changeset/shaggy-socks-glow.md * Update .changeset/shaggy-socks-glow.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> --------- Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> 2023-11-23fix(middleware): rename internal middleware id (#9173)Gravatar Arsh 2-1/+6 * rename internal middleware id * add changeset 2023-11-23fix: Changelog formatting for 3.6.0 View Transition events (#9176)Gravatar Martin Trapp 1-3/+3 Co-authored-by: Eva Decker <itsevadecker@gmail.com> 2023-11-22[ci] formatGravatar Eva Decker 1-3/+3 2023-11-22Fix View Transitions code block formatting (#9174)Gravatar Eva Decker 1-3/+3 2023-11-22Rename entryPoint to entrypoint (#9161)Gravatar Bjorn Lu 14-26/+38 Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> 2023-11-22Fix esbuild warning for local dev (#9160)Gravatar Bjorn Lu 1-1/+1 2023-11-22[ci] release (#9165)astro@3.6.0Gravatar Houston (Bot) 34-90/+83 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>