import { describe, it, expect, beforeEach, afterEach } from "bun:test"; import { gc } from "./gc"; beforeEach(() => gc()); afterEach(() => gc()); it("buffer", () => { var buf = new Buffer(20); gc(); // if this fails or infinitely loops, it means there is a memory issue with the JSC::Structure object expect(Object.keys(buf).length > 0).toBe(true); gc(); expect(buf.write("hello world ")).toBe(12); expect(buf.write("hello world ", "utf8")).toBe(12); gc(); expect(buf.toString("utf8", 0, "hello world ".length)).toBe("hello world "); gc(); expect(buf.toString("base64url", 0, "hello world ".length)).toBe( btoa("hello world ") ); gc(); expect(buf instanceof Uint8Array).toBe(true); gc(); expect(buf instanceof Buffer).toBe(true); gc(); expect(buf.slice() instanceof Uint8Array).toBe(true); gc(); expect(buf.slice(0, 1) instanceof Buffer).toBe(true); gc(); expect(buf.slice(0, 1) instanceof Uint8Array).toBe(true); gc(); expect(buf.slice(0, 1) instanceof Buffer).toBe(true); gc(); }); it("Buffer", () => { var inputs = [ "hello world", "hello world".repeat(100), `πŸ˜‹ Get Emoji β€” All Emojis to βœ‚οΈ Copy and πŸ“‹ Paste πŸ‘Œ`, ]; var good = inputs.map((a) => new TextEncoder().encode(a)); for (let i = 0; i < inputs.length; i++) { var input = inputs[i]; expect(new Buffer(input).toString("utf8")).toBe(inputs[i]); gc(); expect(Array.from(new Buffer(input)).join(",")).toBe(good[i].join(",")); gc(); expect(Buffer.byteLength(input)).toBe(good[i].length); gc(); expect(Buffer.from(input).byteLength).toBe(Buffer.byteLength(input)); } }); it("Buffer.byteLength", () => { expect(Buffer.byteLength("πŸ˜€πŸ˜ƒπŸ˜„πŸ˜πŸ˜†πŸ˜…πŸ˜‚πŸ€£β˜ΊοΈπŸ˜ŠπŸ˜ŠπŸ˜‡")).toBe( new TextEncoder().encode("πŸ˜€πŸ˜ƒπŸ˜„πŸ˜πŸ˜†πŸ˜…πŸ˜‚πŸ€£β˜ΊοΈπŸ˜ŠπŸ˜ŠπŸ˜‡").byteLength ); }); it("Buffer.isBuffer", () => { expect(Buffer.isBuffer(new Buffer(1))).toBe(true); gc(); expect(Buffer.isBuffer(new Buffer(0))).toBe(true); gc(); expect(Buffer.isBuffer(new Uint8Array(0))).toBe(false); gc(); expect(Buffer.isBuffer(new Uint8Array(1))).toBe(false); gc(); var a = new Uint8Array(1); gc(); expect(Buffer.isBuffer(a)).toBe(false); gc(); Buffer.toBuffer(a); gc(); expect(Buffer.isBuffer(a)).toBe(true); gc(); }); it("Buffer.toBuffer throws", () => { const checks = [ [], {}, "foo", new Uint16Array(), new DataView(new Uint8Array(14).buffer), ]; for (let i = 0; i < checks.length; i++) { try { Buffer.toBuffer(checks[i]); expect(false).toBe(true); } catch (exception) { expect(exception.message).toBe("Expected Uint8Array"); } } expect(true).toBe(true); }); it("Buffer.toBuffer works", () => { var array = new Uint8Array(20); expect(array instanceof Buffer).toBe(false); var buf = Buffer.toBuffer(array); expect(array instanceof Buffer).toBe(true); // if this fails or infinitely loops, it means there is a memory issue with the JSC::Structure object expect(Object.keys(buf).length > 0).toBe(true); expect(buf.write("hello world ")).toBe(12); gc(); expect(buf.toString("utf8", 0, "hello world ".length)).toBe("hello world "); gc(); expect(buf.toString("base64url", 0, "hello world ".length)).toBe( btoa("hello world ") ); gc(); expect(buf instanceof Uint8Array).toBe(true); expect(buf instanceof Buffer).toBe(true); expect(buf.slice() instanceof Uint8Array).toBe(true); expect(buf.slice(0, 1) instanceof Buffer).toBe(true); expect(buf.slice(0, 1) instanceof Uint8Array).toBe(true); expect(buf.slice(0, 1) instanceof Buffer).toBe(true); expect(new Buffer(buf) instanceof Buffer).toBe(true); expect(new Buffer(buf.buffer) instanceof Buffer).toBe(true); }); it("writeInt", () => { var buf = new Buffer(1024); var data = new DataView(buf.buffer); buf.writeInt32BE(100); expect(data.getInt32(0, false)).toBe(100); buf.writeInt32BE(100); expect(data.getInt32(0, false)).toBe(100); var childBuf = buf.subarray(0, 4); expect(data.getInt32(0, false)).toBe(100); expect(childBuf.readInt32BE(0, false)).toBe(100); }); it("Buffer.from", () => { expect(Buffer.from("hello world").toString("utf8")).toBe("hello world"); expect(Buffer.from("hello world", "ascii").toString("utf8")).toBe( "hello world" ); expect(Buffer.from("hello world", "latin1").toString("utf8")).toBe( "hello world" ); gc(); expect(Buffer.from([254]).join(",")).toBe("254"); expect(Buffer.from(123).join(",")).toBe(Uint8Array.from(123).join(",")); expect(Buffer.from({ length: 124 }).join(",")).toBe( Uint8Array.from({ length: 124 }).join(",") ); expect(Buffer.from(new ArrayBuffer(1024), 0, 512).join(",")).toBe( new Uint8Array(512).join(",") ); expect(Buffer.from(new Buffer(new ArrayBuffer(1024), 0, 512)).join(",")).toBe( new Uint8Array(512).join(",") ); gc(); }); it("Buffer.equals", () => { var a = new Uint8Array(10); a[2] = 1; var b = new Uint8Array(10); b[2] = 1; Buffer.toBuffer(a); Buffer.toBuffer(b); expect(a.equals(b)).toBe(true); b[2] = 0; expect(a.equals(b)).toBe(false); }); it("Buffer.compare", () => { var a = new Uint8Array(10); a[2] = 1; var b = new Uint8Array(10); b[2] = 1; Buffer.toBuffer(a); Buffer.toBuffer(b); expect(a.compare(b)).toBe(0); b[2] = 0; expect(a.compare(b)).toBe(1); expect(b.compare(a)).toBe(-1); }); it("Buffer.copy", () => { var array1 = new Uint8Array(128); array1.fill(100); Buffer.toBuffer(array1); var array2 = new Uint8Array(128); array2.fill(200); Buffer.toBuffer(array2); var array3 = new Uint8Array(128); Buffer.toBuffer(array3); gc(); expect(array1.copy(array2)).toBe(128); expect(array1.join("")).toBe(array2.join("")); }); it("Buffer.concat", () => { var array1 = new Uint8Array(128); array1.fill(100); var array2 = new Uint8Array(128); array2.fill(200); var array3 = new Uint8Array(128); array3.fill(300); gc(); expect(Buffer.concat([array1, array2, array3]).join("")).toBe( array1.join("") + array2.join("") + array3.join("") ); expect(Buffer.concat([array1, array2, array3], 222).length).toBe(222); expect( Buffer.concat([array1, array2, array3], 222).subarray(0, 128).join("") ).toBe("100".repeat(128)); expect( Buffer.concat([array1, array2, array3], 222).subarray(129, 222).join("") ).toBe("200".repeat(222 - 129)); }); it("read", () => { var buf = new Buffer(1024); var data = new DataView(buf.buffer); function reset() { new Uint8Array(buf.buffer).fill(0); } data.setBigInt64(0, BigInt(1000), false); expect(buf.readBigInt64BE(0)).toBe(BigInt(1000)); reset(); data.setBigInt64(0, BigInt(1000), true); expect(buf.readBigInt64LE(0)).toBe(BigInt(1000)); reset(); data.setBigUint64(0, BigInt(1000), false); expect(buf.readBigUInt64BE(0)).toBe(BigInt(1000)); reset(); data.setBigUint64(0, BigInt(1000), true); expect(buf.readBigUInt64LE(0)).toBe(BigInt(1000)); reset(); data.setFloat64(0, 1000, false); expect(buf.readDoubleBE(0)).toBe(1000); reset(); data.setFloat64(0, 1000, true); expect(buf.readDoubleLE(0)).toBe(1000); reset(); data.setFloat32(0, 1000, false); expect(buf.readFloatBE(0)).toBe(1000); reset(); data.setFloat32(0, 1000, true); expect(buf.readFloatLE(0)).toBe(1000); reset(); data.setInt16(0, 1000, false); expect(buf.readInt16BE(0)).toBe(1000); reset(); data.setInt16(0, 1000, true); expect(buf.readInt16LE(0)).toBe(1000); reset(); data.setInt32(0, 1000, false); expect(buf.readInt32BE(0)).toBe(1000); reset(); data.setInt32(0, 1000, true); expect(buf.readInt32LE(0)).toBe(1000); reset(); data.setInt8(0, 100, false); expect(buf.readInt8(0)).toBe(100); reset(); data.setUint16(0, 1000, false); expect(buf.readUInt16BE(0)).toBe(1000); reset(); data.setUint16(0, 1000, true); expect(buf.readUInt16LE(0)).toBe(1000); reset(); data.setUint32(0, 1000, false); expect(buf.readUInt32BE(0)).toBe(1000); reset(); data.setUint32(0, 1000, true); expect(buf.readUInt32LE(0)).toBe(1000); reset(); data.setUint8(0, 255, false); expect(buf.readUInt8(0)).toBe(255); reset(); data.setUint8(0, 255, false); expect(buf.readUInt8(0)).toBe(255); reset(); }); s'>feat/indexes Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/.github (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2021-12-02Cleanup Actions (#2088)Gravatar Nate Moore 3-10/+32
* chore: actions cleanup * chore: make release messages more fun * chore: fix casing * chore(lint): Prettier fix Co-authored-by: GitHub Action <github-action@users.noreply.github.com>
2021-12-02Docs: Add Themes page in Zh-TW (#1725)Gravatar YM 2-0/+53
* Add 'Themes' page in zh-TW for docs * Update translations of Themes for Zh-tw in Doc * Update relative path for zh-TW docs
2021-12-02[ci] release (#2071)astro@0.21.7@astrojs/renderer-vue@0.2.1@astrojs/renderer-svelte@0.2.2@astrojs/renderer-solid@0.2.1@astrojs/renderer-react@0.3.1@astrojs/renderer-preact@0.3.1Gravatar github-actions[bot] 42-84/+92
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2021-12-02Allow special characters in filenames (#2091)Gravatar Drew Powers 4-1/+16
#2089
2021-12-02Add tests for assets using imports (#2090)Gravatar Matthew Phillips 4-0/+23
2021-12-02fix: renderer behavior with no children (#2078)Gravatar Nate Moore 27-19/+356
* fix: renderer behavior with no children * [ci] Prettier fix * Force CI * fix: properly handle falsy values * [ci] Prettier fix * chore: force ci * [experiment] netlify ignore Co-authored-by: GitHub Action <github-action@users.noreply.github.com>
2021-12-02Improve CSS import ordering, fix empty CSS outputs (#2081)Gravatar Drew Powers 4-12/+50
Fixes #2060
2021-12-02[experiment] ignore netlify builds outside of docs and wwwGravatar Nate Moore 3-4/+2
2021-12-02[experiment] Netlify Ignore (#2080)Gravatar Nate Moore 2-0/+4
* chore: ignore netlify builds for docs/ * chore: ignore netlify builds for www/ * chore: update netlify ignore to check against main
2021-12-02Makes Astro.resolve return root-relative paths (#2048)Gravatar Matthew Phillips 5-4/+35
* Makes Astro.resolve return root-relative paths * Adds a changeset * Update the compiler version and PR review * Fix linting * [ci] Prettier fix * Remove use of vitifyURL Co-authored-by: GitHub Action <github-action@users.noreply.github.com>
2021-12-02Invalidate based on modulePath (#2086)Gravatar Matthew Phillips 2-7/+9
* Invalidate based on modulePath * Adds a changeset
2021-12-01Update ci.yml (#2077)Gravatar Fred K. Schott 1-2/+7
2021-12-01[ci] yarn formatGravatar natemoo-re 2-4/+4
2021-12-01Improving error messages for invalid client hydration directives (#2076)Gravatar Tony Sullivan 6-0/+64
* Adding check to make sure the hydration directive is valid * remove temp debug logging * Adding a check for media query with client:media + small refactor * adding changeset Co-authored-by: Tony Sullivan <tony.sullivan@hyperlab.se>
2021-12-01Upgrade compiler to 0.5.4 (#2057)Gravatar Matthew Phillips 3-6/+6
* Upgrade compiler to 0.4.0 * chore: update compiler to v0.5.1 * chore: update compiler to v0.5.3 * chore: upgrade @astrojs/compiler * test: skip flaky test Co-authored-by: Nate Moore <nate@skypack.dev>
2021-12-01Render void elements as self-closing tags (#2064)Gravatar Jonathan Neal 5-1/+64
* Render void elements as self-closing tags * changeset * nit: only check void element names if there is no child content * nit: only check void element names if there is no child content * add tests
2021-12-01Allow importing of rehype plugins (#2075)Gravatar Drew Powers 3-1/+11
Fixes #2061
2021-12-01fix: release notes (#2074)Gravatar Nate Moore 1-1/+3
2021-12-01[ci] yarn formatGravatar natemoo-re 1-2/+2
2021-12-01Prevent unknown keys in markdownOptions (#2073)Gravatar Ian VanSchooten 2-0/+7
2021-12-01Add migration guide for markdownOptions (#2070)Gravatar Ian VanSchooten 1-0/+23
2021-12-01German translation - docs (#1830)Gravatar borisv 15-109/+1537
* New translation of getting-started.md Rework of the basic translation, resolving a bunch of issues and correcting misconceptions in terminologies. * Spelling correction * Omitting redundant paragraph. Minor corrections. * New translation Fixing errors and grammatical misconceptions. Rectifying terminology. * Minor corrections in quick-start.md * Update quick-start.md Minor corrections * Update quick-start.md Small fix * Update quick-start.md * Update getting-started.md * Update quick-start.md * Update quick-start.md * Update quick-start.md * New translation installation.md New translation leveraging a consistent nomenklatura, fixing spelling errors * Update installation.md * Update installation.md * Update installation.md * Update docs/src/pages/de/getting-started.md Co-authored-by: Kim Schneider <web@schneider.kim> * Update docs/src/pages/de/getting-started.md Co-authored-by: Kim Schneider <web@schneider.kim> * Update docs/src/pages/de/getting-started.md Co-authored-by: Kim Schneider <web@schneider.kim> * Update docs/src/pages/de/installation.md Co-authored-by: Kim Schneider <web@schneider.kim> * Update docs/src/pages/de/quick-start.md Co-authored-by: Kim Schneider <web@schneider.kim> * Update docs/src/pages/de/quick-start.md Co-authored-by: Kim Schneider <web@schneider.kim> * Update docs/src/pages/de/quick-start.md Co-authored-by: Kim Schneider <web@schneider.kim> * Update docs/src/pages/de/installation.md Co-authored-by: Kim Schneider <web@schneider.kim> * Update docs/src/pages/de/getting-started.md Co-authored-by: Kim Schneider <web@schneider.kim> * [ci] yarn format * Create 0.21.0.md First translation * [ci] yarn format * Create themes.astro First translation * Create 404.astro First translation * Update 0.21.0.md Small changes according to the reviews. Additionally changing 'Hydratation' to 'Anreicherung' in the code example (76), which is far more closer to the fact. * [ci] yarn format * Update themes.astro Changed 'Motive' to 'Vorlagen' throughout this document * Create comparing-astro-vs-other-tools.md First translation. Last missing page from the first documentation section 'SETUP' * [ci] yarn format * Create astro-components.md First translation * [ci] yarn format * Update comparing-astro-vs-other-tools.md Corrected reference to Vue in Nuxt section * Update comparing-astro-vs-other-tools.md Replaced 'Vorlagen' with the english term 'Templates' for consistency inside nomenclature across all document pages. * Create astro-pages.md First translation * [ci] yarn format * Create project-structure.md First translation * Create component-hydration.md New translation * [ci] yarn format * Create layouts.md First translation * Create routing.md First translation * [ci] yarn format * Update quick-start.md Changed expression to 'Entwickeln' * Update installation.md Changed expression to 'Entwickeln' * Update comparing-astro-vs-other-tools.md Changed all occurences of 'partielle Anreicherung' to 'Partial Hydration' * Update comparing-astro-vs-other-tools.md Minor punctuation fix * Update astro-components.md Bunch of suggestions worked in * [ci] yarn format * Update astro-pages.md Added suggestions * Update component-hydration.md Added suggestions * Update layouts.md Added suggestions * [ci] yarn format * Update project-structure.md Added suggestions * Update routing.md Added suggestions * Update installation.md Added suggestions * Update 0.21.0.md Added suggestions * Update quick-start.md added suggestions * Update themes.astro Added suggestions * Update 0.21.0.md Added suggestion * Update astro-components.md Minor punctuation fix * [ci] yarn format * Update astro-components.md Replaced last of 'Anreicherung' * Update astro-components.md Punctuation fix, again((( * [ci] yarn format * Update docs/src/pages/de/core-concepts/astro-components.md Minor punctioation fix Co-authored-by: Kim Schneider <web@schneider.kim> * [ci] yarn format * Update astro-components.md Added code example, since github hickubs when only removing ';' * Added sidebar links (de) config.ts Added links to the first two sections of the German translation * Update config.ts Replaced Getting Started with 'Erste Schritte' * Update config.ts Replaced Themes with 'Vorlagen' * Update config.ts Changed Migration to 'Umstellung' * Fixing routing error((( * Fixing routing errors(( * reverse and fix routing errors((( Co-authored-by: Kim Schneider <web@schneider.kim> Co-authored-by: borisv <borisv@users.noreply.github.com> Co-authored-by: smplrtrn <smplrtrn@gmail.com>
2021-12-01Enforce consistent import order of CSS (#2065)Gravatar Drew Powers 11-11/+134
Partially fixes #2060
2021-11-30[ci] release (#2059)astro@0.21.6Gravatar github-actions[bot] 26-37/+32
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2021-11-30Modify changeset for #2052 (#2067)Gravatar Drew Powers 1-1/+1