diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-03-29 04:03:49 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-28 13:03:49 -0400 |
commit | bced52505f32d6cca4f944bb610a8a26767908a8 (patch) | |
tree | da49a5df4b7bd6f8306248069228cd6bd0db1303 /std/encoding/csv_test.ts | |
parent | 1397b8e0e7c85762e19d88fde103342bfa563360 (diff) |
Update to Prettier 2 and use ES Private Fields (#4498)
Diffstat (limited to 'std/encoding/csv_test.ts')
-rw-r--r-- | std/encoding/csv_test.ts | 204 |
1 files changed, 102 insertions, 102 deletions
diff --git a/std/encoding/csv_test.ts b/std/encoding/csv_test.ts index 74ad00c72..cb61de433 100644 --- a/std/encoding/csv_test.ts +++ b/std/encoding/csv_test.ts @@ -14,20 +14,20 @@ const testCases = [ { Name: "Simple", Input: "a,b,c\n", - Output: [["a", "b", "c"]] + Output: [["a", "b", "c"]], }, { Name: "CRLF", Input: "a,b\r\nc,d\r\n", Output: [ ["a", "b"], - ["c", "d"] - ] + ["c", "d"], + ], }, { Name: "BareCR", Input: "a,b\rc,d\r\n", - Output: [["a", "b\rc", "d"]] + Output: [["a", "b\rc", "d"]], }, { Name: "RFC4180test", @@ -41,20 +41,20 @@ zzz,yyy,xxx`, ["#field1", "field2", "field3"], ["aaa", "bbb", "ccc"], ["a,a", `bbb`, "ccc"], - ["zzz", "yyy", "xxx"] + ["zzz", "yyy", "xxx"], ], - ignore: true + ignore: true, }, { Name: "NoEOLTest", Input: "a,b,c", - Output: [["a", "b", "c"]] + Output: [["a", "b", "c"]], }, { Name: "Semicolon", Input: "a;b;c\n", Output: [["a", "b", "c"]], - Comma: ";" + Comma: ";", }, { Name: "MultiLine", @@ -63,103 +63,103 @@ line","one line","three line field"`, Output: [["two\nline"], ["one line"], ["three\nline\nfield"]], - ignore: true + ignore: true, }, { Name: "BlankLine", Input: "a,b,c\n\nd,e,f\n\n", Output: [ ["a", "b", "c"], - ["d", "e", "f"] - ] + ["d", "e", "f"], + ], }, { Name: "BlankLineFieldCount", Input: "a,b,c\n\nd,e,f\n\n", Output: [ ["a", "b", "c"], - ["d", "e", "f"] + ["d", "e", "f"], ], UseFieldsPerRecord: true, - FieldsPerRecord: 0 + FieldsPerRecord: 0, }, { Name: "TrimSpace", Input: " a, b, c\n", Output: [["a", "b", "c"]], - TrimLeadingSpace: true + TrimLeadingSpace: true, }, { Name: "LeadingSpace", Input: " a, b, c\n", - Output: [[" a", " b", " c"]] + Output: [[" a", " b", " c"]], }, { Name: "Comment", Input: "#1,2,3\na,b,c\n#comment", Output: [["a", "b", "c"]], - Comment: "#" + Comment: "#", }, { Name: "NoComment", Input: "#1,2,3\na,b,c", Output: [ ["#1", "2", "3"], - ["a", "b", "c"] - ] + ["a", "b", "c"], + ], }, { Name: "LazyQuotes", Input: `a "word","1"2",a","b`, Output: [[`a "word"`, `1"2`, `a"`, `b`]], - LazyQuotes: true + LazyQuotes: true, }, { Name: "BareQuotes", Input: `a "word","1"2",a"`, Output: [[`a "word"`, `1"2`, `a"`]], - LazyQuotes: true + LazyQuotes: true, }, { Name: "BareDoubleQuotes", Input: `a""b,c`, Output: [[`a""b`, `c`]], - LazyQuotes: true + LazyQuotes: true, }, { Name: "BadDoubleQuotes", Input: `a""b,c`, - Error: ErrBareQuote + Error: ErrBareQuote, // Error: &ParseError{StartLine: 1, Line: 1, Column: 1, Err: ErrBareQuote}, }, { Name: "TrimQuote", Input: ` "a"," b",c`, Output: [["a", " b", "c"]], - TrimLeadingSpace: true + TrimLeadingSpace: true, }, { Name: "BadBareQuote", Input: `a "word","b"`, - Error: ErrBareQuote + Error: ErrBareQuote, // &ParseError{StartLine: 1, Line: 1, Column: 2, Err: ErrBareQuote} }, { Name: "BadTrailingQuote", Input: `"a word",b"`, - Error: ErrBareQuote + Error: ErrBareQuote, }, { Name: "ExtraneousQuote", Input: `"a "word","b"`, - Error: ErrBareQuote + Error: ErrBareQuote, }, { Name: "BadFieldCount", Input: "a,b,c\nd,e", Error: ErrFieldCount, UseFieldsPerRecord: true, - FieldsPerRecord: 0 + FieldsPerRecord: 0, }, { Name: "BadFieldCount1", @@ -167,37 +167,37 @@ field"`, // Error: &ParseError{StartLine: 1, Line: 1, Err: ErrFieldCount}, UseFieldsPerRecord: true, FieldsPerRecord: 2, - Error: ErrFieldCount + Error: ErrFieldCount, }, { Name: "FieldCount", Input: "a,b,c\nd,e", Output: [ ["a", "b", "c"], - ["d", "e"] - ] + ["d", "e"], + ], }, { Name: "TrailingCommaEOF", Input: "a,b,c,", - Output: [["a", "b", "c", ""]] + Output: [["a", "b", "c", ""]], }, { Name: "TrailingCommaEOL", Input: "a,b,c,\n", - Output: [["a", "b", "c", ""]] + Output: [["a", "b", "c", ""]], }, { Name: "TrailingCommaSpaceEOF", Input: "a,b,c, ", Output: [["a", "b", "c", ""]], - TrimLeadingSpace: true + TrimLeadingSpace: true, }, { Name: "TrailingCommaSpaceEOL", Input: "a,b,c, \n", Output: [["a", "b", "c", ""]], - TrimLeadingSpace: true + TrimLeadingSpace: true, }, { Name: "TrailingCommaLine3", @@ -205,14 +205,14 @@ field"`, Output: [ ["a", "b", "c"], ["d", "e", "f"], - ["g", "hi", ""] + ["g", "hi", ""], ], - TrimLeadingSpace: true + TrimLeadingSpace: true, }, { Name: "NotTrailingComma3", Input: "a,b,c, \n", - Output: [["a", "b", "c", " "]] + Output: [["a", "b", "c", " "]], }, { Name: "CommaFieldTest", @@ -237,98 +237,98 @@ x,,, ["x", "y", "z", ""], ["x", "y", "", ""], ["x", "", "", ""], - ["", "", "", ""] - ] + ["", "", "", ""], + ], }, { Name: "TrailingCommaIneffective1", Input: "a,b,\nc,d,e", Output: [ ["a", "b", ""], - ["c", "d", "e"] + ["c", "d", "e"], ], - TrimLeadingSpace: true + TrimLeadingSpace: true, }, { Name: "ReadAllReuseRecord", Input: "a,b\nc,d", Output: [ ["a", "b"], - ["c", "d"] + ["c", "d"], ], - ReuseRecord: true + ReuseRecord: true, }, { Name: "StartLine1", // Issue 19019 Input: 'a,"b\nc"d,e', Error: true, // Error: &ParseError{StartLine: 1, Line: 2, Column: 1, Err: ErrQuote}, - ignore: true + ignore: true, }, { Name: "StartLine2", Input: 'a,b\n"d\n\n,e', Error: true, // Error: &ParseError{StartLine: 2, Line: 5, Column: 0, Err: ErrQuote}, - ignore: true + ignore: true, }, { Name: "CRLFInQuotedField", // Issue 21201 Input: 'A,"Hello\r\nHi",B\r\n', Output: [["A", "Hello\nHi", "B"]], - ignore: true + ignore: true, }, { Name: "BinaryBlobField", // Issue 19410 Input: "x09\x41\xb4\x1c,aktau", - Output: [["x09A\xb4\x1c", "aktau"]] + Output: [["x09A\xb4\x1c", "aktau"]], }, { Name: "TrailingCR", Input: "field1,field2\r", Output: [["field1", "field2"]], - ignore: true + ignore: true, }, { Name: "QuotedTrailingCR", Input: '"field"\r', Output: [['"field"']], - ignore: true + ignore: true, }, { Name: "QuotedTrailingCRCR", Input: '"field"\r\r', Error: true, // Error: &ParseError{StartLine: 1, Line: 1, Column: 6, Err: ErrQuote}, - ignore: true + ignore: true, }, { Name: "FieldCR", Input: "field\rfield\r", Output: [["field\rfield"]], - ignore: true + ignore: true, }, { Name: "FieldCRCR", Input: "field\r\rfield\r\r", Output: [["field\r\rfield\r"]], - ignore: true + ignore: true, }, { Name: "FieldCRCRLF", Input: "field\r\r\nfield\r\r\n", - Output: [["field\r"], ["field\r"]] + Output: [["field\r"], ["field\r"]], }, { Name: "FieldCRCRLFCR", Input: "field\r\r\n\rfield\r\r\n\r", - Output: [["field\r"], ["\rfield\r"]] + Output: [["field\r"], ["\rfield\r"]], }, { Name: "FieldCRCRLFCRCR", Input: "field\r\r\n\r\rfield\r\r\n\r\r", Output: [["field\r"], ["\r\rfield\r"], ["\r"]], - ignore: true + ignore: true, }, { Name: "MultiFieldCRCRLFCRCR", @@ -336,9 +336,9 @@ x,,, Output: [ ["field1", "field2\r"], ["\r\rfield1", "field2\r"], - ["\r\r", ""] + ["\r\r", ""], ], - ignore: true + ignore: true, }, { Name: "NonASCIICommaAndComment", @@ -346,14 +346,14 @@ x,,, Output: [["a", "b,c", "d,e"]], TrimLeadingSpace: true, Comma: "£", - Comment: "€" + Comment: "€", }, { Name: "NonASCIICommaAndCommentWithQuotes", Input: 'a€" b,"€ c\nλ comment\n', Output: [["a", " b,", " c"]], Comma: "€", - Comment: "λ" + Comment: "λ", }, { // λ and θ start with the same byte. @@ -362,24 +362,24 @@ x,,, Input: '"abθcd"λefθgh', Output: [["abθcd", "efθgh"]], Comma: "λ", - Comment: "€" + Comment: "€", }, { Name: "NonASCIICommentConfusion", Input: "λ\nλ\nθ\nλ\n", Output: [["λ"], ["λ"], ["λ"]], - Comment: "θ" + Comment: "θ", }, { Name: "QuotedFieldMultipleLF", Input: '"\n\n\n\n"', Output: [["\n\n\n\n"]], - ignore: true + ignore: true, }, { Name: "MultipleCRLF", Input: "\r\n\r\n\r\n\r\n", - ignore: true + ignore: true, }, /** * The implementation may read each line in several chunks if @@ -392,77 +392,77 @@ x,,, "#ignore\n".repeat(10000) + "@".repeat(5000) + "," + "*".repeat(5000), Output: [["@".repeat(5000), "*".repeat(5000)]], Comment: "#", - ignore: true + ignore: true, }, { Name: "QuoteWithTrailingCRLF", Input: '"foo"bar"\r\n', - Error: ErrBareQuote + Error: ErrBareQuote, // Error: &ParseError{StartLine: 1, Line: 1, Column: 4, Err: ErrQuote}, }, { Name: "LazyQuoteWithTrailingCRLF", Input: '"foo"bar"\r\n', Output: [[`foo"bar`]], - LazyQuotes: true + LazyQuotes: true, }, { Name: "DoubleQuoteWithTrailingCRLF", Input: '"foo""bar"\r\n', Output: [[`foo"bar`]], - ignore: true + ignore: true, }, { Name: "EvenQuotes", Input: `""""""""`, Output: [[`"""`]], - ignore: true + ignore: true, }, { Name: "OddQuotes", Input: `"""""""`, Error: true, // Error:" &ParseError{StartLine: 1, Line: 1, Column: 7, Err: ErrQuote}", - ignore: true + ignore: true, }, { Name: "LazyOddQuotes", Input: `"""""""`, Output: [[`"""`]], LazyQuotes: true, - ignore: true + ignore: true, }, { Name: "BadComma1", Comma: "\n", - Error: ErrInvalidDelim + Error: ErrInvalidDelim, }, { Name: "BadComma2", Comma: "\r", - Error: ErrInvalidDelim + Error: ErrInvalidDelim, }, { Name: "BadComma3", Comma: '"', - Error: ErrInvalidDelim + Error: ErrInvalidDelim, }, { Name: "BadComment1", Comment: "\n", - Error: ErrInvalidDelim + Error: ErrInvalidDelim, }, { Name: "BadComment2", Comment: "\r", - Error: ErrInvalidDelim + Error: ErrInvalidDelim, }, { Name: "BadCommaComment", Comma: "X", Comment: "X", - Error: ErrInvalidDelim - } + Error: ErrInvalidDelim, + }, ]; for (const t of testCases) { Deno.test({ @@ -500,7 +500,7 @@ for (const t of testCases) { comment: comment, trimLeadingSpace: trim, fieldsPerRecord: fieldsPerRec, - lazyQuotes: lazyquote + lazyQuotes: lazyquote, } ); } catch (e) { @@ -516,13 +516,13 @@ for (const t of testCases) { comment: comment, trimLeadingSpace: trim, fieldsPerRecord: fieldsPerRec, - lazyQuotes: lazyquote + lazyQuotes: lazyquote, } ); const expected = t.Output; assertEquals(actual, expected); } - } + }, }); } @@ -531,13 +531,13 @@ const parseTestCases = [ name: "simple", in: "a,b,c", header: false, - result: [["a", "b", "c"]] + result: [["a", "b", "c"]], }, { name: "simple Bufreader", in: new BufReader(new StringReader("a,b,c")), header: false, - result: [["a", "b", "c"]] + result: [["a", "b", "c"]], }, { name: "multiline", @@ -545,14 +545,14 @@ const parseTestCases = [ header: false, result: [ ["a", "b", "c"], - ["e", "f", "g"] - ] + ["e", "f", "g"], + ], }, { name: "header mapping boolean", in: "a,b,c\ne,f,g\n", header: true, - result: [{ a: "e", b: "f", c: "g" }] + result: [{ a: "e", b: "f", c: "g" }], }, { name: "header mapping array", @@ -560,8 +560,8 @@ const parseTestCases = [ header: ["this", "is", "sparta"], result: [ { this: "a", is: "b", sparta: "c" }, - { this: "e", is: "f", sparta: "g" } - ] + { this: "e", is: "f", sparta: "g" }, + ], }, { name: "header mapping object", @@ -569,8 +569,8 @@ const parseTestCases = [ header: [{ name: "this" }, { name: "is" }, { name: "sparta" }], result: [ { this: "a", is: "b", sparta: "c" }, - { this: "e", is: "f", sparta: "g" } - ] + { this: "e", is: "f", sparta: "g" }, + ], }, { name: "header mapping parse entry", @@ -580,25 +580,25 @@ const parseTestCases = [ name: "this", parse: (e: string): string => { return `b${e}$$`; - } + }, }, { name: "is", parse: (e: string): number => { return e.length; - } + }, }, { name: "sparta", parse: (e: string): unknown => { return { bim: `boom-${e}` }; - } - } + }, + }, ], result: [ { this: "ba$$", is: 1, sparta: { bim: `boom-c` } }, - { this: "be$$", is: 1, sparta: { bim: `boom-g` } } - ] + { this: "be$$", is: 1, sparta: { bim: `boom-g` } }, + ], }, { name: "multiline parse", @@ -609,8 +609,8 @@ const parseTestCases = [ header: false, result: [ { super: "a", street: "b", fighter: "c" }, - { super: "e", street: "f", fighter: "g" } - ] + { super: "e", street: "f", fighter: "g" }, + ], }, { name: "header mapping object parseline", @@ -621,9 +621,9 @@ const parseTestCases = [ }, result: [ { super: "a", street: "b", fighter: "c" }, - { super: "e", street: "f", fighter: "g" } - ] - } + { super: "e", street: "f", fighter: "g" }, + ], + }, ]; for (const testCase of parseTestCases) { @@ -632,9 +632,9 @@ for (const testCase of parseTestCases) { async fn(): Promise<void> { const r = await parse(testCase.in, { header: testCase.header, - parse: testCase.parse as (input: unknown) => unknown + parse: testCase.parse as (input: unknown) => unknown, }); assertEquals(r, testCase.result); - } + }, }); } |