aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/unsafe.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'integration/bunjs-only-snippets/unsafe.test.js')
-rw-r--r--integration/bunjs-only-snippets/unsafe.test.js19
1 files changed, 10 insertions, 9 deletions
diff --git a/integration/bunjs-only-snippets/unsafe.test.js b/integration/bunjs-only-snippets/unsafe.test.js
index d47821f42..741dc0241 100644
--- a/integration/bunjs-only-snippets/unsafe.test.js
+++ b/integration/bunjs-only-snippets/unsafe.test.js
@@ -1,25 +1,26 @@
import { test, expect, it, describe } from "bun:test";
+import { gc } from "./gc";
it("arrayBufferToString u8", async () => {
var encoder = new TextEncoder();
const bytes = encoder.encode("hello world");
- Bun.gc(true);
+ gc(true);
expect(Bun.unsafe.arrayBufferToString(bytes)).toBe("hello world");
- Bun.gc(true);
+ gc(true);
await new Promise((resolve) => setTimeout(resolve, 0));
- Bun.gc(true);
+ gc(true);
});
it("arrayBufferToString ArrayBuffer", async () => {
var encoder = new TextEncoder();
var bytes = encoder.encode("hello world");
- Bun.gc(true);
+ gc(true);
const out = Bun.unsafe.arrayBufferToString(bytes.buffer);
expect(out).toBe("hello world");
- Bun.gc(true);
+ gc(true);
await new Promise((resolve) => setTimeout(resolve, 0));
globalThis.bytes = bytes;
- Bun.gc(true);
+ gc(true);
expect(out).toBe("hello world");
});
@@ -32,13 +33,13 @@ it("arrayBufferToString u16", () => {
.arrayBufferToString(uint16)
.split("")
.map((a) => a.charCodeAt(0));
- Bun.gc(true);
+ gc(true);
for (let i = 0; i < charCodes.length; i++) {
expect("hello world"[i]).toBe(String.fromCharCode(charCodes[i]));
}
- Bun.gc(true);
+ gc(true);
expect(charCodes.length).toBe("hello world".length);
- Bun.gc(true);
+ gc(true);
});
it("Bun.allocUnsafe", () => {