aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/unsafe.test.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--integration/bunjs-only-snippets/unsafe.test.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/integration/bunjs-only-snippets/unsafe.test.js b/integration/bunjs-only-snippets/unsafe.test.js
index c8c241020..1ce0935d6 100644
--- a/integration/bunjs-only-snippets/unsafe.test.js
+++ b/integration/bunjs-only-snippets/unsafe.test.js
@@ -1,17 +1,26 @@
import { test, expect, it, describe } from "bun:test";
-it("arrayBufferToString u8", () => {
+it("arrayBufferToString u8", async () => {
var encoder = new TextEncoder();
const bytes = encoder.encode("hello world");
Bun.gc(true);
expect(Bun.unsafe.arrayBufferToString(bytes)).toBe("hello world");
+ Bun.gc(true);
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ Bun.gc(true);
});
-it("arrayBufferToString ArrayBuffer", () => {
+it("arrayBufferToString ArrayBuffer", async () => {
var encoder = new TextEncoder();
- const bytes = encoder.encode("hello world");
+ var bytes = encoder.encode("hello world");
Bun.gc(true);
- expect(Bun.unsafe.arrayBufferToString(bytes.buffer)).toBe("hello world");
+ const out = Bun.unsafe.arrayBufferToString(bytes.buffer);
+ expect(out).toBe("hello world");
+ Bun.gc(true);
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ globalThis.bytes = bytes;
+ Bun.gc(true);
+ expect(out).toBe("hello world");
});
it("arrayBufferToString u16", () => {
@@ -29,4 +38,5 @@ it("arrayBufferToString u16", () => {
}
Bun.gc(true);
expect(charCodes.length).toBe("hello world".length);
+ Bun.gc(true);
});