From f7e4eb83694aa007a492ef66c28ffbe6a2dae791 Mon Sep 17 00:00:00 2001 From: Ashcon Partovi Date: Tue, 7 Mar 2023 12:22:34 -0800 Subject: Reorganize tests (#2332) --- test/bun.js/concat.test.js | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 test/bun.js/concat.test.js (limited to 'test/bun.js/concat.test.js') diff --git a/test/bun.js/concat.test.js b/test/bun.js/concat.test.js deleted file mode 100644 index 36421cab6..000000000 --- a/test/bun.js/concat.test.js +++ /dev/null @@ -1,44 +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])]), - ); - }); -}); -- cgit v1.2.3