From 69c429b8e098697eccb87a0c27fe2cf06070b314 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 11 Mar 2025 22:09:37 +0100 Subject: [PATCH 1/3] initial commit --- toml/parse_test.ts | 356 +++++++++++++++++-- toml/testdata/CRLF.toml | 3 - toml/testdata/arrayTable.toml | 29 -- toml/testdata/arrays.toml | 12 - toml/testdata/boolean.toml | 4 - toml/testdata/cargo.toml | 54 --- toml/testdata/cargoTest.toml | 147 -------- toml/testdata/comment.toml | 33 -- toml/testdata/datetime.toml | 9 - toml/testdata/error-invalid-string.toml | 2 - toml/testdata/error-invalid-whitespace1.toml | 1 - toml/testdata/error-invalid-whitespace2.toml | 1 - toml/testdata/error-open-string.toml | 2 - toml/testdata/float.toml | 23 -- toml/testdata/inlineArrayOfInlineTable.toml | 8 - toml/testdata/inlineTable.toml | 11 - toml/testdata/integer.toml | 20 -- toml/testdata/keys.toml | 15 - toml/testdata/simple.toml | 5 - toml/testdata/string.toml | 57 --- toml/testdata/table.toml | 17 - 21 files changed, 323 insertions(+), 486 deletions(-) delete mode 100644 toml/testdata/CRLF.toml delete mode 100644 toml/testdata/arrayTable.toml delete mode 100644 toml/testdata/arrays.toml delete mode 100644 toml/testdata/boolean.toml delete mode 100644 toml/testdata/cargo.toml delete mode 100644 toml/testdata/cargoTest.toml delete mode 100644 toml/testdata/comment.toml delete mode 100644 toml/testdata/datetime.toml delete mode 100644 toml/testdata/error-invalid-string.toml delete mode 100644 toml/testdata/error-invalid-whitespace1.toml delete mode 100644 toml/testdata/error-invalid-whitespace2.toml delete mode 100644 toml/testdata/error-open-string.toml delete mode 100644 toml/testdata/float.toml delete mode 100644 toml/testdata/inlineArrayOfInlineTable.toml delete mode 100644 toml/testdata/inlineTable.toml delete mode 100644 toml/testdata/integer.toml delete mode 100644 toml/testdata/keys.toml delete mode 100644 toml/testdata/simple.toml delete mode 100644 toml/testdata/string.toml delete mode 100644 toml/testdata/table.toml diff --git a/toml/parse_test.ts b/toml/parse_test.ts index 3605f43df031..d32aba4b8d3d 100644 --- a/toml/parse_test.ts +++ b/toml/parse_test.ts @@ -22,18 +22,6 @@ import { value, } from "./_parser.ts"; import { parse, stringify } from "./mod.ts"; -import { existsSync } from "@std/fs/exists"; -import * as path from "@std/path"; - -const moduleDir = path.dirname(path.fromFileUrl(import.meta.url)); -const testdataDir = path.resolve(moduleDir, "./testdata"); - -function parseFile(filePath: string): Record { - if (!existsSync(filePath)) { - throw new Error(`File not found: ${filePath}`); - } - return parse(Deno.readTextFileSync(filePath)); -} Deno.test({ name: "Scanner", @@ -603,7 +591,64 @@ Deno.test({ withUnicodeChar2: "Deno🦕", }, }; - const actual = parseFile(path.join(testdataDir, "string.toml")); + const actual = parse(`[strings] +str0 = "deno" +str1 = """ +Roses are not Deno + Violets are not Deno either""" +# On a Unix system, the above multi-line string will most likely be the same as: +str2 = "Roses are not Deno\\nViolets are not Deno either" + +# On a Windows system, it will most likely be equivalent to: +str3 = "Roses are not Deno\\r\\nViolets are not Deno either" +str4 = "this is a \\"quote\\"" + +str5 = """ +The quick brown \\ + + + fox jumps over \\ + the lazy dog.""" + +str6 = """\\ + The quick brown \\ + fox jumps over \\ + the lazy dog.\\ + """ +str7 = "Roses are red\\tViolets are blue" +str8 = "Roses are red\\fViolets are blue" +str9 = "Roses are red\\bViolets are blue" +str10 = "Roses are red\\\\Violets are blue" +str11 = """ +double "quote" +single 'quote' +""" +str12 = """Here are two quotation marks: "". Simple enough.""" +str13 = """Here are three quotation marks: ""\\".""" +str14 = """Here are fifteen quotation marks: ""\\"""\\"""\\"""\\"""\\".""" +str15 = """"This," she said, "is just a pointless statement."""" + +literal1 = ''' +The first newline is +trimmed in raw strings. + All other whitespace + is preserved. +''' + +literal2 = '"\\n#=*{' +literal3 = ''' +\\n\\t is 'literal'\\ +''' +literal4 = '''Here are fifteen quotation marks: """""""""""""""''' +literal5 = "Here are fifteen apostrophes: '''''''''''''''" +literal6 = ''''That,' she said, 'is still pointless.'''' + +withApostrophe = "What if it's not?" +withSemicolon = "const message = 'hello world';" +withHexNumberLiteral = "Prevent bug from stripping string here ->0xabcdef" +withUnicodeChar1 = "\\u3042" +withUnicodeChar2 = "Deno\\U01F995" +`); assertEquals(actual, expected); }, }); @@ -612,7 +657,9 @@ Deno.test({ name: "parse() handles CRLF", fn() { const expected = { boolean: { bool1: true, bool2: false } }; - const actual = parseFile(path.join(testdataDir, "CRLF.toml")); + const actual = parse(`[boolean] +bool1 = true +bool2 = false`); assertEquals(actual, expected); }, }); @@ -621,7 +668,10 @@ Deno.test({ name: "parse() handles boolean", fn() { const expected = { boolean: { bool1: true, bool2: false, bool3: true } }; - const actual = parseFile(path.join(testdataDir, "boolean.toml")); + const actual = parse(`[boolean] # i hate comments +bool1 = true +bool2 = false +bool3 = true # I love comments`); assertEquals(actual, expected); }, }); @@ -646,7 +696,26 @@ Deno.test({ bin1: "0b11010110", }, }; - const actual = parseFile(path.join(testdataDir, "integer.toml")); + const actual = parse(`[integer] +int1 = +99 +int2 = 42 +int3 = 0 +int4 = -17 +int5 = 1_000 +int6 = 5_349_221 +int7 = 1_2_3_4_5 # VALID but discouraged + +# hexadecimal with prefix \`0x\` +hex1 = 0xDEADBEEF +hex2 = 0xdeadbeef +hex3 = 0xdead_beef + +# octal with prefix \`0o\` +oct1 = 0o01234567 +oct2 = 0o755 # useful for Unix file permissions + +# binary with prefix \`0b\` +bin1 = 0b11010110`); assertEquals(actual, expected); }, }); @@ -672,7 +741,29 @@ Deno.test({ sf6: NaN, }, }; - const actual = parseFile(path.join(testdataDir, "float.toml")); + const actual = parse(`[float] +# fractional +flt1 = +1.0 # Comment +flt2 = 3.1415 # Comment +flt3 = -0.01 # Comment + +# exponent +flt4 = 5e+22 # Comment +flt5 = 1e6 # Comment +flt6 = -2E-2 # Comment + +# both +flt7 = 6.626e-34 # Comment +flt8 = 224_617.445_991_228 # Comment +# infinity +sf1 = inf # positive infinity +sf2 = +inf # positive infinity +sf3 = -inf # negative infinity + +# not a number +sf4 = nan # actual sNaN/qNaN encoding is implementation specific +sf5 = +nan # same as \`nan\` +sf6 = -nan # valid, actual encoding is implementation specific`); assertEquals(actual, expected); }, }); @@ -703,7 +794,19 @@ Deno.test({ ], }, }; - const actual = parseFile(path.join(testdataDir, "arrays.toml")); + const actual = parse(`[arrays] +data = [ ["gamma", "delta"], [1, 2] ] # comment after an array caused issue #7072 + +# Line breaks are OK when inside arrays +hosts = [ + "alpha", + "omega" +] # comment + +profiles = [ { name = "John", "john@example.com" = true }, { name = "Doe", "doe@example.com" = true }, ] + +floats = [ 0.1, -1.25 ]`); + assertEquals(actual, expected); }, }); @@ -743,7 +846,24 @@ Deno.test({ }, }, }; - const actual = parseFile(path.join(testdataDir, "table.toml")); + const actual = parse(`[deeply.nested.object.in.the.toml] +name = "Tom Preston-Werner" + +[servers] + + # Indentation (tabs and/or spaces) is allowed but not required + [servers.alpha] + ip = "10.0.0.1" + dc = "eqdc10" + + [servers.beta] + ip = "10.0.0.2" + dc = "eqdc20" + +# Naming rules for tables are the same as for keys +[dog."tater.man"] +type.name = "pug" +`); assertEquals(actual, expected); }, }); @@ -762,7 +882,22 @@ Deno.test({ "basic__\n__": 1, "literal__\\n__": 1, }; - const actual = parseFile(path.join(testdataDir, "keys.toml")); + const actual = parse(`"" = 1 +"127.0.0.1" = 1 +"ʎǝʞ" = 1 +'this is "literal"' = 1 +"double \\"quote\\"" = 1 + +site."google.com".bar = 1 +site."google.com".baz = 1 + +a . b . c = 1 +a . b . d = 1 +a . e = 1 + +'literal__\\n__' = 1 +"basic__\\n__" = 1 +`); assertEquals(actual, expected); }, }); @@ -777,7 +912,12 @@ Deno.test({ NANI: "何?!", comment: "Comment inside # the comment", }; - const actual = parseFile(path.join(testdataDir, "simple.toml")); + const actual = parse(`deno = "is" +not = "[node]" +regex = '<\\i\\c*\\s*>' +NANI = '何?!' +comment = "Comment inside # the comment" # Comment +`); assertEquals(actual, expected); }, }); @@ -797,7 +937,16 @@ Deno.test({ lt2: "00:32:00.999999", }, }; - const actual = parseFile(path.join(testdataDir, "datetime.toml")); + const actual = parse(`[datetime] +odt1 = 1979-05-27T07:32:00Z # Comment +odt2 = 1979-05-27T00:32:00-07:00 # Comment +odt3 = 1979-05-27T14:32:00+07:00 # Comment +odt4 = 1979-05-27T00:32:00.999999-07:00 # Comment +odt5 = 1979-05-27 07:32:00Z # Comment +ld1 = 1979-05-27 # Comment +lt1 = 07:32:00 # Comment +lt2 = 00:32:00.999999 # Comment +`); assertEquals(actual, expected); }, }); @@ -859,7 +1008,20 @@ Deno.test({ empty: {}, }, }; - const actual = parseFile(path.join(testdataDir, "inlineTable.toml")); + + const actual = parse(`[inlinetable] +name = { first = "Tom", last = "Preston-Werner" } +point = { x = 1, y = 2 } +dog = { type = { name = "pug" } } +animal.as.leaders = "tosin" +"tosin.abasi" = "guitarist" +nile = { derek.roddy = "drummer", also = { malevolant.creation = { drum.kit = "Tama" } } } +annotation_filter = { "kubernetes.io/ingress.class" = "nginx" } +literal_key = { 'foo\\nbar' = 'foo\\nbar' } +nested = { parent = { children = ["{", "}"], "child.ren" = ["[", "]"] } } # comment +empty = {} +`); + assertEquals(actual, expected); }, }); @@ -899,7 +1061,35 @@ Deno.test({ }, ], }; - const actual = parseFile(path.join(testdataDir, "arrayTable.toml")); + const actual = parse(` +[[bin]] +name = "deno" +path = "cli/main.rs" + +[[bin]] +name = "deno_core" +path = "src/foo.rs" + +[[nib]] +name = "node" +path = "not_found" + +[a] +[a.c] +z = "z" + +[[b]] +[b.c] +z = "z" + +[[b]] +[b.c] +z = "z" + +[[aaa]] +hi = "hi" +[aaa.bbb] +asdf = "asdf"`); assertEquals(actual, expected); }, }); @@ -946,7 +1136,63 @@ Deno.test({ "cfg(linux)": { dependencies: { winapi: "0.3.9" } }, }, }; - const actual = parseFile(path.join(testdataDir, "cargo.toml")); + const actual = parse( + `# Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. +# Dummy package info required by \`cargo fetch\`. + +[workspace] +members = [ + "./", + "core", +] + +[[bin]] +name = "deno" +path = "cli/main.rs" + +[package] +name = "deno" +version = "0.3.4" +edition = "2018" + +[dependencies] +deno_core = { path = "./core" } + +atty = "0.2.11" +dirs = "1.0.5" +flatbuffers = "0.5.0" +futures = "0.1.25" +getopts = "0.2.18" +http = "0.1.16" +hyper = "0.12.24" +hyper-rustls = "0.16.0" +integer-atomics = "1.0.2" +lazy_static = "1.3.0" +libc = "0.2.49" +log = "0.4.6" +rand = "0.6.5" +regex = "1.1.0" +remove_dir_all = "0.5.2" +ring = "0.14.6" +rustyline = "3.0.0" +serde_json = "1.0.38" +source-map-mappings = "0.5.0" +tempfile = "3.0.7" +tokio = "0.1.15" +tokio-executor = "0.1.6" +tokio-fs = "0.1.5" +tokio-io = "0.1.11" +tokio-process = "0.2.3" +tokio-threadpool = "0.1.11" +url = "1.7.2" + +[target.'cfg(windows)'.dependencies] +winapi = "0.3.6" + +[target."cfg(linux)".dependencies] +winapi = "0.3.9" +`, + ); assertEquals(actual, expected); }, }); @@ -1149,7 +1395,40 @@ Deno.test({ objectives: ["easy to read", "minimal config file", "#not a comment"], }, }; - const actual = parseFile(path.join(testdataDir, "comment.toml")); + const actual = parse(`# This is a full-line comment + # Comment line starting with whitespaces (#823 case 3) foo = "..." +str0 = 'value' # This is a comment at the end of a line +str1 = "# This is not a comment" # but this is +str2 = """ # this is not a comment! +A multiline string with a # +# this is also not a comment +""" # this is definitely a comment + +str3 = ''' +"# not a comment" + # this is a real tab on purpose +# not a comment +''' # comment + +point0 = { x = 1, y = 2, str0 = "#not a comment", z = 3 } # comment +point1 = { x = 7, y = 8, z = 9, str0 = "#not a comment"} # comment + +[deno] # this comment is fine +features = ["#secure by default", "supports typescript # not a comment"] # Comment caused Issue #7072 +url = "https://deno.land/" # comment +is_not_node = true # comment + +# """ +# ''' + +[toml] # Comment caused Issue #7072 (case 2) +name = "Tom's Obvious, Minimal Language" +objectives = [ # Comment + "easy to read", # Comment + "minimal config file", + "#not a comment" # comment +] # comment +`); assertEquals(actual, expected); }, }); @@ -1172,9 +1451,14 @@ Deno.test({ ], }, }; - const actual = parseFile( - path.join(testdataDir, "inlineArrayOfInlineTable.toml"), - ); + const actual = parse(`[inlineArray] +string = [ {var = "a string"} ] + +my_points = [ { x = 1, y = 2, z = 3 }, { x = 7, y = 8, z = 9 }, { x = 2, y = 4, z = 8 } ] + +points = [ { x = 1, y = 2, z = 3 }, # comment ] + { x = 7, y = 8, z = 9 }, # comment + { x = 2, y = 4, z = 8 } ] # comment`); assertEquals(actual, expected); }, }); @@ -1193,7 +1477,9 @@ Deno.test({ fn() { assertThrows( () => { - parseFile(path.join(testdataDir, "error-open-string.toml")); + parse(`badComment = 'The first newline is +' +`); }, Error, `Parse error on line 1, column 34: Single-line string cannot contain EOL`, @@ -1206,7 +1492,9 @@ Deno.test({ fn() { assertThrows( () => { - parseFile(path.join(testdataDir, "error-invalid-string.toml")); + parse(`[invalid-string] +foo = BAR +`); }, Error, `invalid data format`, @@ -1219,14 +1507,16 @@ Deno.test({ fn() { assertThrows( () => { - parseFile(path.join(testdataDir, "error-invalid-whitespace1.toml")); + parse(` foo = "bar" +`); }, Error, "Parse error on line 1, column 0: Cannot parse the TOML: It contains invalid whitespace at position '0': `\\u3000`", ); assertThrows( () => { - parseFile(path.join(testdataDir, "error-invalid-whitespace2.toml")); + parse(`foo = "bar" +`); }, Error, "Parse error on line 1, column 3: Cannot parse the TOML: It contains invalid whitespace at position '3': `\\u3000`", diff --git a/toml/testdata/CRLF.toml b/toml/testdata/CRLF.toml deleted file mode 100644 index 92264888a2b3..000000000000 --- a/toml/testdata/CRLF.toml +++ /dev/null @@ -1,3 +0,0 @@ -[boolean] -bool1 = true -bool2 = false \ No newline at end of file diff --git a/toml/testdata/arrayTable.toml b/toml/testdata/arrayTable.toml deleted file mode 100644 index 61bcccab5b90..000000000000 --- a/toml/testdata/arrayTable.toml +++ /dev/null @@ -1,29 +0,0 @@ - -[[bin]] -name = "deno" -path = "cli/main.rs" - -[[bin]] -name = "deno_core" -path = "src/foo.rs" - -[[nib]] -name = "node" -path = "not_found" - -[a] -[a.c] -z = "z" - -[[b]] -[b.c] -z = "z" - -[[b]] -[b.c] -z = "z" - -[[aaa]] -hi = "hi" -[aaa.bbb] -asdf = "asdf" \ No newline at end of file diff --git a/toml/testdata/arrays.toml b/toml/testdata/arrays.toml deleted file mode 100644 index 16a4ffc81e3b..000000000000 --- a/toml/testdata/arrays.toml +++ /dev/null @@ -1,12 +0,0 @@ -[arrays] -data = [ ["gamma", "delta"], [1, 2] ] # comment after an array caused issue #7072 - -# Line breaks are OK when inside arrays -hosts = [ - "alpha", - "omega" -] # comment - -profiles = [ { name = "John", "john@example.com" = true }, { name = "Doe", "doe@example.com" = true }, ] - -floats = [ 0.1, -1.25 ] \ No newline at end of file diff --git a/toml/testdata/boolean.toml b/toml/testdata/boolean.toml deleted file mode 100644 index e3e287981baf..000000000000 --- a/toml/testdata/boolean.toml +++ /dev/null @@ -1,4 +0,0 @@ -[boolean] # i hate comments -bool1 = true -bool2 = false -bool3 = true # I love comments \ No newline at end of file diff --git a/toml/testdata/cargo.toml b/toml/testdata/cargo.toml deleted file mode 100644 index a34c906e8110..000000000000 --- a/toml/testdata/cargo.toml +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -# Dummy package info required by `cargo fetch`. - -[workspace] -members = [ - "./", - "core", -] - -[[bin]] -name = "deno" -path = "cli/main.rs" - -[package] -name = "deno" -version = "0.3.4" -edition = "2018" - -[dependencies] -deno_core = { path = "./core" } - -atty = "0.2.11" -dirs = "1.0.5" -flatbuffers = "0.5.0" -futures = "0.1.25" -getopts = "0.2.18" -http = "0.1.16" -hyper = "0.12.24" -hyper-rustls = "0.16.0" -integer-atomics = "1.0.2" -lazy_static = "1.3.0" -libc = "0.2.49" -log = "0.4.6" -rand = "0.6.5" -regex = "1.1.0" -remove_dir_all = "0.5.2" -ring = "0.14.6" -rustyline = "3.0.0" -serde_json = "1.0.38" -source-map-mappings = "0.5.0" -tempfile = "3.0.7" -tokio = "0.1.15" -tokio-executor = "0.1.6" -tokio-fs = "0.1.5" -tokio-io = "0.1.11" -tokio-process = "0.2.3" -tokio-threadpool = "0.1.11" -url = "1.7.2" - -[target.'cfg(windows)'.dependencies] -winapi = "0.3.6" - -[target."cfg(linux)".dependencies] -winapi = "0.3.9" diff --git a/toml/testdata/cargoTest.toml b/toml/testdata/cargoTest.toml deleted file mode 100644 index 47e7f6e4d353..000000000000 --- a/toml/testdata/cargoTest.toml +++ /dev/null @@ -1,147 +0,0 @@ -# This is a TOML document. - -title = "TOML Example" - -[deeply.nested.object.in.the.toml] -name = "Tom Preston-Werner" -dob = 2009-05-27T07:32:00 - -[database] -server = "192.168.1.1" -ports = [ 8001, 8001, 8002 ] -connection_max = 5000 -enabled = true - -[servers] - - # Indentation (tabs and/or spaces) is allowed but not required - [servers.alpha] - ip = "10.0.0.1" - dc = "eqdc10" - - [servers.beta] - ip = "10.0.0.2" - dc = "eqdc10" - -[clients] -data = [ ["gamma", "delta"], [1, 2] ] - -# Line breaks are OK when inside arrays -hosts = [ - "alpha", - "omega" -] - -[strings] -str0 = "deno" -str1 = """ -Roses are red - Violets are blue""" -# On a Unix system, the above multi-line string will most likely be the same as: -str2 = "Roses are red\nViolets are blue" - -# On a Windows system, it will most likely be equivalent to: -str3 = "Roses are red\r\nViolets are blue" -str4 = "The quick brown fox jumps over the lazy dog." -str5 = "this is a \"quote\"" - -str5 = """ -The quick brown \ - - - fox jumps over \ - the lazy dog.""" - -str6 = """\ - The quick brown \ - fox jumps over \ - the lazy dog.\ - """ -lines = ''' -The first newline is -trimmed in raw strings. - All other whitespace - is preserved. -''' - -[Integer] -int1 = +99 -int2 = 42 -int3 = 0 -int4 = -17 -int5 = 1_000 -int6 = 5_349_221 -int7 = 1_2_3_4_5 # VALID but discouraged - -# hexadecimal with prefix `0x` -hex1 = 0xDEADBEEF -hex2 = 0xdeadbeef -hex3 = 0xdead_beef - -# octal with prefix `0o` -oct1 = 0o01234567 -oct2 = 0o755 # useful for Unix file permissions - -# binary with prefix `0b` -bin1 = 0b11010110 - -[Date-Time] -odt1 = 1979-05-27T07:32:00Z -odt2 = 1979-05-27T00:32:00-07:00 -odt3 = 1979-05-27T00:32:00.999999-07:00 -odt4 = 1979-05-27 07:32:00Z -ld1 = 1979-05-27 -lt1 = 07:32:00 #buggy -lt2 = 00:32:00.999999 #buggy - -[boolean] -bool1 = true -bool2 = false - -[float] -# fractional -flt1 = +1.0 -flt2 = 3.1415 -flt3 = -0.01 - -# exponent -flt4 = 5e+22 -flt5 = 1e6 -flt6 = -2E-2 - -# both -flt7 = 6.626e-34 -flt8 = 224_617.445_991_228 -# infinity -sf1 = inf # positive infinity -sf2 = +inf # positive infinity -sf3 = -inf # negative infinity - -# not a number -sf4 = nan # actual sNaN/qNaN encoding is implementation specific -sf5 = +nan # same as `nan` -sf6 = -nan # valid, actual encoding is implementation specific - -[Table] -name = { first = "Tom", last = "Preston-Werner" } -point = { x = 1, y = 2 } -animal = { type.name = "pug" } - -[[fruit]] - name = "apple" - - [fruit.physical] - color = "red" - shape = "round" - - [[fruit.variety]] - name = "red delicious" - - [[fruit.variety]] - name = "granny smith" - -[[fruit]] - name = "banana" - - [[fruit.variety]] - name = "plantain" diff --git a/toml/testdata/comment.toml b/toml/testdata/comment.toml deleted file mode 100644 index 7bf85c96df1d..000000000000 --- a/toml/testdata/comment.toml +++ /dev/null @@ -1,33 +0,0 @@ -# This is a full-line comment - # Comment line starting with whitespaces (#823 case 3) foo = "..." -str0 = 'value' # This is a comment at the end of a line -str1 = "# This is not a comment" # but this is -str2 = """ # this is not a comment! -A multiline string with a # -# this is also not a comment -""" # this is definitely a comment - -str3 = ''' -"# not a comment" - # this is a real tab on purpose -# not a comment -''' # comment - -point0 = { x = 1, y = 2, str0 = "#not a comment", z = 3 } # comment -point1 = { x = 7, y = 8, z = 9, str0 = "#not a comment"} # comment - -[deno] # this comment is fine -features = ["#secure by default", "supports typescript # not a comment"] # Comment caused Issue #7072 -url = "https://deno.land/" # comment -is_not_node = true # comment - -# """ -# ''' - -[toml] # Comment caused Issue #7072 (case 2) -name = "Tom's Obvious, Minimal Language" -objectives = [ # Comment - "easy to read", # Comment - "minimal config file", - "#not a comment" # comment -] # comment diff --git a/toml/testdata/datetime.toml b/toml/testdata/datetime.toml deleted file mode 100644 index 1bf92c2dc209..000000000000 --- a/toml/testdata/datetime.toml +++ /dev/null @@ -1,9 +0,0 @@ -[datetime] -odt1 = 1979-05-27T07:32:00Z # Comment -odt2 = 1979-05-27T00:32:00-07:00 # Comment -odt3 = 1979-05-27T14:32:00+07:00 # Comment -odt4 = 1979-05-27T00:32:00.999999-07:00 # Comment -odt5 = 1979-05-27 07:32:00Z # Comment -ld1 = 1979-05-27 # Comment -lt1 = 07:32:00 # Comment -lt2 = 00:32:00.999999 # Comment diff --git a/toml/testdata/error-invalid-string.toml b/toml/testdata/error-invalid-string.toml deleted file mode 100644 index 4c1e33a8e7e4..000000000000 --- a/toml/testdata/error-invalid-string.toml +++ /dev/null @@ -1,2 +0,0 @@ -[invalid-string] -foo = BAR diff --git a/toml/testdata/error-invalid-whitespace1.toml b/toml/testdata/error-invalid-whitespace1.toml deleted file mode 100644 index 2037d71415ac..000000000000 --- a/toml/testdata/error-invalid-whitespace1.toml +++ /dev/null @@ -1 +0,0 @@ - foo = "bar" diff --git a/toml/testdata/error-invalid-whitespace2.toml b/toml/testdata/error-invalid-whitespace2.toml deleted file mode 100644 index 48dceff1994f..000000000000 --- a/toml/testdata/error-invalid-whitespace2.toml +++ /dev/null @@ -1 +0,0 @@ -foo = "bar" diff --git a/toml/testdata/error-open-string.toml b/toml/testdata/error-open-string.toml deleted file mode 100644 index 57124c963d27..000000000000 --- a/toml/testdata/error-open-string.toml +++ /dev/null @@ -1,2 +0,0 @@ -badComment = 'The first newline is -' diff --git a/toml/testdata/float.toml b/toml/testdata/float.toml deleted file mode 100644 index 6a384179cf19..000000000000 --- a/toml/testdata/float.toml +++ /dev/null @@ -1,23 +0,0 @@ -[float] -# fractional -flt1 = +1.0 # Comment -flt2 = 3.1415 # Comment -flt3 = -0.01 # Comment - -# exponent -flt4 = 5e+22 # Comment -flt5 = 1e6 # Comment -flt6 = -2E-2 # Comment - -# both -flt7 = 6.626e-34 # Comment -flt8 = 224_617.445_991_228 # Comment -# infinity -sf1 = inf # positive infinity -sf2 = +inf # positive infinity -sf3 = -inf # negative infinity - -# not a number -sf4 = nan # actual sNaN/qNaN encoding is implementation specific -sf5 = +nan # same as `nan` -sf6 = -nan # valid, actual encoding is implementation specific \ No newline at end of file diff --git a/toml/testdata/inlineArrayOfInlineTable.toml b/toml/testdata/inlineArrayOfInlineTable.toml deleted file mode 100644 index 9ae4c256817f..000000000000 --- a/toml/testdata/inlineArrayOfInlineTable.toml +++ /dev/null @@ -1,8 +0,0 @@ -[inlineArray] -string = [ {var = "a string"} ] - -my_points = [ { x = 1, y = 2, z = 3 }, { x = 7, y = 8, z = 9 }, { x = 2, y = 4, z = 8 } ] - -points = [ { x = 1, y = 2, z = 3 }, # comment ] - { x = 7, y = 8, z = 9 }, # comment - { x = 2, y = 4, z = 8 } ] # comment \ No newline at end of file diff --git a/toml/testdata/inlineTable.toml b/toml/testdata/inlineTable.toml deleted file mode 100644 index 7551271519c0..000000000000 --- a/toml/testdata/inlineTable.toml +++ /dev/null @@ -1,11 +0,0 @@ -[inlinetable] -name = { first = "Tom", last = "Preston-Werner" } -point = { x = 1, y = 2 } -dog = { type = { name = "pug" } } -animal.as.leaders = "tosin" -"tosin.abasi" = "guitarist" -nile = { derek.roddy = "drummer", also = { malevolant.creation = { drum.kit = "Tama" } } } -annotation_filter = { "kubernetes.io/ingress.class" = "nginx" } -literal_key = { 'foo\nbar' = 'foo\nbar' } -nested = { parent = { children = ["{", "}"], "child.ren" = ["[", "]"] } } # comment -empty = {} diff --git a/toml/testdata/integer.toml b/toml/testdata/integer.toml deleted file mode 100644 index 3bd781e8f52b..000000000000 --- a/toml/testdata/integer.toml +++ /dev/null @@ -1,20 +0,0 @@ -[integer] -int1 = +99 -int2 = 42 -int3 = 0 -int4 = -17 -int5 = 1_000 -int6 = 5_349_221 -int7 = 1_2_3_4_5 # VALID but discouraged - -# hexadecimal with prefix `0x` -hex1 = 0xDEADBEEF -hex2 = 0xdeadbeef -hex3 = 0xdead_beef - -# octal with prefix `0o` -oct1 = 0o01234567 -oct2 = 0o755 # useful for Unix file permissions - -# binary with prefix `0b` -bin1 = 0b11010110 \ No newline at end of file diff --git a/toml/testdata/keys.toml b/toml/testdata/keys.toml deleted file mode 100644 index 5e4195bcaef4..000000000000 --- a/toml/testdata/keys.toml +++ /dev/null @@ -1,15 +0,0 @@ -"" = 1 -"127.0.0.1" = 1 -"ʎǝʞ" = 1 -'this is "literal"' = 1 -"double \"quote\"" = 1 - -site."google.com".bar = 1 -site."google.com".baz = 1 - -a . b . c = 1 -a . b . d = 1 -a . e = 1 - -'literal__\n__' = 1 -"basic__\n__" = 1 diff --git a/toml/testdata/simple.toml b/toml/testdata/simple.toml deleted file mode 100644 index f3f6c10365df..000000000000 --- a/toml/testdata/simple.toml +++ /dev/null @@ -1,5 +0,0 @@ -deno = "is" -not = "[node]" -regex = '<\i\c*\s*>' -NANI = '何?!' -comment = "Comment inside # the comment" # Comment diff --git a/toml/testdata/string.toml b/toml/testdata/string.toml deleted file mode 100644 index dec147320b78..000000000000 --- a/toml/testdata/string.toml +++ /dev/null @@ -1,57 +0,0 @@ -[strings] -str0 = "deno" -str1 = """ -Roses are not Deno - Violets are not Deno either""" -# On a Unix system, the above multi-line string will most likely be the same as: -str2 = "Roses are not Deno\nViolets are not Deno either" - -# On a Windows system, it will most likely be equivalent to: -str3 = "Roses are not Deno\r\nViolets are not Deno either" -str4 = "this is a \"quote\"" - -str5 = """ -The quick brown \ - - - fox jumps over \ - the lazy dog.""" - -str6 = """\ - The quick brown \ - fox jumps over \ - the lazy dog.\ - """ -str7 = "Roses are red\tViolets are blue" -str8 = "Roses are red\fViolets are blue" -str9 = "Roses are red\bViolets are blue" -str10 = "Roses are red\\Violets are blue" -str11 = """ -double "quote" -single 'quote' -""" -str12 = """Here are two quotation marks: "". Simple enough.""" -str13 = """Here are three quotation marks: ""\".""" -str14 = """Here are fifteen quotation marks: ""\"""\"""\"""\"""\".""" -str15 = """"This," she said, "is just a pointless statement."""" - -literal1 = ''' -The first newline is -trimmed in raw strings. - All other whitespace - is preserved. -''' - -literal2 = '"\n#=*{' -literal3 = ''' -\n\t is 'literal'\ -''' -literal4 = '''Here are fifteen quotation marks: """""""""""""""''' -literal5 = "Here are fifteen apostrophes: '''''''''''''''" -literal6 = ''''That,' she said, 'is still pointless.'''' - -withApostrophe = "What if it's not?" -withSemicolon = "const message = 'hello world';" -withHexNumberLiteral = "Prevent bug from stripping string here ->0xabcdef" -withUnicodeChar1 = "\u3042" -withUnicodeChar2 = "Deno\U01F995" diff --git a/toml/testdata/table.toml b/toml/testdata/table.toml deleted file mode 100644 index 8f379438e538..000000000000 --- a/toml/testdata/table.toml +++ /dev/null @@ -1,17 +0,0 @@ -[deeply.nested.object.in.the.toml] -name = "Tom Preston-Werner" - -[servers] - - # Indentation (tabs and/or spaces) is allowed but not required - [servers.alpha] - ip = "10.0.0.1" - dc = "eqdc10" - - [servers.beta] - ip = "10.0.0.2" - dc = "eqdc20" - -# Naming rules for tables are the same as for keys -[dog."tater.man"] -type.name = "pug" From f63563a561b468edae52c86a53c79f797c2a26a3 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 11 Mar 2025 22:14:04 +0100 Subject: [PATCH 2/3] fmt --- toml/parse_test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toml/parse_test.ts b/toml/parse_test.ts index d32aba4b8d3d..03f53dc1fd98 100644 --- a/toml/parse_test.ts +++ b/toml/parse_test.ts @@ -806,7 +806,7 @@ hosts = [ profiles = [ { name = "John", "john@example.com" = true }, { name = "Doe", "doe@example.com" = true }, ] floats = [ 0.1, -1.25 ]`); - + assertEquals(actual, expected); }, }); From 7039273a20006de0f3806f8ee468fe7df453bbe0 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Thu, 13 Mar 2025 12:45:52 +0900 Subject: [PATCH 3/3] add CR --- toml/parse_test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toml/parse_test.ts b/toml/parse_test.ts index 03f53dc1fd98..95033c4c3358 100644 --- a/toml/parse_test.ts +++ b/toml/parse_test.ts @@ -657,8 +657,8 @@ Deno.test({ name: "parse() handles CRLF", fn() { const expected = { boolean: { bool1: true, bool2: false } }; - const actual = parse(`[boolean] -bool1 = true + const actual = parse(`[boolean]\r +bool1 = true\r bool2 = false`); assertEquals(actual, expected); },