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-22 23:21:48 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-06-22 23:21:48 -0700
commit729d445b6885f69dd2c6355f38707bd42851c791 (patch)
treef87a7c408929ea3f57bbb7ace380cf869da83c0e /integration/bunjs-only-snippets/unsafe.test.js
parent25f820c6bf1d8ec6d444ef579cc036b8c0607b75 (diff)
downloadbun-jarred/rename.tar.gz
bun-jarred/rename.tar.zst
bun-jarred/rename.zip
change the directory structurejarred/rename
Diffstat (limited to 'integration/bunjs-only-snippets/unsafe.test.js')
-rw-r--r--integration/bunjs-only-snippets/unsafe.test.js51
1 files changed, 0 insertions, 51 deletions
diff --git a/integration/bunjs-only-snippets/unsafe.test.js b/integration/bunjs-only-snippets/unsafe.test.js
deleted file mode 100644
index 741dc0241..000000000
--- a/integration/bunjs-only-snippets/unsafe.test.js
+++ /dev/null
@@ -1,51 +0,0 @@
-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");
- gc(true);
- expect(Bun.unsafe.arrayBufferToString(bytes)).toBe("hello world");
- gc(true);
- await new Promise((resolve) => setTimeout(resolve, 0));
- gc(true);
-});
-
-it("arrayBufferToString ArrayBuffer", async () => {
- var encoder = new TextEncoder();
- var bytes = encoder.encode("hello world");
- gc(true);
- const out = Bun.unsafe.arrayBufferToString(bytes.buffer);
- expect(out).toBe("hello world");
- gc(true);
- await new Promise((resolve) => setTimeout(resolve, 0));
- globalThis.bytes = bytes;
- gc(true);
- expect(out).toBe("hello world");
-});
-
-it("arrayBufferToString u16", () => {
- var encoder = new TextEncoder();
- const bytes = encoder.encode("hello world");
- var uint16 = new Uint16Array(bytes.byteLength);
- uint16.set(bytes);
- const charCodes = Bun.unsafe
- .arrayBufferToString(uint16)
- .split("")
- .map((a) => a.charCodeAt(0));
- gc(true);
- for (let i = 0; i < charCodes.length; i++) {
- expect("hello world"[i]).toBe(String.fromCharCode(charCodes[i]));
- }
- gc(true);
- expect(charCodes.length).toBe("hello world".length);
- gc(true);
-});
-
-it("Bun.allocUnsafe", () => {
- var buffer = Bun.allocUnsafe(1024);
- expect(buffer instanceof Uint8Array).toBe(true);
- expect(buffer.length).toBe(1024);
- buffer[0] = 0;
- expect(buffer[0]).toBe(0);
-});