import { expect, it, describe } from "bun:test"; import { gc as gcTrace, withoutAggressiveGC } from "./gc"; const getByteLength = (str) => { // returns the byte length of an utf8 string var s = str.length; for (var i = str.length - 1; i >= 0; i--) { var code = str.charCodeAt(i); if (code > 0x7f && code <= 0x7ff) s++; else if (code > 0x7ff && code <= 0xffff) s += 2; if (code >= 0xdc00 && code <= 0xdfff) i--; //trail surrogate } return s; }; describe("TextDecoder", () => { it("should decode ascii text", () => { const decoder = new TextDecoder("latin1"); gcTrace(true); expect(decoder.encoding).toBe("windows-1252"); gcTrace(true); expect(decoder.decode(new Uint8Array([0x41, 0x42, 0x43]))).toBe("ABC"); gcTrace(true); const result = [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]; gcTrace(true); expect(decoder.decode(Uint8Array.from(result))).toBe( String.fromCharCode(...result), ); gcTrace(true); }); it("should decode unicode text", () => { const decoder = new TextDecoder(); gcTrace(true); var text = `❤️ Red Heart`; const bytes = [ 226, 157, 164, 239, 184, 143, 32, 82, 101, 100, 32, 72, 101, 97, 114, 116, ]; const decoded = decoder.decode(Uint8Array.from(bytes)); expect(decoder.encoding).toBe("utf-8"); gcTrace(true); for (let i = 0; i < text.length; i++) { expect(decoded.charCodeAt(i)).toBe(text.charCodeAt(i)); } expect(decoded).toHaveLength(text.length); gcTrace(true); }); describe("typedArrays", () => { var text = `ABC DEF GHI JKL MNO PQR STU VWX YZ ABC DEF GHI JKL MNO PQR STU V`; var bytes = new TextEncoder().encode(text); var decoder = new TextDecoder(); for (let TypedArray of [ Uint8Array, Uint16Array, Uint32Array, Int8Array, Int16Array, Int32Array, Float32Array, Float64Array, DataView, BigInt64Array, BigUint64Array, ]) { it(`should decode ${TypedArray.name}`, () => { const decoded = decoder.decode(new TypedArray(bytes.buffer)); expect(decoded).toBe(text); }); } it("DOMJIT call", () => { const array = new Uint8Array(bytes.buffer); withoutAggressiveGC(() => { for (let i = 0; i < 100_000; i++) { const decoded = decoder.decode(array); expect(decoded).toBe(text); } }); }); }); it("should decode unicode text with multiple consecutive emoji", () => { const decoder = new TextDecoder(); const encoder = new TextEncoder(); gcTrace(true); var text = `❤️❤️❤️❤️❤️❤️ Red Heart`; text += ` ✨ Sparkles 🔥 Fire 😀 😃 😄 😁 😆 😅 😂 🤣 🥲 ☺️ 😊 😇 🙂 🙃 😉 😌 😍 🥰 😘 😗 😙 😚 😋 😛 😝 😜 🤪 🤨 🧐 🤓 😎 🥸 🤩 🥳 😏 😒 😞 😔 😟 😕 🙁 ☹️ 😣 😖 😫 😩 🥺 😢 😭 😤 😠 😡 🤬 🤯 😳 🥵 🥶 😱 😨 😰`; gcTrace(true); expect(decoder.decode(encoder.encode(text))).toBe(text); gcTrace(true); const bytes = new Uint8Array(getByteLength(text) * 8); gcTrace(true); const amount = encoder.encodeInto(text, bytes); gcTrace(true); expect(decoder.decode(bytes.subarray(0, amount.written))).toBe(text); gcTrace(true); }); }); it("truncated sequences", () => { const assert_equals = (a, b) => expect(a).toBe(b); // Truncated sequences assert_equals(new TextDecoder().decode(new Uint8Array([0xf0])), "\uFFFD"); assert_equals( new TextDecoder().decode(new Uint8Array([0xf0, 0x9f])), "\uFFFD", ); assert_equals( new TextDecoder().decode(new Uint8Array([0xf0, 0x9f, 0x92])), "\uFFFD", ); // Errors near end-of-queue assert_equals( new TextDecoder().decode(new Uint8Array([0xf0, 0x9f, 0x41])), "\uFFFDA", ); assert_equals( new TextDecoder().decode(new Uint8Array([0xf0, 0x41, 0x42])), "\uFFFDAB", ); assert_equals( new TextDecoder().decode(new Uint8Array([0xf0, 0x41, 0xf0])), "\uFFFDA\uFFFD", ); assert_equals( new TextDecoder().decode(new Uint8Array([0xf0, 0x8f, 0x92])), "\uFFFD\uFFFD\uFFFD", ); }); n value='examples/framework-vue'>examples/framework-vue Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/packages/integrations/prefetch/test/fixtures/basic-prefetch/src/pages/contact.astro (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-07-08[ci] formatGravatar bholmesdev 1-1/+1
2022-07-08chore: changeset (#3873)Gravatar Ben Holmes 3-1/+10
2022-07-08Add editor integrations to language integrations (#3864)Gravatar Erika 8-6/+131
2022-07-08[ci] formatGravatar tony-sull 7-38/+59
2022-07-08Adds a new `<Picture>` component to the image integration (#3866)Gravatar Tony Sullivan 28-164/+1052
2022-07-08[ci] formatGravatar bholmesdev 7-31/+60
2022-07-08[astro add] Support adapters and third party packages (#3854)Gravatar Ben Holmes 20-37/+221
2022-07-08Ignore big formatting commit (#3870)Gravatar Marcus Otterström 1-1/+3
2022-07-08[ci] formatGravatar tony-sull 1-3/+3
2022-07-08fix: Always add @astrojs/image to vite.ssr.noExternal (#3869)Gravatar Tony Sullivan 2-0/+8
2022-07-08Format astro files in examples (#3862)Gravatar Marcus Otterström 73-694/+957
2022-07-08Integration README fixes (#3865)Gravatar Chris Swithinbank 8-8/+17
2022-07-08fix(#3843): move @babel/types to dependencies (#3863)Gravatar Nate Moore 2-2/+2
2022-07-08Fixed broken Markdown link (#3868)Gravatar Isaac McFadyen 1-2/+2
2022-07-08chore: bump Vite minimum version (#3861)Gravatar Nate Moore 2-2/+2
2022-07-08[ci] formatGravatar matthewp 1-1/+1
2022-07-08Better response.arrayBuffer() handling in Node (#3860)Gravatar Matthew Phillips 8-3/+125
2022-07-08[ci] update lockfile (#3858)Gravatar Fred K. Bot 1-411/+437
2022-07-08Fix manual import (#3857)Gravatar Chris Williams 1-1/+1
2022-07-07[ci] formatGravatar bholmesdev 1-3/+3
2022-07-07Docs: add adapter heading for configuration docs (#3842)Gravatar Ben Holmes 2-4/+20
2022-07-07[ci] formatGravatar natemoo-re 2-3/+3
2022-07-07fix: lint failing on astro and some integrations (#3794)Gravatar Joaquín Sánchez 7-17/+18
2022-07-07update solid peer dependenciesGravatar Fred K. Schott 2-1/+6
2022-07-07update lockfile (#3828)Gravatar Fred K. Schott 3-7/+1
2022-07-07Improve JSX definitions (#3801)Gravatar Erika 2-477/+858
2022-07-07Fix slot attribute inside expressions (#3837)Gravatar Nate Moore 8-5/+89
2022-07-07[ci] formatGravatar FredKSchott 1-2/+1
2022-07-07detect package manager and improve types (#3847)Gravatar Fred K. Schott 7-44/+78
2022-07-07small create-astro wording changes (#3831)Gravatar Fred K. Schott 3-10/+15
2022-07-07Upgrade to pnpm@7.4.1, remove `patch-package` (#3747)Gravatar Nate Moore 6-127/+100
2022-07-07[ci] formatGravatar matthewp 1-1/+1
2022-07-07Allow importing Image component from @astrojs/image (#3848)Gravatar Matthew Phillips 7-6/+20
2022-07-06[ci] release (#3818)astro@1.0.0-beta.64@astrojs/telemetry@0.2.4@astrojs/node@0.1.4Gravatar Fred K. Bot 41-90/+90
2022-07-07[ci] formatGravatar bholmesdev 1-1/+1
2022-07-06Fix: Infer content type with charset in dev and prod (#3841)Gravatar Ben Holmes 4-3/+23
2022-07-06[ci] formatGravatar bholmesdev 1-2/+2
2022-07-06Fix `client:visible` directive in safari (#3839)Gravatar Ben Holmes 2-2/+20
2022-07-06[ci] formatGravatar matthewp 1-1/+1
2022-07-06Ensure that maybeRenderHead runs last (#3821)Gravatar Matthew Phillips 5-8/+67
2022-07-05Fix portfolio example to use lowercase srcset (#3829)Gravatar Matthew Phillips 1-1/+1
2022-07-05[ci] formatGravatar delucis 1-29/+29