aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/concat.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/concat.test.js
parent25f820c6bf1d8ec6d444ef579cc036b8c0607b75 (diff)
downloadbun-729d445b6885f69dd2c6355f38707bd42851c791.tar.gz
bun-729d445b6885f69dd2c6355f38707bd42851c791.tar.zst
bun-729d445b6885f69dd2c6355f38707bd42851c791.zip
change the directory structurejarred/rename
Diffstat (limited to 'integration/bunjs-only-snippets/concat.test.js')
-rw-r--r--integration/bunjs-only-snippets/concat.test.js46
1 files changed, 0 insertions, 46 deletions
diff --git a/integration/bunjs-only-snippets/concat.test.js b/integration/bunjs-only-snippets/concat.test.js
deleted file mode 100644
index a965fdb94..000000000
--- a/integration/bunjs-only-snippets/concat.test.js
+++ /dev/null
@@ -1,46 +0,0 @@
-import { describe, it, expect } from "bun:test";
-import { gcTick } from "./gc";
-import { concatArrayBuffers } from "bun";
-
-describe("concat", () => {
- function polyfill(chunks) {
- var size = 0;
- for (const chunk of chunks) {
- size += chunk.byteLength;
- }
- var buffer = new ArrayBuffer(size);
- var view = new Uint8Array(buffer);
- var offset = 0;
- for (const chunk of chunks) {
- view.set(chunk, offset);
- offset += chunk.byteLength;
- }
- return buffer;
- }
-
- function concatToString(chunks) {
- return Array.from(new Uint8Array(concatArrayBuffers(chunks))).join("");
- }
-
- function polyfillToString(chunks) {
- return Array.from(new Uint8Array(polyfill(chunks))).join("");
- }
-
- it("works with one element", () => {
- expect(concatToString([new Uint8Array([123])])).toBe(
- polyfillToString([new Uint8Array([123])])
- );
- });
-
- it("works with two elements", () => {
- expect(
- concatToString([Uint8Array.from([123]), Uint8Array.from([456])])
- ).toBe(polyfillToString([Uint8Array.from([123]), Uint8Array.from([456])]));
- });
-
- it("works with mix of ArrayBuffer and TypedArray elements", () => {
- expect(
- concatToString([Uint8Array.from([123]).buffer, Uint8Array.from([456])])
- ).toBe(polyfillToString([Uint8Array.from([123]), Uint8Array.from([456])]));
- });
-});