aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/unsafe.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-06-20 21:35:22 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-06-22 06:56:47 -0700
commit41b03b5c4c426bd3f2a3c7c6aaf454cee11744f0 (patch)
treefd1819ed5dfbe58edfe971b7c05c2c59549b8251 /integration/bunjs-only-snippets/unsafe.test.js
parentbfa5b2955533a60b2f12e6ac65d4868efcaf5222 (diff)
downloadbun-41b03b5c4c426bd3f2a3c7c6aaf454cee11744f0.tar.gz
bun-41b03b5c4c426bd3f2a3c7c6aaf454cee11744f0.tar.zst
bun-41b03b5c4c426bd3f2a3c7c6aaf454cee11744f0.zip
Cleanup tests
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", () => {