diff options
author | 2023-01-31 17:55:16 -0800 | |
---|---|---|
committer | 2023-01-31 17:55:16 -0800 | |
commit | cc4326cd829decc95d1f1f23998f97705637e04b (patch) | |
tree | 9ccaa829b6d48af521d5e5fcdbabc0dac8d186af /test/bun.js/string-decoder.test.js | |
parent | c57b37d29f9d04780c7f7917789cf8b424710d23 (diff) | |
download | bun-cc4326cd829decc95d1f1f23998f97705637e04b.tar.gz bun-cc4326cd829decc95d1f1f23998f97705637e04b.tar.zst bun-cc4326cd829decc95d1f1f23998f97705637e04b.zip |
Re-run prettier after changes
Diffstat (limited to 'test/bun.js/string-decoder.test.js')
-rw-r--r-- | test/bun.js/string-decoder.test.js | 92 |
1 files changed, 17 insertions, 75 deletions
diff --git a/test/bun.js/string-decoder.test.js b/test/bun.js/string-decoder.test.js index 449f35620..4bc9d7e8b 100644 --- a/test/bun.js/string-decoder.test.js +++ b/test/bun.js/string-decoder.test.js @@ -4,9 +4,7 @@ import { withoutAggressiveGC } from "gc"; const RealStringDecoder = require("string_decoder").StringDecoder; it("require('string_decoder')", async () => { - expect((await import("string_decoder")).StringDecoder).toBe( - RealStringDecoder, - ); + expect((await import("string_decoder")).StringDecoder).toBe(RealStringDecoder); }); it("Bun.inspect(StringDecoder)", async () => { @@ -35,9 +33,7 @@ for (const StringDecoder of [FakeStringDecoderCall, RealStringDecoder]) { // U+3045 -> E3 81 85 test( "utf-8", - Buffer.from([ - 0xcb, 0xa4, 0x64, 0xe1, 0x8b, 0xa4, 0x30, 0xe3, 0x81, 0x85, - ]), + Buffer.from([0xcb, 0xa4, 0x64, 0xe1, 0x8b, 0xa4, 0x30, 0xe3, 0x81, 0x85]), "\u02e4\u0064\u12e4\u0030\u3045", ); }); @@ -60,9 +56,7 @@ for (const StringDecoder of [FakeStringDecoderCall, RealStringDecoder]) { expect(decoder.end()).toBe(""); decoder = new StringDecoder("utf8"); - expect(decoder.write(Buffer.from("\ufffd\ufffd\ufffd"))).toBe( - "\ufffd\ufffd\ufffd", - ); + expect(decoder.write(Buffer.from("\ufffd\ufffd\ufffd"))).toBe("\ufffd\ufffd\ufffd"); expect(decoder.end()).toBe(""); decoder = new StringDecoder("utf8"); @@ -114,10 +108,10 @@ for (const StringDecoder of [FakeStringDecoderCall, RealStringDecoder]) { } else { sequences = [singleSequence]; } - sequences.forEach((sequence) => { + sequences.forEach(sequence => { const decoder = new StringDecoder(encoding); let output = ""; - sequence.forEach((write) => { + sequence.forEach(write => { output += decoder.write(input.slice(write[0], write[1])); }); output += decoder.end(); @@ -146,28 +140,16 @@ for (const StringDecoder of [FakeStringDecoderCall, RealStringDecoder]) { let sequences = []; for (let end = length; end > start; end--) { const subSequence = sequence.concat([[start, end]]); - const subSequences = writeSequences( - length, - end, - subSequence, - sequences, - ); + const subSequences = writeSequences(length, end, subSequence, sequences); sequences = sequences.concat(subSequences); } return sequences; } describe("StringDecoder.end", () => { - const encodings = [ - "base64", - "base64url", - "hex", - "utf8", - "utf16le", - "ucs2", - ]; + const encodings = ["base64", "base64url", "hex", "utf8", "utf16le", "ucs2"]; - const bufs = ["☃💩", "asdf"].map((b) => Buffer.from(b)); + const bufs = ["☃💩", "asdf"].map(b => Buffer.from(b)); // Also test just arbitrary bytes from 0-15. for (let i = 1; i <= 16; i++) { @@ -189,72 +171,32 @@ for (const StringDecoder of [FakeStringDecoderCall, RealStringDecoder]) { testEnd("utf8", Buffer.of(0xe2, 0x82, 0xac), Buffer.of(0x61), "€a"); testEnd("utf16le", Buffer.of(0x3d), Buffer.of(0x61, 0x00), "a"); - testEnd( - "utf16le", - Buffer.of(0x3d), - Buffer.of(0xd8, 0x4d, 0xdc), - "\u4DD8", - ); + testEnd("utf16le", Buffer.of(0x3d), Buffer.of(0xd8, 0x4d, 0xdc), "\u4DD8"); testEnd("utf16le", Buffer.of(0x3d, 0xd8), Buffer.of(), "\uD83D"); - testEnd( - "utf16le", - Buffer.of(0x3d, 0xd8), - Buffer.of(0x61, 0x00), - "\uD83Da", - ); - testEnd( - "utf16le", - Buffer.of(0x3d, 0xd8), - Buffer.of(0x4d, 0xdc), - "\uD83D\uDC4D", - ); + testEnd("utf16le", Buffer.of(0x3d, 0xd8), Buffer.of(0x61, 0x00), "\uD83Da"); + testEnd("utf16le", Buffer.of(0x3d, 0xd8), Buffer.of(0x4d, 0xdc), "\uD83D\uDC4D"); testEnd("utf16le", Buffer.of(0x3d, 0xd8, 0x4d), Buffer.of(), "\uD83D"); - testEnd( - "utf16le", - Buffer.of(0x3d, 0xd8, 0x4d), - Buffer.of(0x61, 0x00), - "\uD83Da", - ); - testEnd( - "utf16le", - Buffer.of(0x3d, 0xd8, 0x4d), - Buffer.of(0xdc), - "\uD83D", - ); - testEnd( - "utf16le", - Buffer.of(0x3d, 0xd8, 0x4d, 0xdc), - Buffer.of(0x61, 0x00), - "👍a", - ); + testEnd("utf16le", Buffer.of(0x3d, 0xd8, 0x4d), Buffer.of(0x61, 0x00), "\uD83Da"); + testEnd("utf16le", Buffer.of(0x3d, 0xd8, 0x4d), Buffer.of(0xdc), "\uD83D"); + testEnd("utf16le", Buffer.of(0x3d, 0xd8, 0x4d, 0xdc), Buffer.of(0x61, 0x00), "👍a"); testEnd("base64", Buffer.of(0x61), Buffer.of(), "YQ=="); testEnd("base64", Buffer.of(0x61), Buffer.of(0x61), "YQ==YQ=="); testEnd("base64", Buffer.of(0x61, 0x61), Buffer.of(), "YWE="); testEnd("base64", Buffer.of(0x61, 0x61), Buffer.of(0x61), "YWE=YQ=="); testEnd("base64", Buffer.of(0x61, 0x61, 0x61), Buffer.of(), "YWFh"); - testEnd( - "base64", - Buffer.of(0x61, 0x61, 0x61), - Buffer.of(0x61), - "YWFhYQ==", - ); + testEnd("base64", Buffer.of(0x61, 0x61, 0x61), Buffer.of(0x61), "YWFhYQ=="); testEnd("base64url", Buffer.of(0x61), Buffer.of(), "YQ"); testEnd("base64url", Buffer.of(0x61), Buffer.of(0x61), "YQYQ"); testEnd("base64url", Buffer.of(0x61, 0x61), Buffer.of(), "YWE"); testEnd("base64url", Buffer.of(0x61, 0x61), Buffer.of(0x61), "YWEYQ"); testEnd("base64url", Buffer.of(0x61, 0x61, 0x61), Buffer.of(), "YWFh"); - testEnd( - "base64url", - Buffer.of(0x61, 0x61, 0x61), - Buffer.of(0x61), - "YWFhYQ", - ); + testEnd("base64url", Buffer.of(0x61, 0x61, 0x61), Buffer.of(0x61), "YWFhYQ"); function testEncoding(encoding) { it(encoding + " testbuf", () => { - bufs.forEach((buf) => { + bufs.forEach(buf => { testBuf(encoding, buf); }); }); |