From d73da82a4a6b82eb63738e26e2d7f883fa4fd91b Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Fri, 20 Jan 2023 15:36:49 +0100 Subject: [PATCH] Update test cases from toml-test --- .../tests/invalid/encoding/bad-codepoint.toml | 1 + .../tests/invalid/float/inf-capital.toml | 1 + .../tests/invalid/float/nan-capital.toml | 1 + .../invalid/inline-table/bad-key-syntax.toml | 1 + .../inline-table/dotted-key-conflict.toml | 1 + .../inline-table/nested_key_conflict.toml | 2 + .../tests/invalid/spec/inline-table-2-0.toml | 3 + .../tests/invalid/spec/inline-table-3-0.toml | 3 + .../tests/invalid/spec/key-value-pair-1.toml | 1 + .../toml-test/tests/invalid/spec/keys-2.toml | 3 + .../tests/invalid/spec/string-4-0.toml | 7 + .../tests/invalid/spec/string-7-0.toml | 7 + .../tests/invalid/spec/table-9-0.toml | 9 ++ .../tests/invalid/spec/table-9-1.toml | 9 ++ .../append-to-array-with-dotted-keys.toml | 4 + .../table/duplicate-key-dotted-array.toml | 4 + .../tests/valid/comment/nonascii.json | 1 + .../tests/valid/comment/nonascii.toml | 1 + .../tests/valid/key/dotted-empty.json | 22 +++ .../tests/valid/key/dotted-empty.toml | 4 + .../tests/valid/key/quoted-unicode.json | 22 +++ .../tests/valid/key/quoted-unicode.toml | 7 + .../toml-test/tests/valid/spec/array-0.json | 146 ++++++++++++++++++ .../toml-test/tests/valid/spec/array-0.toml | 12 ++ .../toml-test/tests/valid/spec/array-1.json | 26 ++++ .../toml-test/tests/valid/spec/array-1.toml | 8 + .../tests/valid/spec/array-of-tables-0.json | 29 ++++ .../tests/valid/spec/array-of-tables-0.toml | 11 ++ .../tests/valid/spec/array-of-tables-1.json | 48 ++++++ .../tests/valid/spec/array-of-tables-1.toml | 19 +++ .../tests/valid/spec/array-of-tables-2.json | 46 ++++++ .../tests/valid/spec/array-of-tables-2.toml | 3 + .../toml-test/tests/valid/spec/boolean-0.json | 10 ++ .../toml-test/tests/valid/spec/boolean-0.toml | 2 + .../toml-test/tests/valid/spec/comment-0.json | 10 ++ .../toml-test/tests/valid/spec/comment-0.toml | 3 + .../toml-test/tests/valid/spec/float-0.json | 30 ++++ .../toml-test/tests/valid/spec/float-0.toml | 12 ++ .../toml-test/tests/valid/spec/float-1.json | 6 + .../toml-test/tests/valid/spec/float-1.toml | 1 + .../toml-test/tests/valid/spec/float-2.json | 26 ++++ .../toml-test/tests/valid/spec/float-2.toml | 9 ++ .../tests/valid/spec/inline-table-0.json | 30 ++++ .../tests/valid/spec/inline-table-0.toml | 3 + .../tests/valid/spec/inline-table-1.json | 30 ++++ .../tests/valid/spec/inline-table-1.toml | 10 ++ .../tests/valid/spec/inline-table-2.json | 10 ++ .../tests/valid/spec/inline-table-2.toml | 3 + .../tests/valid/spec/inline-table-3.json | 10 ++ .../tests/valid/spec/inline-table-3.toml | 3 + .../toml-test/tests/valid/spec/integer-0.json | 18 +++ .../toml-test/tests/valid/spec/integer-0.toml | 4 + .../toml-test/tests/valid/spec/integer-1.json | 18 +++ .../toml-test/tests/valid/spec/integer-1.toml | 4 + .../toml-test/tests/valid/spec/integer-2.json | 26 ++++ .../toml-test/tests/valid/spec/integer-2.toml | 11 ++ .../tests/valid/spec/key-value-pair-0.json | 6 + .../tests/valid/spec/key-value-pair-0.toml | 1 + .../toml-test/tests/valid/spec/keys-0.json | 18 +++ .../toml-test/tests/valid/spec/keys-0.toml | 4 + .../toml-test/tests/valid/spec/keys-1.json | 22 +++ .../toml-test/tests/valid/spec/keys-1.toml | 5 + .../toml-test/tests/valid/spec/keys-3.json | 22 +++ .../toml-test/tests/valid/spec/keys-3.toml | 4 + .../toml-test/tests/valid/spec/keys-4.json | 16 ++ .../toml-test/tests/valid/spec/keys-4.toml | 3 + .../toml-test/tests/valid/spec/keys-5.json | 30 ++++ .../toml-test/tests/valid/spec/keys-5.toml | 10 ++ .../toml-test/tests/valid/spec/keys-6.json | 30 ++++ .../toml-test/tests/valid/spec/keys-6.toml | 9 ++ .../toml-test/tests/valid/spec/keys-7.json | 8 + .../toml-test/tests/valid/spec/keys-7.toml | 1 + .../tests/valid/spec/local-date-0.json | 6 + .../tests/valid/spec/local-date-0.toml | 1 + .../tests/valid/spec/local-date-time-0.json | 10 ++ .../tests/valid/spec/local-date-time-0.toml | 2 + .../tests/valid/spec/local-time-0.json | 10 ++ .../tests/valid/spec/local-time-0.toml | 2 + .../tests/valid/spec/offset-date-time-0.json | 14 ++ .../tests/valid/spec/offset-date-time-0.toml | 3 + .../tests/valid/spec/offset-date-time-1.json | 6 + .../tests/valid/spec/offset-date-time-1.toml | 1 + .../toml-test/tests/valid/spec/string-0.json | 6 + .../toml-test/tests/valid/spec/string-0.toml | 1 + .../toml-test/tests/valid/spec/string-1.json | 6 + .../toml-test/tests/valid/spec/string-1.toml | 3 + .../toml-test/tests/valid/spec/string-2.json | 10 ++ .../toml-test/tests/valid/spec/string-2.toml | 5 + .../toml-test/tests/valid/spec/string-3.json | 14 ++ .../toml-test/tests/valid/spec/string-3.toml | 15 ++ .../toml-test/tests/valid/spec/string-4.json | 18 +++ .../toml-test/tests/valid/spec/string-4.toml | 7 + .../toml-test/tests/valid/spec/string-5.json | 18 +++ .../toml-test/tests/valid/spec/string-5.toml | 5 + .../toml-test/tests/valid/spec/string-6.json | 10 ++ .../toml-test/tests/valid/spec/string-6.toml | 7 + .../toml-test/tests/valid/spec/string-7.json | 14 ++ .../toml-test/tests/valid/spec/string-7.toml | 7 + .../toml-test/tests/valid/spec/table-0.json | 3 + .../toml-test/tests/valid/spec/table-0.toml | 1 + .../toml-test/tests/valid/spec/table-1.json | 22 +++ .../toml-test/tests/valid/spec/table-1.toml | 7 + .../toml-test/tests/valid/spec/table-2.json | 12 ++ .../toml-test/tests/valid/spec/table-2.toml | 2 + .../toml-test/tests/valid/spec/table-3.json | 22 +++ .../toml-test/tests/valid/spec/table-3.toml | 4 + .../toml-test/tests/valid/spec/table-4.json | 9 ++ .../toml-test/tests/valid/spec/table-4.toml | 6 + .../toml-test/tests/valid/spec/table-5.json | 7 + .../toml-test/tests/valid/spec/table-5.toml | 4 + .../toml-test/tests/valid/spec/table-6.json | 7 + .../toml-test/tests/valid/spec/table-6.toml | 4 + .../toml-test/tests/valid/spec/table-7.json | 20 +++ .../toml-test/tests/valid/spec/table-7.toml | 8 + .../toml-test/tests/valid/spec/table-8.json | 16 ++ .../toml-test/tests/valid/spec/table-8.toml | 7 + .../toml-test/tests/valid/spec/table-9.json | 22 +++ .../toml-test/tests/valid/spec/table-9.toml | 9 ++ .../tests/valid/string/quoted-unicode.json | 18 +++ .../tests/valid/string/quoted-unicode.toml | 6 + .../array-implicit-and-explicit-after.json | 16 ++ .../array-implicit-and-explicit-after.toml | 5 + .../valid/table/array-within-dotted.json | 18 +++ .../valid/table/array-within-dotted.toml | 5 + .../tests/valid/table/empty-name.json | 22 +++ .../tests/valid/table/empty-name.toml | 8 + toml_test.go | 9 +- 127 files changed, 1438 insertions(+), 2 deletions(-) create mode 100644 internal/toml-test/tests/invalid/encoding/bad-codepoint.toml create mode 100644 internal/toml-test/tests/invalid/float/inf-capital.toml create mode 100644 internal/toml-test/tests/invalid/float/nan-capital.toml create mode 100644 internal/toml-test/tests/invalid/inline-table/bad-key-syntax.toml create mode 100644 internal/toml-test/tests/invalid/inline-table/dotted-key-conflict.toml create mode 100644 internal/toml-test/tests/invalid/inline-table/nested_key_conflict.toml create mode 100644 internal/toml-test/tests/invalid/spec/inline-table-2-0.toml create mode 100644 internal/toml-test/tests/invalid/spec/inline-table-3-0.toml create mode 100644 internal/toml-test/tests/invalid/spec/key-value-pair-1.toml create mode 100644 internal/toml-test/tests/invalid/spec/keys-2.toml create mode 100644 internal/toml-test/tests/invalid/spec/string-4-0.toml create mode 100644 internal/toml-test/tests/invalid/spec/string-7-0.toml create mode 100644 internal/toml-test/tests/invalid/spec/table-9-0.toml create mode 100644 internal/toml-test/tests/invalid/spec/table-9-1.toml create mode 100644 internal/toml-test/tests/invalid/table/append-to-array-with-dotted-keys.toml create mode 100644 internal/toml-test/tests/invalid/table/duplicate-key-dotted-array.toml create mode 100644 internal/toml-test/tests/valid/comment/nonascii.json create mode 100644 internal/toml-test/tests/valid/comment/nonascii.toml create mode 100644 internal/toml-test/tests/valid/key/dotted-empty.json create mode 100644 internal/toml-test/tests/valid/key/dotted-empty.toml create mode 100644 internal/toml-test/tests/valid/key/quoted-unicode.json create mode 100644 internal/toml-test/tests/valid/key/quoted-unicode.toml create mode 100644 internal/toml-test/tests/valid/spec/array-0.json create mode 100644 internal/toml-test/tests/valid/spec/array-0.toml create mode 100644 internal/toml-test/tests/valid/spec/array-1.json create mode 100644 internal/toml-test/tests/valid/spec/array-1.toml create mode 100644 internal/toml-test/tests/valid/spec/array-of-tables-0.json create mode 100644 internal/toml-test/tests/valid/spec/array-of-tables-0.toml create mode 100644 internal/toml-test/tests/valid/spec/array-of-tables-1.json create mode 100644 internal/toml-test/tests/valid/spec/array-of-tables-1.toml create mode 100644 internal/toml-test/tests/valid/spec/array-of-tables-2.json create mode 100644 internal/toml-test/tests/valid/spec/array-of-tables-2.toml create mode 100644 internal/toml-test/tests/valid/spec/boolean-0.json create mode 100644 internal/toml-test/tests/valid/spec/boolean-0.toml create mode 100644 internal/toml-test/tests/valid/spec/comment-0.json create mode 100644 internal/toml-test/tests/valid/spec/comment-0.toml create mode 100644 internal/toml-test/tests/valid/spec/float-0.json create mode 100644 internal/toml-test/tests/valid/spec/float-0.toml create mode 100644 internal/toml-test/tests/valid/spec/float-1.json create mode 100644 internal/toml-test/tests/valid/spec/float-1.toml create mode 100644 internal/toml-test/tests/valid/spec/float-2.json create mode 100644 internal/toml-test/tests/valid/spec/float-2.toml create mode 100644 internal/toml-test/tests/valid/spec/inline-table-0.json create mode 100644 internal/toml-test/tests/valid/spec/inline-table-0.toml create mode 100644 internal/toml-test/tests/valid/spec/inline-table-1.json create mode 100644 internal/toml-test/tests/valid/spec/inline-table-1.toml create mode 100644 internal/toml-test/tests/valid/spec/inline-table-2.json create mode 100644 internal/toml-test/tests/valid/spec/inline-table-2.toml create mode 100644 internal/toml-test/tests/valid/spec/inline-table-3.json create mode 100644 internal/toml-test/tests/valid/spec/inline-table-3.toml create mode 100644 internal/toml-test/tests/valid/spec/integer-0.json create mode 100644 internal/toml-test/tests/valid/spec/integer-0.toml create mode 100644 internal/toml-test/tests/valid/spec/integer-1.json create mode 100644 internal/toml-test/tests/valid/spec/integer-1.toml create mode 100644 internal/toml-test/tests/valid/spec/integer-2.json create mode 100644 internal/toml-test/tests/valid/spec/integer-2.toml create mode 100644 internal/toml-test/tests/valid/spec/key-value-pair-0.json create mode 100644 internal/toml-test/tests/valid/spec/key-value-pair-0.toml create mode 100644 internal/toml-test/tests/valid/spec/keys-0.json create mode 100644 internal/toml-test/tests/valid/spec/keys-0.toml create mode 100644 internal/toml-test/tests/valid/spec/keys-1.json create mode 100644 internal/toml-test/tests/valid/spec/keys-1.toml create mode 100644 internal/toml-test/tests/valid/spec/keys-3.json create mode 100644 internal/toml-test/tests/valid/spec/keys-3.toml create mode 100644 internal/toml-test/tests/valid/spec/keys-4.json create mode 100644 internal/toml-test/tests/valid/spec/keys-4.toml create mode 100644 internal/toml-test/tests/valid/spec/keys-5.json create mode 100644 internal/toml-test/tests/valid/spec/keys-5.toml create mode 100644 internal/toml-test/tests/valid/spec/keys-6.json create mode 100644 internal/toml-test/tests/valid/spec/keys-6.toml create mode 100644 internal/toml-test/tests/valid/spec/keys-7.json create mode 100644 internal/toml-test/tests/valid/spec/keys-7.toml create mode 100644 internal/toml-test/tests/valid/spec/local-date-0.json create mode 100644 internal/toml-test/tests/valid/spec/local-date-0.toml create mode 100644 internal/toml-test/tests/valid/spec/local-date-time-0.json create mode 100644 internal/toml-test/tests/valid/spec/local-date-time-0.toml create mode 100644 internal/toml-test/tests/valid/spec/local-time-0.json create mode 100644 internal/toml-test/tests/valid/spec/local-time-0.toml create mode 100644 internal/toml-test/tests/valid/spec/offset-date-time-0.json create mode 100644 internal/toml-test/tests/valid/spec/offset-date-time-0.toml create mode 100644 internal/toml-test/tests/valid/spec/offset-date-time-1.json create mode 100644 internal/toml-test/tests/valid/spec/offset-date-time-1.toml create mode 100644 internal/toml-test/tests/valid/spec/string-0.json create mode 100644 internal/toml-test/tests/valid/spec/string-0.toml create mode 100644 internal/toml-test/tests/valid/spec/string-1.json create mode 100644 internal/toml-test/tests/valid/spec/string-1.toml create mode 100644 internal/toml-test/tests/valid/spec/string-2.json create mode 100644 internal/toml-test/tests/valid/spec/string-2.toml create mode 100644 internal/toml-test/tests/valid/spec/string-3.json create mode 100644 internal/toml-test/tests/valid/spec/string-3.toml create mode 100644 internal/toml-test/tests/valid/spec/string-4.json create mode 100644 internal/toml-test/tests/valid/spec/string-4.toml create mode 100644 internal/toml-test/tests/valid/spec/string-5.json create mode 100644 internal/toml-test/tests/valid/spec/string-5.toml create mode 100644 internal/toml-test/tests/valid/spec/string-6.json create mode 100644 internal/toml-test/tests/valid/spec/string-6.toml create mode 100644 internal/toml-test/tests/valid/spec/string-7.json create mode 100644 internal/toml-test/tests/valid/spec/string-7.toml create mode 100644 internal/toml-test/tests/valid/spec/table-0.json create mode 100644 internal/toml-test/tests/valid/spec/table-0.toml create mode 100644 internal/toml-test/tests/valid/spec/table-1.json create mode 100644 internal/toml-test/tests/valid/spec/table-1.toml create mode 100644 internal/toml-test/tests/valid/spec/table-2.json create mode 100644 internal/toml-test/tests/valid/spec/table-2.toml create mode 100644 internal/toml-test/tests/valid/spec/table-3.json create mode 100644 internal/toml-test/tests/valid/spec/table-3.toml create mode 100644 internal/toml-test/tests/valid/spec/table-4.json create mode 100644 internal/toml-test/tests/valid/spec/table-4.toml create mode 100644 internal/toml-test/tests/valid/spec/table-5.json create mode 100644 internal/toml-test/tests/valid/spec/table-5.toml create mode 100644 internal/toml-test/tests/valid/spec/table-6.json create mode 100644 internal/toml-test/tests/valid/spec/table-6.toml create mode 100644 internal/toml-test/tests/valid/spec/table-7.json create mode 100644 internal/toml-test/tests/valid/spec/table-7.toml create mode 100644 internal/toml-test/tests/valid/spec/table-8.json create mode 100644 internal/toml-test/tests/valid/spec/table-8.toml create mode 100644 internal/toml-test/tests/valid/spec/table-9.json create mode 100644 internal/toml-test/tests/valid/spec/table-9.toml create mode 100644 internal/toml-test/tests/valid/string/quoted-unicode.json create mode 100644 internal/toml-test/tests/valid/string/quoted-unicode.toml create mode 100644 internal/toml-test/tests/valid/table/array-implicit-and-explicit-after.json create mode 100644 internal/toml-test/tests/valid/table/array-implicit-and-explicit-after.toml create mode 100644 internal/toml-test/tests/valid/table/array-within-dotted.json create mode 100644 internal/toml-test/tests/valid/table/array-within-dotted.toml create mode 100644 internal/toml-test/tests/valid/table/empty-name.json create mode 100644 internal/toml-test/tests/valid/table/empty-name.toml diff --git a/internal/toml-test/tests/invalid/encoding/bad-codepoint.toml b/internal/toml-test/tests/invalid/encoding/bad-codepoint.toml new file mode 100644 index 00000000..b5b819a2 --- /dev/null +++ b/internal/toml-test/tests/invalid/encoding/bad-codepoint.toml @@ -0,0 +1 @@ +# Invalid codepoint U+D800 : diff --git a/internal/toml-test/tests/invalid/float/inf-capital.toml b/internal/toml-test/tests/invalid/float/inf-capital.toml new file mode 100644 index 00000000..2c0cb4ef --- /dev/null +++ b/internal/toml-test/tests/invalid/float/inf-capital.toml @@ -0,0 +1 @@ +v = Inf diff --git a/internal/toml-test/tests/invalid/float/nan-capital.toml b/internal/toml-test/tests/invalid/float/nan-capital.toml new file mode 100644 index 00000000..f6f926e9 --- /dev/null +++ b/internal/toml-test/tests/invalid/float/nan-capital.toml @@ -0,0 +1 @@ +v = NaN diff --git a/internal/toml-test/tests/invalid/inline-table/bad-key-syntax.toml b/internal/toml-test/tests/invalid/inline-table/bad-key-syntax.toml new file mode 100644 index 00000000..bf71827c --- /dev/null +++ b/internal/toml-test/tests/invalid/inline-table/bad-key-syntax.toml @@ -0,0 +1 @@ +tbl = { a = 1, [b] } diff --git a/internal/toml-test/tests/invalid/inline-table/dotted-key-conflict.toml b/internal/toml-test/tests/invalid/inline-table/dotted-key-conflict.toml new file mode 100644 index 00000000..58fa3b2a --- /dev/null +++ b/internal/toml-test/tests/invalid/inline-table/dotted-key-conflict.toml @@ -0,0 +1 @@ +tbl = { a.b = "a_b", a.b.c = "a_b_c" } diff --git a/internal/toml-test/tests/invalid/inline-table/nested_key_conflict.toml b/internal/toml-test/tests/invalid/inline-table/nested_key_conflict.toml new file mode 100644 index 00000000..c567c3f5 --- /dev/null +++ b/internal/toml-test/tests/invalid/inline-table/nested_key_conflict.toml @@ -0,0 +1,2 @@ +tbl = { fruit = { apple.color = "red" }, fruit.apple.texture = { smooth = true } } + diff --git a/internal/toml-test/tests/invalid/spec/inline-table-2-0.toml b/internal/toml-test/tests/invalid/spec/inline-table-2-0.toml new file mode 100644 index 00000000..7689e14f --- /dev/null +++ b/internal/toml-test/tests/invalid/spec/inline-table-2-0.toml @@ -0,0 +1,3 @@ +[product] +type = { name = "Nail" } +type.edible = false # INVALID diff --git a/internal/toml-test/tests/invalid/spec/inline-table-3-0.toml b/internal/toml-test/tests/invalid/spec/inline-table-3-0.toml new file mode 100644 index 00000000..d6937eb8 --- /dev/null +++ b/internal/toml-test/tests/invalid/spec/inline-table-3-0.toml @@ -0,0 +1,3 @@ +[product] +type.name = "Nail" +type = { edible = false } # INVALID diff --git a/internal/toml-test/tests/invalid/spec/key-value-pair-1.toml b/internal/toml-test/tests/invalid/spec/key-value-pair-1.toml new file mode 100644 index 00000000..56f085a5 --- /dev/null +++ b/internal/toml-test/tests/invalid/spec/key-value-pair-1.toml @@ -0,0 +1 @@ +key = # INVALID diff --git a/internal/toml-test/tests/invalid/spec/keys-2.toml b/internal/toml-test/tests/invalid/spec/keys-2.toml new file mode 100644 index 00000000..1547a5c7 --- /dev/null +++ b/internal/toml-test/tests/invalid/spec/keys-2.toml @@ -0,0 +1,3 @@ += "no key name" # INVALID +"" = "blank" # VALID but discouraged +'' = 'blank' # VALID but discouraged diff --git a/internal/toml-test/tests/invalid/spec/string-4-0.toml b/internal/toml-test/tests/invalid/spec/string-4-0.toml new file mode 100644 index 00000000..72071ea9 --- /dev/null +++ b/internal/toml-test/tests/invalid/spec/string-4-0.toml @@ -0,0 +1,7 @@ +str4 = """Here are two quotation marks: "". Simple enough.""" +str5 = """Here are three quotation marks: """.""" # INVALID +str5 = """Here are three quotation marks: ""\".""" +str6 = """Here are fifteen quotation marks: ""\"""\"""\"""\"""\".""" + +# "This," she said, "is just a pointless statement." +str7 = """"This," she said, "is just a pointless statement."""" diff --git a/internal/toml-test/tests/invalid/spec/string-7-0.toml b/internal/toml-test/tests/invalid/spec/string-7-0.toml new file mode 100644 index 00000000..7b20aeca --- /dev/null +++ b/internal/toml-test/tests/invalid/spec/string-7-0.toml @@ -0,0 +1,7 @@ +quot15 = '''Here are fifteen quotation marks: """""""""""""""''' + +apos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID +apos15 = "Here are fifteen apostrophes: '''''''''''''''" + +# 'That,' she said, 'is still pointless.' +str = ''''That,' she said, 'is still pointless.'''' diff --git a/internal/toml-test/tests/invalid/spec/table-9-0.toml b/internal/toml-test/tests/invalid/spec/table-9-0.toml new file mode 100644 index 00000000..adc38410 --- /dev/null +++ b/internal/toml-test/tests/invalid/spec/table-9-0.toml @@ -0,0 +1,9 @@ +[fruit] +apple.color = "red" +apple.taste.sweet = true + +[fruit.apple] # INVALID +# [fruit.apple.taste] # INVALID + +[fruit.apple.texture] # you can add sub-tables +smooth = true diff --git a/internal/toml-test/tests/invalid/spec/table-9-1.toml b/internal/toml-test/tests/invalid/spec/table-9-1.toml new file mode 100644 index 00000000..3b5644ea --- /dev/null +++ b/internal/toml-test/tests/invalid/spec/table-9-1.toml @@ -0,0 +1,9 @@ +[fruit] +apple.color = "red" +apple.taste.sweet = true + +# [fruit.apple] # INVALID +[fruit.apple.taste] # INVALID + +[fruit.apple.texture] # you can add sub-tables +smooth = true diff --git a/internal/toml-test/tests/invalid/table/append-to-array-with-dotted-keys.toml b/internal/toml-test/tests/invalid/table/append-to-array-with-dotted-keys.toml new file mode 100644 index 00000000..1cae3a9b --- /dev/null +++ b/internal/toml-test/tests/invalid/table/append-to-array-with-dotted-keys.toml @@ -0,0 +1,4 @@ +[[a.b]] + +[a] +b.y = 2 diff --git a/internal/toml-test/tests/invalid/table/duplicate-key-dotted-array.toml b/internal/toml-test/tests/invalid/table/duplicate-key-dotted-array.toml new file mode 100644 index 00000000..b75c2bc6 --- /dev/null +++ b/internal/toml-test/tests/invalid/table/duplicate-key-dotted-array.toml @@ -0,0 +1,4 @@ +[fruit] +apple.color = "red" + +[[fruit.apple]] diff --git a/internal/toml-test/tests/valid/comment/nonascii.json b/internal/toml-test/tests/valid/comment/nonascii.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/internal/toml-test/tests/valid/comment/nonascii.json @@ -0,0 +1 @@ +{} diff --git a/internal/toml-test/tests/valid/comment/nonascii.toml b/internal/toml-test/tests/valid/comment/nonascii.toml new file mode 100644 index 00000000..2fdde6b5 --- /dev/null +++ b/internal/toml-test/tests/valid/comment/nonascii.toml @@ -0,0 +1 @@ +# ~ € ÿ ퟿  ￿ 𐀀 􏿿 diff --git a/internal/toml-test/tests/valid/key/dotted-empty.json b/internal/toml-test/tests/valid/key/dotted-empty.json new file mode 100644 index 00000000..4ca4b507 --- /dev/null +++ b/internal/toml-test/tests/valid/key/dotted-empty.json @@ -0,0 +1,22 @@ +{ + "": { + "x": { + "type": "string", + "value": "empty.x" + } + }, + "x": { + "": { + "type": "string", + "value": "x.empty" + } + }, + "a": { + "": { + "": { + "type": "string", + "value": "empty.empty" + } + } + } +} diff --git a/internal/toml-test/tests/valid/key/dotted-empty.toml b/internal/toml-test/tests/valid/key/dotted-empty.toml new file mode 100644 index 00000000..45ef4c7e --- /dev/null +++ b/internal/toml-test/tests/valid/key/dotted-empty.toml @@ -0,0 +1,4 @@ +''.x = "empty.x" +x."" = "x.empty" +[a] +"".'' = "empty.empty" diff --git a/internal/toml-test/tests/valid/key/quoted-unicode.json b/internal/toml-test/tests/valid/key/quoted-unicode.json new file mode 100644 index 00000000..a51cc01f --- /dev/null +++ b/internal/toml-test/tests/valid/key/quoted-unicode.json @@ -0,0 +1,22 @@ +{ + "\u0000": { + "type": "string", + "value": "null" + }, + "\\u0000": { + "type": "string", + "value": "different key" + }, + "\b \f A \u007f \u0080 \u00ff \ud7ff \ue000 \uffff \ud800\udc00 \udbff\udfff": { + "type": "string", + "value": "escaped key" + }, + "~ \u0080 \u00ff \ud7ff \ue000 \uffff \ud800\udc00 \udbff\udfff": { + "type": "string", + "value": "basic key" + }, + "l ~ \u0080 \u00ff \ud7ff \ue000 \uffff \ud800\udc00 \udbff\udfff": { + "type": "string", + "value": "literal key" + } +} diff --git a/internal/toml-test/tests/valid/key/quoted-unicode.toml b/internal/toml-test/tests/valid/key/quoted-unicode.toml new file mode 100644 index 00000000..bc31b729 --- /dev/null +++ b/internal/toml-test/tests/valid/key/quoted-unicode.toml @@ -0,0 +1,7 @@ + +"\u0000" = "null" +'\u0000' = "different key" +"\u0008 \u000c \U00000041 \u007f \u0080 \u00ff \ud7ff \ue000 \uffff \U00010000 \U0010ffff" = "escaped key" + +"~ € ÿ ퟿  ￿ 𐀀 􏿿" = "basic key" +'l ~ € ÿ ퟿  ￿ 𐀀 􏿿' = "literal key" diff --git a/internal/toml-test/tests/valid/spec/array-0.json b/internal/toml-test/tests/valid/spec/array-0.json new file mode 100644 index 00000000..f150e9db --- /dev/null +++ b/internal/toml-test/tests/valid/spec/array-0.json @@ -0,0 +1,146 @@ +{ + "colors": [ + { + "type": "string", + "value": "red" + }, + { + "type": "string", + "value": "yellow" + }, + { + "type": "string", + "value": "green" + } + ], + "contributors": [ + { + "type": "string", + "value": "Foo Bar \u003cfoo@example.com\u003e" + }, + { + "email": { + "type": "string", + "value": "bazqux@example.com" + }, + "name": { + "type": "string", + "value": "Baz Qux" + }, + "url": { + "type": "string", + "value": "https://example.com/bazqux" + } + } + ], + "integers": [ + { + "type": "integer", + "value": "1" + }, + { + "type": "integer", + "value": "2" + }, + { + "type": "integer", + "value": "3" + } + ], + "nested_arrays_of_ints": [ + [ + { + "type": "integer", + "value": "1" + }, + { + "type": "integer", + "value": "2" + } + ], + [ + { + "type": "integer", + "value": "3" + }, + { + "type": "integer", + "value": "4" + }, + { + "type": "integer", + "value": "5" + } + ] + ], + "nested_mixed_array": [ + [ + { + "type": "integer", + "value": "1" + }, + { + "type": "integer", + "value": "2" + } + ], + [ + { + "type": "string", + "value": "a" + }, + { + "type": "string", + "value": "b" + }, + { + "type": "string", + "value": "c" + } + ] + ], + "numbers": [ + { + "type": "float", + "value": "0.1" + }, + { + "type": "float", + "value": "0.2" + }, + { + "type": "float", + "value": "0.5" + }, + { + "type": "integer", + "value": "1" + }, + { + "type": "integer", + "value": "2" + }, + { + "type": "integer", + "value": "5" + } + ], + "string_array": [ + { + "type": "string", + "value": "all" + }, + { + "type": "string", + "value": "strings" + }, + { + "type": "string", + "value": "are the same" + }, + { + "type": "string", + "value": "type" + } + ] +} diff --git a/internal/toml-test/tests/valid/spec/array-0.toml b/internal/toml-test/tests/valid/spec/array-0.toml new file mode 100644 index 00000000..467a8bc0 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/array-0.toml @@ -0,0 +1,12 @@ +integers = [ 1, 2, 3 ] +colors = [ "red", "yellow", "green" ] +nested_arrays_of_ints = [ [ 1, 2 ], [3, 4, 5] ] +nested_mixed_array = [ [ 1, 2 ], ["a", "b", "c"] ] +string_array = [ "all", 'strings', """are the same""", '''type''' ] + +# Mixed-type arrays are allowed +numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ] +contributors = [ + "Foo Bar ", + { name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" } +] diff --git a/internal/toml-test/tests/valid/spec/array-1.json b/internal/toml-test/tests/valid/spec/array-1.json new file mode 100644 index 00000000..334c3331 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/array-1.json @@ -0,0 +1,26 @@ +{ + "integers2": [ + { + "type": "integer", + "value": "1" + }, + { + "type": "integer", + "value": "2" + }, + { + "type": "integer", + "value": "3" + } + ], + "integers3": [ + { + "type": "integer", + "value": "1" + }, + { + "type": "integer", + "value": "2" + } + ] +} diff --git a/internal/toml-test/tests/valid/spec/array-1.toml b/internal/toml-test/tests/valid/spec/array-1.toml new file mode 100644 index 00000000..6acd9ca2 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/array-1.toml @@ -0,0 +1,8 @@ +integers2 = [ + 1, 2, 3 +] + +integers3 = [ + 1, + 2, # this is ok +] diff --git a/internal/toml-test/tests/valid/spec/array-of-tables-0.json b/internal/toml-test/tests/valid/spec/array-of-tables-0.json new file mode 100644 index 00000000..23287571 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/array-of-tables-0.json @@ -0,0 +1,29 @@ +{ + "products": [ + { + "name": { + "type": "string", + "value": "Hammer" + }, + "sku": { + "type": "integer", + "value": "738594937" + } + }, + {}, + { + "color": { + "type": "string", + "value": "gray" + }, + "name": { + "type": "string", + "value": "Nail" + }, + "sku": { + "type": "integer", + "value": "284758393" + } + } + ] +} diff --git a/internal/toml-test/tests/valid/spec/array-of-tables-0.toml b/internal/toml-test/tests/valid/spec/array-of-tables-0.toml new file mode 100644 index 00000000..544d142d --- /dev/null +++ b/internal/toml-test/tests/valid/spec/array-of-tables-0.toml @@ -0,0 +1,11 @@ +[[products]] +name = "Hammer" +sku = 738594937 + +[[products]] # empty table within the array + +[[products]] +name = "Nail" +sku = 284758393 + +color = "gray" diff --git a/internal/toml-test/tests/valid/spec/array-of-tables-1.json b/internal/toml-test/tests/valid/spec/array-of-tables-1.json new file mode 100644 index 00000000..17d49187 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/array-of-tables-1.json @@ -0,0 +1,48 @@ +{ + "fruits": [ + { + "name": { + "type": "string", + "value": "apple" + }, + "physical": { + "color": { + "type": "string", + "value": "red" + }, + "shape": { + "type": "string", + "value": "round" + } + }, + "varieties": [ + { + "name": { + "type": "string", + "value": "red delicious" + } + }, + { + "name": { + "type": "string", + "value": "granny smith" + } + } + ] + }, + { + "name": { + "type": "string", + "value": "banana" + }, + "varieties": [ + { + "name": { + "type": "string", + "value": "plantain" + } + } + ] + } + ] +} diff --git a/internal/toml-test/tests/valid/spec/array-of-tables-1.toml b/internal/toml-test/tests/valid/spec/array-of-tables-1.toml new file mode 100644 index 00000000..7a3971f3 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/array-of-tables-1.toml @@ -0,0 +1,19 @@ +[[fruits]] +name = "apple" + +[fruits.physical] # subtable +color = "red" +shape = "round" + +[[fruits.varieties]] # nested array of tables +name = "red delicious" + +[[fruits.varieties]] +name = "granny smith" + + +[[fruits]] +name = "banana" + +[[fruits.varieties]] +name = "plantain" diff --git a/internal/toml-test/tests/valid/spec/array-of-tables-2.json b/internal/toml-test/tests/valid/spec/array-of-tables-2.json new file mode 100644 index 00000000..f2e3f367 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/array-of-tables-2.json @@ -0,0 +1,46 @@ +{ + "points": [ + { + "x": { + "type": "integer", + "value": "1" + }, + "y": { + "type": "integer", + "value": "2" + }, + "z": { + "type": "integer", + "value": "3" + } + }, + { + "x": { + "type": "integer", + "value": "7" + }, + "y": { + "type": "integer", + "value": "8" + }, + "z": { + "type": "integer", + "value": "9" + } + }, + { + "x": { + "type": "integer", + "value": "2" + }, + "y": { + "type": "integer", + "value": "4" + }, + "z": { + "type": "integer", + "value": "8" + } + } + ] +} diff --git a/internal/toml-test/tests/valid/spec/array-of-tables-2.toml b/internal/toml-test/tests/valid/spec/array-of-tables-2.toml new file mode 100644 index 00000000..ba5584af --- /dev/null +++ b/internal/toml-test/tests/valid/spec/array-of-tables-2.toml @@ -0,0 +1,3 @@ +points = [ { x = 1, y = 2, z = 3 }, + { x = 7, y = 8, z = 9 }, + { x = 2, y = 4, z = 8 } ] diff --git a/internal/toml-test/tests/valid/spec/boolean-0.json b/internal/toml-test/tests/valid/spec/boolean-0.json new file mode 100644 index 00000000..f956ec02 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/boolean-0.json @@ -0,0 +1,10 @@ +{ + "bool1": { + "type": "bool", + "value": "true" + }, + "bool2": { + "type": "bool", + "value": "false" + } +} diff --git a/internal/toml-test/tests/valid/spec/boolean-0.toml b/internal/toml-test/tests/valid/spec/boolean-0.toml new file mode 100644 index 00000000..1f80fbd1 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/boolean-0.toml @@ -0,0 +1,2 @@ +bool1 = true +bool2 = false diff --git a/internal/toml-test/tests/valid/spec/comment-0.json b/internal/toml-test/tests/valid/spec/comment-0.json new file mode 100644 index 00000000..d9796079 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/comment-0.json @@ -0,0 +1,10 @@ +{ + "another": { + "type": "string", + "value": "# This is not a comment" + }, + "key": { + "type": "string", + "value": "value" + } +} diff --git a/internal/toml-test/tests/valid/spec/comment-0.toml b/internal/toml-test/tests/valid/spec/comment-0.toml new file mode 100644 index 00000000..fae57c60 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/comment-0.toml @@ -0,0 +1,3 @@ +# This is a full-line comment +key = "value" # This is a comment at the end of a line +another = "# This is not a comment" diff --git a/internal/toml-test/tests/valid/spec/float-0.json b/internal/toml-test/tests/valid/spec/float-0.json new file mode 100644 index 00000000..ae7d5a5c --- /dev/null +++ b/internal/toml-test/tests/valid/spec/float-0.json @@ -0,0 +1,30 @@ +{ + "flt1": { + "type": "float", + "value": "1" + }, + "flt2": { + "type": "float", + "value": "3.1415" + }, + "flt3": { + "type": "float", + "value": "-0.01" + }, + "flt4": { + "type": "float", + "value": "5e+22" + }, + "flt5": { + "type": "float", + "value": "1e+06" + }, + "flt6": { + "type": "float", + "value": "-0.02" + }, + "flt7": { + "type": "float", + "value": "6.626e-34" + } +} diff --git a/internal/toml-test/tests/valid/spec/float-0.toml b/internal/toml-test/tests/valid/spec/float-0.toml new file mode 100644 index 00000000..7b29c655 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/float-0.toml @@ -0,0 +1,12 @@ +# fractional +flt1 = +1.0 +flt2 = 3.1415 +flt3 = -0.01 + +# exponent +flt4 = 5e+22 +flt5 = 1e06 +flt6 = -2E-2 + +# both +flt7 = 6.626e-34 diff --git a/internal/toml-test/tests/valid/spec/float-1.json b/internal/toml-test/tests/valid/spec/float-1.json new file mode 100644 index 00000000..592a4d2e --- /dev/null +++ b/internal/toml-test/tests/valid/spec/float-1.json @@ -0,0 +1,6 @@ +{ + "flt8": { + "type": "float", + "value": "224617.445991228" + } +} diff --git a/internal/toml-test/tests/valid/spec/float-1.toml b/internal/toml-test/tests/valid/spec/float-1.toml new file mode 100644 index 00000000..3c8f0aa5 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/float-1.toml @@ -0,0 +1 @@ +flt8 = 224_617.445_991_228 diff --git a/internal/toml-test/tests/valid/spec/float-2.json b/internal/toml-test/tests/valid/spec/float-2.json new file mode 100644 index 00000000..95077204 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/float-2.json @@ -0,0 +1,26 @@ +{ + "sf1": { + "type": "float", + "value": "+Inf" + }, + "sf2": { + "type": "float", + "value": "+Inf" + }, + "sf3": { + "type": "float", + "value": "-Inf" + }, + "sf4": { + "type": "float", + "value": "nan" + }, + "sf5": { + "type": "float", + "value": "nan" + }, + "sf6": { + "type": "float", + "value": "nan" + } +} diff --git a/internal/toml-test/tests/valid/spec/float-2.toml b/internal/toml-test/tests/valid/spec/float-2.toml new file mode 100644 index 00000000..4cede55d --- /dev/null +++ b/internal/toml-test/tests/valid/spec/float-2.toml @@ -0,0 +1,9 @@ +# 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 diff --git a/internal/toml-test/tests/valid/spec/inline-table-0.json b/internal/toml-test/tests/valid/spec/inline-table-0.json new file mode 100644 index 00000000..8c0d3150 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/inline-table-0.json @@ -0,0 +1,30 @@ +{ + "animal": { + "type": { + "name": { + "type": "string", + "value": "pug" + } + } + }, + "name": { + "first": { + "type": "string", + "value": "Tom" + }, + "last": { + "type": "string", + "value": "Preston-Werner" + } + }, + "point": { + "x": { + "type": "integer", + "value": "1" + }, + "y": { + "type": "integer", + "value": "2" + } + } +} diff --git a/internal/toml-test/tests/valid/spec/inline-table-0.toml b/internal/toml-test/tests/valid/spec/inline-table-0.toml new file mode 100644 index 00000000..26062b51 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/inline-table-0.toml @@ -0,0 +1,3 @@ +name = { first = "Tom", last = "Preston-Werner" } +point = { x = 1, y = 2 } +animal = { type.name = "pug" } diff --git a/internal/toml-test/tests/valid/spec/inline-table-1.json b/internal/toml-test/tests/valid/spec/inline-table-1.json new file mode 100644 index 00000000..8c0d3150 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/inline-table-1.json @@ -0,0 +1,30 @@ +{ + "animal": { + "type": { + "name": { + "type": "string", + "value": "pug" + } + } + }, + "name": { + "first": { + "type": "string", + "value": "Tom" + }, + "last": { + "type": "string", + "value": "Preston-Werner" + } + }, + "point": { + "x": { + "type": "integer", + "value": "1" + }, + "y": { + "type": "integer", + "value": "2" + } + } +} diff --git a/internal/toml-test/tests/valid/spec/inline-table-1.toml b/internal/toml-test/tests/valid/spec/inline-table-1.toml new file mode 100644 index 00000000..6f72155f --- /dev/null +++ b/internal/toml-test/tests/valid/spec/inline-table-1.toml @@ -0,0 +1,10 @@ +[name] +first = "Tom" +last = "Preston-Werner" + +[point] +x = 1 +y = 2 + +[animal] +type.name = "pug" diff --git a/internal/toml-test/tests/valid/spec/inline-table-2.json b/internal/toml-test/tests/valid/spec/inline-table-2.json new file mode 100644 index 00000000..406691d1 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/inline-table-2.json @@ -0,0 +1,10 @@ +{ + "product": { + "type": { + "name": { + "type": "string", + "value": "Nail" + } + } + } +} diff --git a/internal/toml-test/tests/valid/spec/inline-table-2.toml b/internal/toml-test/tests/valid/spec/inline-table-2.toml new file mode 100644 index 00000000..aabb5005 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/inline-table-2.toml @@ -0,0 +1,3 @@ +[product] +type = { name = "Nail" } +# type.edible = false # INVALID diff --git a/internal/toml-test/tests/valid/spec/inline-table-3.json b/internal/toml-test/tests/valid/spec/inline-table-3.json new file mode 100644 index 00000000..406691d1 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/inline-table-3.json @@ -0,0 +1,10 @@ +{ + "product": { + "type": { + "name": { + "type": "string", + "value": "Nail" + } + } + } +} diff --git a/internal/toml-test/tests/valid/spec/inline-table-3.toml b/internal/toml-test/tests/valid/spec/inline-table-3.toml new file mode 100644 index 00000000..970949c3 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/inline-table-3.toml @@ -0,0 +1,3 @@ +[product] +type.name = "Nail" +# type = { edible = false } # INVALID diff --git a/internal/toml-test/tests/valid/spec/integer-0.json b/internal/toml-test/tests/valid/spec/integer-0.json new file mode 100644 index 00000000..72cbbbbf --- /dev/null +++ b/internal/toml-test/tests/valid/spec/integer-0.json @@ -0,0 +1,18 @@ +{ + "int1": { + "type": "integer", + "value": "99" + }, + "int2": { + "type": "integer", + "value": "42" + }, + "int3": { + "type": "integer", + "value": "0" + }, + "int4": { + "type": "integer", + "value": "-17" + } +} diff --git a/internal/toml-test/tests/valid/spec/integer-0.toml b/internal/toml-test/tests/valid/spec/integer-0.toml new file mode 100644 index 00000000..da14ea2a --- /dev/null +++ b/internal/toml-test/tests/valid/spec/integer-0.toml @@ -0,0 +1,4 @@ +int1 = +99 +int2 = 42 +int3 = 0 +int4 = -17 diff --git a/internal/toml-test/tests/valid/spec/integer-1.json b/internal/toml-test/tests/valid/spec/integer-1.json new file mode 100644 index 00000000..f431f47d --- /dev/null +++ b/internal/toml-test/tests/valid/spec/integer-1.json @@ -0,0 +1,18 @@ +{ + "int5": { + "type": "integer", + "value": "1000" + }, + "int6": { + "type": "integer", + "value": "5349221" + }, + "int7": { + "type": "integer", + "value": "5349221" + }, + "int8": { + "type": "integer", + "value": "12345" + } +} diff --git a/internal/toml-test/tests/valid/spec/integer-1.toml b/internal/toml-test/tests/valid/spec/integer-1.toml new file mode 100644 index 00000000..0c4b6190 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/integer-1.toml @@ -0,0 +1,4 @@ +int5 = 1_000 +int6 = 5_349_221 +int7 = 53_49_221 # Indian number system grouping +int8 = 1_2_3_4_5 # VALID but discouraged diff --git a/internal/toml-test/tests/valid/spec/integer-2.json b/internal/toml-test/tests/valid/spec/integer-2.json new file mode 100644 index 00000000..b937b2b8 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/integer-2.json @@ -0,0 +1,26 @@ +{ + "bin1": { + "type": "integer", + "value": "214" + }, + "hex1": { + "type": "integer", + "value": "3735928559" + }, + "hex2": { + "type": "integer", + "value": "3735928559" + }, + "hex3": { + "type": "integer", + "value": "3735928559" + }, + "oct1": { + "type": "integer", + "value": "342391" + }, + "oct2": { + "type": "integer", + "value": "493" + } +} diff --git a/internal/toml-test/tests/valid/spec/integer-2.toml b/internal/toml-test/tests/valid/spec/integer-2.toml new file mode 100644 index 00000000..ecffca63 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/integer-2.toml @@ -0,0 +1,11 @@ +# 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 diff --git a/internal/toml-test/tests/valid/spec/key-value-pair-0.json b/internal/toml-test/tests/valid/spec/key-value-pair-0.json new file mode 100644 index 00000000..af3154ab --- /dev/null +++ b/internal/toml-test/tests/valid/spec/key-value-pair-0.json @@ -0,0 +1,6 @@ +{ + "key": { + "type": "string", + "value": "value" + } +} diff --git a/internal/toml-test/tests/valid/spec/key-value-pair-0.toml b/internal/toml-test/tests/valid/spec/key-value-pair-0.toml new file mode 100644 index 00000000..e5b34ebc --- /dev/null +++ b/internal/toml-test/tests/valid/spec/key-value-pair-0.toml @@ -0,0 +1 @@ +key = "value" diff --git a/internal/toml-test/tests/valid/spec/keys-0.json b/internal/toml-test/tests/valid/spec/keys-0.json new file mode 100644 index 00000000..6130c71d --- /dev/null +++ b/internal/toml-test/tests/valid/spec/keys-0.json @@ -0,0 +1,18 @@ +{ + "1234": { + "type": "string", + "value": "value" + }, + "bare-key": { + "type": "string", + "value": "value" + }, + "bare_key": { + "type": "string", + "value": "value" + }, + "key": { + "type": "string", + "value": "value" + } +} diff --git a/internal/toml-test/tests/valid/spec/keys-0.toml b/internal/toml-test/tests/valid/spec/keys-0.toml new file mode 100644 index 00000000..657ff241 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/keys-0.toml @@ -0,0 +1,4 @@ +key = "value" +bare_key = "value" +bare-key = "value" +1234 = "value" diff --git a/internal/toml-test/tests/valid/spec/keys-1.json b/internal/toml-test/tests/valid/spec/keys-1.json new file mode 100644 index 00000000..fb756032 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/keys-1.json @@ -0,0 +1,22 @@ +{ + "127.0.0.1": { + "type": "string", + "value": "value" + }, + "character encoding": { + "type": "string", + "value": "value" + }, + "key2": { + "type": "string", + "value": "value" + }, + "quoted \"value\"": { + "type": "string", + "value": "value" + }, + "ʎǝʞ": { + "type": "string", + "value": "value" + } +} diff --git a/internal/toml-test/tests/valid/spec/keys-1.toml b/internal/toml-test/tests/valid/spec/keys-1.toml new file mode 100644 index 00000000..cc2d1d00 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/keys-1.toml @@ -0,0 +1,5 @@ +"127.0.0.1" = "value" +"character encoding" = "value" +"ʎǝʞ" = "value" +'key2' = "value" +'quoted "value"' = "value" diff --git a/internal/toml-test/tests/valid/spec/keys-3.json b/internal/toml-test/tests/valid/spec/keys-3.json new file mode 100644 index 00000000..b8ee7193 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/keys-3.json @@ -0,0 +1,22 @@ +{ + "name": { + "type": "string", + "value": "Orange" + }, + "physical": { + "color": { + "type": "string", + "value": "orange" + }, + "shape": { + "type": "string", + "value": "round" + } + }, + "site": { + "google.com": { + "type": "bool", + "value": "true" + } + } +} diff --git a/internal/toml-test/tests/valid/spec/keys-3.toml b/internal/toml-test/tests/valid/spec/keys-3.toml new file mode 100644 index 00000000..8f835713 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/keys-3.toml @@ -0,0 +1,4 @@ +name = "Orange" +physical.color = "orange" +physical.shape = "round" +site."google.com" = true diff --git a/internal/toml-test/tests/valid/spec/keys-4.json b/internal/toml-test/tests/valid/spec/keys-4.json new file mode 100644 index 00000000..c33966a5 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/keys-4.json @@ -0,0 +1,16 @@ +{ + "fruit": { + "color": { + "type": "string", + "value": "yellow" + }, + "flavor": { + "type": "string", + "value": "banana" + }, + "name": { + "type": "string", + "value": "banana" + } + } +} diff --git a/internal/toml-test/tests/valid/spec/keys-4.toml b/internal/toml-test/tests/valid/spec/keys-4.toml new file mode 100644 index 00000000..75bf90b5 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/keys-4.toml @@ -0,0 +1,3 @@ +fruit.name = "banana" # this is best practice +fruit. color = "yellow" # same as fruit.color +fruit . flavor = "banana" # same as fruit.flavor diff --git a/internal/toml-test/tests/valid/spec/keys-5.json b/internal/toml-test/tests/valid/spec/keys-5.json new file mode 100644 index 00000000..482b362d --- /dev/null +++ b/internal/toml-test/tests/valid/spec/keys-5.json @@ -0,0 +1,30 @@ +{ + "apple": { + "color": { + "type": "string", + "value": "red" + }, + "skin": { + "type": "string", + "value": "thin" + }, + "type": { + "type": "string", + "value": "fruit" + } + }, + "orange": { + "color": { + "type": "string", + "value": "orange" + }, + "skin": { + "type": "string", + "value": "thick" + }, + "type": { + "type": "string", + "value": "fruit" + } + } +} diff --git a/internal/toml-test/tests/valid/spec/keys-5.toml b/internal/toml-test/tests/valid/spec/keys-5.toml new file mode 100644 index 00000000..dc94a8c9 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/keys-5.toml @@ -0,0 +1,10 @@ +# VALID BUT DISCOURAGED + +apple.type = "fruit" +orange.type = "fruit" + +apple.skin = "thin" +orange.skin = "thick" + +apple.color = "red" +orange.color = "orange" diff --git a/internal/toml-test/tests/valid/spec/keys-6.json b/internal/toml-test/tests/valid/spec/keys-6.json new file mode 100644 index 00000000..482b362d --- /dev/null +++ b/internal/toml-test/tests/valid/spec/keys-6.json @@ -0,0 +1,30 @@ +{ + "apple": { + "color": { + "type": "string", + "value": "red" + }, + "skin": { + "type": "string", + "value": "thin" + }, + "type": { + "type": "string", + "value": "fruit" + } + }, + "orange": { + "color": { + "type": "string", + "value": "orange" + }, + "skin": { + "type": "string", + "value": "thick" + }, + "type": { + "type": "string", + "value": "fruit" + } + } +} diff --git a/internal/toml-test/tests/valid/spec/keys-6.toml b/internal/toml-test/tests/valid/spec/keys-6.toml new file mode 100644 index 00000000..705686c9 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/keys-6.toml @@ -0,0 +1,9 @@ +# RECOMMENDED + +apple.type = "fruit" +apple.skin = "thin" +apple.color = "red" + +orange.type = "fruit" +orange.skin = "thick" +orange.color = "orange" diff --git a/internal/toml-test/tests/valid/spec/keys-7.json b/internal/toml-test/tests/valid/spec/keys-7.json new file mode 100644 index 00000000..5ab0e066 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/keys-7.json @@ -0,0 +1,8 @@ +{ + "3": { + "14159": { + "type": "string", + "value": "pi" + } + } +} diff --git a/internal/toml-test/tests/valid/spec/keys-7.toml b/internal/toml-test/tests/valid/spec/keys-7.toml new file mode 100644 index 00000000..2efd659b --- /dev/null +++ b/internal/toml-test/tests/valid/spec/keys-7.toml @@ -0,0 +1 @@ +3.14159 = "pi" diff --git a/internal/toml-test/tests/valid/spec/local-date-0.json b/internal/toml-test/tests/valid/spec/local-date-0.json new file mode 100644 index 00000000..9e281f54 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/local-date-0.json @@ -0,0 +1,6 @@ +{ + "ld1": { + "type": "date-local", + "value": "1979-05-27" + } +} diff --git a/internal/toml-test/tests/valid/spec/local-date-0.toml b/internal/toml-test/tests/valid/spec/local-date-0.toml new file mode 100644 index 00000000..6670e5dd --- /dev/null +++ b/internal/toml-test/tests/valid/spec/local-date-0.toml @@ -0,0 +1 @@ +ld1 = 1979-05-27 diff --git a/internal/toml-test/tests/valid/spec/local-date-time-0.json b/internal/toml-test/tests/valid/spec/local-date-time-0.json new file mode 100644 index 00000000..d42d49d6 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/local-date-time-0.json @@ -0,0 +1,10 @@ +{ + "ldt1": { + "type": "datetime-local", + "value": "1979-05-27T07:32:00" + }, + "ldt2": { + "type": "datetime-local", + "value": "1979-05-27T00:32:00.999999" + } +} diff --git a/internal/toml-test/tests/valid/spec/local-date-time-0.toml b/internal/toml-test/tests/valid/spec/local-date-time-0.toml new file mode 100644 index 00000000..38700d21 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/local-date-time-0.toml @@ -0,0 +1,2 @@ +ldt1 = 1979-05-27T07:32:00 +ldt2 = 1979-05-27T00:32:00.999999 diff --git a/internal/toml-test/tests/valid/spec/local-time-0.json b/internal/toml-test/tests/valid/spec/local-time-0.json new file mode 100644 index 00000000..93803fc3 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/local-time-0.json @@ -0,0 +1,10 @@ +{ + "lt1": { + "type": "time-local", + "value": "07:32:00" + }, + "lt2": { + "type": "time-local", + "value": "00:32:00.999999" + } +} diff --git a/internal/toml-test/tests/valid/spec/local-time-0.toml b/internal/toml-test/tests/valid/spec/local-time-0.toml new file mode 100644 index 00000000..dbd058a6 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/local-time-0.toml @@ -0,0 +1,2 @@ +lt1 = 07:32:00 +lt2 = 00:32:00.999999 diff --git a/internal/toml-test/tests/valid/spec/offset-date-time-0.json b/internal/toml-test/tests/valid/spec/offset-date-time-0.json new file mode 100644 index 00000000..26d59a8c --- /dev/null +++ b/internal/toml-test/tests/valid/spec/offset-date-time-0.json @@ -0,0 +1,14 @@ +{ + "odt1": { + "type": "datetime", + "value": "1979-05-27T07:32:00Z" + }, + "odt2": { + "type": "datetime", + "value": "1979-05-27T00:32:00-07:00" + }, + "odt3": { + "type": "datetime", + "value": "1979-05-27T00:32:00.999999-07:00" + } +} diff --git a/internal/toml-test/tests/valid/spec/offset-date-time-0.toml b/internal/toml-test/tests/valid/spec/offset-date-time-0.toml new file mode 100644 index 00000000..52eaff2f --- /dev/null +++ b/internal/toml-test/tests/valid/spec/offset-date-time-0.toml @@ -0,0 +1,3 @@ +odt1 = 1979-05-27T07:32:00Z +odt2 = 1979-05-27T00:32:00-07:00 +odt3 = 1979-05-27T00:32:00.999999-07:00 diff --git a/internal/toml-test/tests/valid/spec/offset-date-time-1.json b/internal/toml-test/tests/valid/spec/offset-date-time-1.json new file mode 100644 index 00000000..fa17a4ea --- /dev/null +++ b/internal/toml-test/tests/valid/spec/offset-date-time-1.json @@ -0,0 +1,6 @@ +{ + "odt4": { + "type": "datetime", + "value": "1979-05-27T07:32:00Z" + } +} diff --git a/internal/toml-test/tests/valid/spec/offset-date-time-1.toml b/internal/toml-test/tests/valid/spec/offset-date-time-1.toml new file mode 100644 index 00000000..da9bd3bc --- /dev/null +++ b/internal/toml-test/tests/valid/spec/offset-date-time-1.toml @@ -0,0 +1 @@ +odt4 = 1979-05-27 07:32:00Z diff --git a/internal/toml-test/tests/valid/spec/string-0.json b/internal/toml-test/tests/valid/spec/string-0.json new file mode 100644 index 00000000..3c26fa17 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-0.json @@ -0,0 +1,6 @@ +{ + "str": { + "type": "string", + "value": "I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF." + } +} diff --git a/internal/toml-test/tests/valid/spec/string-0.toml b/internal/toml-test/tests/valid/spec/string-0.toml new file mode 100644 index 00000000..b6115490 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-0.toml @@ -0,0 +1 @@ +str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." diff --git a/internal/toml-test/tests/valid/spec/string-1.json b/internal/toml-test/tests/valid/spec/string-1.json new file mode 100644 index 00000000..316d0f4e --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-1.json @@ -0,0 +1,6 @@ +{ + "str1": { + "type": "string", + "value": "Roses are red\nViolets are blue" + } +} diff --git a/internal/toml-test/tests/valid/spec/string-1.toml b/internal/toml-test/tests/valid/spec/string-1.toml new file mode 100644 index 00000000..337ad080 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-1.toml @@ -0,0 +1,3 @@ +str1 = """ +Roses are red +Violets are blue""" diff --git a/internal/toml-test/tests/valid/spec/string-2.json b/internal/toml-test/tests/valid/spec/string-2.json new file mode 100644 index 00000000..09faeb6b --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-2.json @@ -0,0 +1,10 @@ +{ + "str2": { + "type": "string", + "value": "Roses are red\nViolets are blue" + }, + "str3": { + "type": "string", + "value": "Roses are red\r\nViolets are blue" + } +} diff --git a/internal/toml-test/tests/valid/spec/string-2.toml b/internal/toml-test/tests/valid/spec/string-2.toml new file mode 100644 index 00000000..ce5a73be --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-2.toml @@ -0,0 +1,5 @@ +# 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" diff --git a/internal/toml-test/tests/valid/spec/string-3.json b/internal/toml-test/tests/valid/spec/string-3.json new file mode 100644 index 00000000..c55424f7 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-3.json @@ -0,0 +1,14 @@ +{ + "str1": { + "type": "string", + "value": "The quick brown fox jumps over the lazy dog." + }, + "str2": { + "type": "string", + "value": "The quick brown fox jumps over the lazy dog." + }, + "str3": { + "type": "string", + "value": "The quick brown fox jumps over the lazy dog." + } +} diff --git a/internal/toml-test/tests/valid/spec/string-3.toml b/internal/toml-test/tests/valid/spec/string-3.toml new file mode 100644 index 00000000..20b4aa7c --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-3.toml @@ -0,0 +1,15 @@ +# The following strings are byte-for-byte equivalent: +str1 = "The quick brown fox jumps over the lazy dog." + +str2 = """ +The quick brown \ + + + fox jumps over \ + the lazy dog.""" + +str3 = """\ + The quick brown \ + fox jumps over \ + the lazy dog.\ + """ diff --git a/internal/toml-test/tests/valid/spec/string-4.json b/internal/toml-test/tests/valid/spec/string-4.json new file mode 100644 index 00000000..52ddb197 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-4.json @@ -0,0 +1,18 @@ +{ + "str4": { + "type": "string", + "value": "Here are two quotation marks: \"\". Simple enough." + }, + "str5": { + "type": "string", + "value": "Here are three quotation marks: \"\"\"." + }, + "str6": { + "type": "string", + "value": "Here are fifteen quotation marks: \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"." + }, + "str7": { + "type": "string", + "value": "\"This,\" she said, \"is just a pointless statement.\"" + } +} diff --git a/internal/toml-test/tests/valid/spec/string-4.toml b/internal/toml-test/tests/valid/spec/string-4.toml new file mode 100644 index 00000000..8f51b117 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-4.toml @@ -0,0 +1,7 @@ +str4 = """Here are two quotation marks: "". Simple enough.""" +# str5 = """Here are three quotation marks: """.""" # INVALID +str5 = """Here are three quotation marks: ""\".""" +str6 = """Here are fifteen quotation marks: ""\"""\"""\"""\"""\".""" + +# "This," she said, "is just a pointless statement." +str7 = """"This," she said, "is just a pointless statement."""" diff --git a/internal/toml-test/tests/valid/spec/string-5.json b/internal/toml-test/tests/valid/spec/string-5.json new file mode 100644 index 00000000..bce72d90 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-5.json @@ -0,0 +1,18 @@ +{ + "quoted": { + "type": "string", + "value": "Tom \"Dubs\" Preston-Werner" + }, + "regex": { + "type": "string", + "value": "\u003c\\i\\c*\\s*\u003e" + }, + "winpath": { + "type": "string", + "value": "C:\\Users\\nodejs\\templates" + }, + "winpath2": { + "type": "string", + "value": "\\\\ServerX\\admin$\\system32\\" + } +} diff --git a/internal/toml-test/tests/valid/spec/string-5.toml b/internal/toml-test/tests/valid/spec/string-5.toml new file mode 100644 index 00000000..36772bb6 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-5.toml @@ -0,0 +1,5 @@ +# What you see is what you get. +winpath = 'C:\Users\nodejs\templates' +winpath2 = '\\ServerX\admin$\system32\' +quoted = 'Tom "Dubs" Preston-Werner' +regex = '<\i\c*\s*>' diff --git a/internal/toml-test/tests/valid/spec/string-6.json b/internal/toml-test/tests/valid/spec/string-6.json new file mode 100644 index 00000000..aa7663e0 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-6.json @@ -0,0 +1,10 @@ +{ + "lines": { + "type": "string", + "value": "The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n" + }, + "regex2": { + "type": "string", + "value": "I [dw]on't need \\d{2} apples" + } +} diff --git a/internal/toml-test/tests/valid/spec/string-6.toml b/internal/toml-test/tests/valid/spec/string-6.toml new file mode 100644 index 00000000..bc88494c --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-6.toml @@ -0,0 +1,7 @@ +regex2 = '''I [dw]on't need \d{2} apples''' +lines = ''' +The first newline is +trimmed in raw strings. + All other whitespace + is preserved. +''' diff --git a/internal/toml-test/tests/valid/spec/string-7.json b/internal/toml-test/tests/valid/spec/string-7.json new file mode 100644 index 00000000..ad0fff21 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-7.json @@ -0,0 +1,14 @@ +{ + "apos15": { + "type": "string", + "value": "Here are fifteen apostrophes: '''''''''''''''" + }, + "quot15": { + "type": "string", + "value": "Here are fifteen quotation marks: \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"" + }, + "str": { + "type": "string", + "value": "'That,' she said, 'is still pointless.'" + } +} diff --git a/internal/toml-test/tests/valid/spec/string-7.toml b/internal/toml-test/tests/valid/spec/string-7.toml new file mode 100644 index 00000000..82890b08 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/string-7.toml @@ -0,0 +1,7 @@ +quot15 = '''Here are fifteen quotation marks: """""""""""""""''' + +# apos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID +apos15 = "Here are fifteen apostrophes: '''''''''''''''" + +# 'That,' she said, 'is still pointless.' +str = ''''That,' she said, 'is still pointless.'''' diff --git a/internal/toml-test/tests/valid/spec/table-0.json b/internal/toml-test/tests/valid/spec/table-0.json new file mode 100644 index 00000000..b6e7fb50 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-0.json @@ -0,0 +1,3 @@ +{ + "table": {} +} diff --git a/internal/toml-test/tests/valid/spec/table-0.toml b/internal/toml-test/tests/valid/spec/table-0.toml new file mode 100644 index 00000000..f1098fda --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-0.toml @@ -0,0 +1 @@ +[table] diff --git a/internal/toml-test/tests/valid/spec/table-1.json b/internal/toml-test/tests/valid/spec/table-1.json new file mode 100644 index 00000000..f8521e0f --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-1.json @@ -0,0 +1,22 @@ +{ + "table-1": { + "key1": { + "type": "string", + "value": "some string" + }, + "key2": { + "type": "integer", + "value": "123" + } + }, + "table-2": { + "key1": { + "type": "string", + "value": "another string" + }, + "key2": { + "type": "integer", + "value": "456" + } + } +} diff --git a/internal/toml-test/tests/valid/spec/table-1.toml b/internal/toml-test/tests/valid/spec/table-1.toml new file mode 100644 index 00000000..6b4884c2 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-1.toml @@ -0,0 +1,7 @@ +[table-1] +key1 = "some string" +key2 = 123 + +[table-2] +key1 = "another string" +key2 = 456 diff --git a/internal/toml-test/tests/valid/spec/table-2.json b/internal/toml-test/tests/valid/spec/table-2.json new file mode 100644 index 00000000..afb74d59 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-2.json @@ -0,0 +1,12 @@ +{ + "dog": { + "tater.man": { + "type": { + "name": { + "type": "string", + "value": "pug" + } + } + } + } +} diff --git a/internal/toml-test/tests/valid/spec/table-2.toml b/internal/toml-test/tests/valid/spec/table-2.toml new file mode 100644 index 00000000..32cbe792 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-2.toml @@ -0,0 +1,2 @@ +[dog."tater.man"] +type.name = "pug" diff --git a/internal/toml-test/tests/valid/spec/table-3.json b/internal/toml-test/tests/valid/spec/table-3.json new file mode 100644 index 00000000..0e40e3fd --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-3.json @@ -0,0 +1,22 @@ +{ + "a": { + "b": { + "c": {} + } + }, + "d": { + "e": { + "f": {} + } + }, + "g": { + "h": { + "i": {} + } + }, + "j": { + "ʞ": { + "l": {} + } + } +} diff --git a/internal/toml-test/tests/valid/spec/table-3.toml b/internal/toml-test/tests/valid/spec/table-3.toml new file mode 100644 index 00000000..0b10db3a --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-3.toml @@ -0,0 +1,4 @@ +[a.b.c] # this is best practice +[ d.e.f ] # same as [d.e.f] +[ g . h . i ] # same as [g.h.i] +[ j . "ʞ" . 'l' ] # same as [j."ʞ".'l'] diff --git a/internal/toml-test/tests/valid/spec/table-4.json b/internal/toml-test/tests/valid/spec/table-4.json new file mode 100644 index 00000000..3c390c68 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-4.json @@ -0,0 +1,9 @@ +{ + "x": { + "y": { + "z": { + "w": {} + } + } + } +} diff --git a/internal/toml-test/tests/valid/spec/table-4.toml b/internal/toml-test/tests/valid/spec/table-4.toml new file mode 100644 index 00000000..256e6c08 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-4.toml @@ -0,0 +1,6 @@ +# [x] you +# [x.y] don't +# [x.y.z] need these +[x.y.z.w] # for this to work + +[x] # defining a super-table afterward is ok diff --git a/internal/toml-test/tests/valid/spec/table-5.json b/internal/toml-test/tests/valid/spec/table-5.json new file mode 100644 index 00000000..2ec84071 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-5.json @@ -0,0 +1,7 @@ +{ + "animal": {}, + "fruit": { + "apple": {}, + "orange": {} + } +} diff --git a/internal/toml-test/tests/valid/spec/table-5.toml b/internal/toml-test/tests/valid/spec/table-5.toml new file mode 100644 index 00000000..03fe3a3e --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-5.toml @@ -0,0 +1,4 @@ +# VALID BUT DISCOURAGED +[fruit.apple] +[animal] +[fruit.orange] diff --git a/internal/toml-test/tests/valid/spec/table-6.json b/internal/toml-test/tests/valid/spec/table-6.json new file mode 100644 index 00000000..2ec84071 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-6.json @@ -0,0 +1,7 @@ +{ + "animal": {}, + "fruit": { + "apple": {}, + "orange": {} + } +} diff --git a/internal/toml-test/tests/valid/spec/table-6.toml b/internal/toml-test/tests/valid/spec/table-6.toml new file mode 100644 index 00000000..ef330e40 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-6.toml @@ -0,0 +1,4 @@ +# RECOMMENDED +[fruit.apple] +[fruit.orange] +[animal] diff --git a/internal/toml-test/tests/valid/spec/table-7.json b/internal/toml-test/tests/valid/spec/table-7.json new file mode 100644 index 00000000..3bdfe953 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-7.json @@ -0,0 +1,20 @@ +{ + "breed": { + "type": "string", + "value": "pug" + }, + "name": { + "type": "string", + "value": "Fido" + }, + "owner": { + "member_since": { + "type": "date-local", + "value": "1999-08-04" + }, + "name": { + "type": "string", + "value": "Regina Dogman" + } + } +} diff --git a/internal/toml-test/tests/valid/spec/table-7.toml b/internal/toml-test/tests/valid/spec/table-7.toml new file mode 100644 index 00000000..c57a2294 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-7.toml @@ -0,0 +1,8 @@ +# Top-level table begins. +name = "Fido" +breed = "pug" + +# Top-level table ends. +[owner] +name = "Regina Dogman" +member_since = 1999-08-04 diff --git a/internal/toml-test/tests/valid/spec/table-8.json b/internal/toml-test/tests/valid/spec/table-8.json new file mode 100644 index 00000000..dd59a518 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-8.json @@ -0,0 +1,16 @@ +{ + "fruit": { + "apple": { + "color": { + "type": "string", + "value": "red" + }, + "taste": { + "sweet": { + "type": "bool", + "value": "true" + } + } + } + } +} diff --git a/internal/toml-test/tests/valid/spec/table-8.toml b/internal/toml-test/tests/valid/spec/table-8.toml new file mode 100644 index 00000000..d5a2c11f --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-8.toml @@ -0,0 +1,7 @@ +fruit.apple.color = "red" +# Defines a table named fruit +# Defines a table named fruit.apple + +fruit.apple.taste.sweet = true +# Defines a table named fruit.apple.taste +# fruit and fruit.apple were already created diff --git a/internal/toml-test/tests/valid/spec/table-9.json b/internal/toml-test/tests/valid/spec/table-9.json new file mode 100644 index 00000000..89e8d5e5 --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-9.json @@ -0,0 +1,22 @@ +{ + "fruit": { + "apple": { + "color": { + "type": "string", + "value": "red" + }, + "taste": { + "sweet": { + "type": "bool", + "value": "true" + } + }, + "texture": { + "smooth": { + "type": "bool", + "value": "true" + } + } + } + } +} diff --git a/internal/toml-test/tests/valid/spec/table-9.toml b/internal/toml-test/tests/valid/spec/table-9.toml new file mode 100644 index 00000000..ae2d65bb --- /dev/null +++ b/internal/toml-test/tests/valid/spec/table-9.toml @@ -0,0 +1,9 @@ +[fruit] +apple.color = "red" +apple.taste.sweet = true + +# [fruit.apple] # INVALID +# [fruit.apple.taste] # INVALID + +[fruit.apple.texture] # you can add sub-tables +smooth = true diff --git a/internal/toml-test/tests/valid/string/quoted-unicode.json b/internal/toml-test/tests/valid/string/quoted-unicode.json new file mode 100644 index 00000000..9c6cc955 --- /dev/null +++ b/internal/toml-test/tests/valid/string/quoted-unicode.json @@ -0,0 +1,18 @@ +{ + "escaped_string": { + "type": "string", + "value": "\u0000 \b \f A \u007f \u0080 \u00ff \ud7ff \ue000 \uffff \ud800\udc00 \udbff\udfff" + }, + "not_escaped_string": { + "type": "string", + "value": "\\u0000 \\u0008 \\u000c \\U00000041 \\u007f \\u0080 \\u00ff \\ud7ff \\ue000 \\uffff \\U00010000 \\U0010ffff" + }, + "basic_string": { + "type": "string", + "value": "~ \u0080 \u00ff \ud7ff \ue000 \uffff \ud800\udc00 \udbff\udfff" + }, + "literal_string": { + "type": "string", + "value": "~ \u0080 \u00ff \ud7ff \ue000 \uffff \ud800\udc00 \udbff\udfff" + } +} diff --git a/internal/toml-test/tests/valid/string/quoted-unicode.toml b/internal/toml-test/tests/valid/string/quoted-unicode.toml new file mode 100644 index 00000000..3dfb1473 --- /dev/null +++ b/internal/toml-test/tests/valid/string/quoted-unicode.toml @@ -0,0 +1,6 @@ + +escaped_string = "\u0000 \u0008 \u000c \U00000041 \u007f \u0080 \u00ff \ud7ff \ue000 \uffff \U00010000 \U0010ffff" +not_escaped_string = '\u0000 \u0008 \u000c \U00000041 \u007f \u0080 \u00ff \ud7ff \ue000 \uffff \U00010000 \U0010ffff' + +basic_string = "~ € ÿ ퟿  ￿ 𐀀 􏿿" +literal_string = '~ € ÿ ퟿  ￿ 𐀀 􏿿' diff --git a/internal/toml-test/tests/valid/table/array-implicit-and-explicit-after.json b/internal/toml-test/tests/valid/table/array-implicit-and-explicit-after.json new file mode 100644 index 00000000..de156c5b --- /dev/null +++ b/internal/toml-test/tests/valid/table/array-implicit-and-explicit-after.json @@ -0,0 +1,16 @@ +{ + "a": { + "b": [ + { + "x": { + "type": "integer", + "value": "1" + } + } + ], + "y": { + "type": "integer", + "value": "2" + } + } +} diff --git a/internal/toml-test/tests/valid/table/array-implicit-and-explicit-after.toml b/internal/toml-test/tests/valid/table/array-implicit-and-explicit-after.toml new file mode 100644 index 00000000..bab8d619 --- /dev/null +++ b/internal/toml-test/tests/valid/table/array-implicit-and-explicit-after.toml @@ -0,0 +1,5 @@ +[[a.b]] +x = 1 + +[a] +y = 2 diff --git a/internal/toml-test/tests/valid/table/array-within-dotted.json b/internal/toml-test/tests/valid/table/array-within-dotted.json new file mode 100644 index 00000000..30b15173 --- /dev/null +++ b/internal/toml-test/tests/valid/table/array-within-dotted.json @@ -0,0 +1,18 @@ +{ + "fruit": { + "apple": { + "color": { + "type": "string", + "value": "red" + }, + "seeds": [ + { + "size": { + "type": "integer", + "value": "2" + } + } + ] + } + } +} diff --git a/internal/toml-test/tests/valid/table/array-within-dotted.toml b/internal/toml-test/tests/valid/table/array-within-dotted.toml new file mode 100644 index 00000000..3ecbeb70 --- /dev/null +++ b/internal/toml-test/tests/valid/table/array-within-dotted.toml @@ -0,0 +1,5 @@ +[fruit] +apple.color = "red" + +[[fruit.apple.seeds]] +size = 2 diff --git a/internal/toml-test/tests/valid/table/empty-name.json b/internal/toml-test/tests/valid/table/empty-name.json new file mode 100644 index 00000000..fc58e386 --- /dev/null +++ b/internal/toml-test/tests/valid/table/empty-name.json @@ -0,0 +1,22 @@ +{ + "": { + "x": { + "type": "integer", + "value": "1" + }, + "a": { + "x": { + "type": "integer", + "value": "2" + } + } + }, + "a": { + "": { + "x": { + "type": "integer", + "value": "3" + } + } + } +} diff --git a/internal/toml-test/tests/valid/table/empty-name.toml b/internal/toml-test/tests/valid/table/empty-name.toml new file mode 100644 index 00000000..3c98faac --- /dev/null +++ b/internal/toml-test/tests/valid/table/empty-name.toml @@ -0,0 +1,8 @@ +[''] +x = 1 + +["".a] +x = 2 + +[a.''] +x = 3 diff --git a/toml_test.go b/toml_test.go index 5e56c3ff..10c88b7c 100644 --- a/toml_test.go +++ b/toml_test.go @@ -313,14 +313,19 @@ func runTomlTest(t *testing.T, includeNext bool, wantFail ...string) { // https://github.com/BurntSushi/toml/issues/320 "invalid/datetime/time-no-leads", - // This test is fine, just doesn't deal well with empty output. + // These tests are fine, just doesn't deal well with empty output. "valid/comment/noeol", + "valid/comment/nonascii", - // TODO: fix this. + // TODO: fix this; we allow appending to tables, but shouldn't. "invalid/table/append-with-dotted*", "invalid/inline-table/add", "invalid/table/duplicate-key-dotted-table", "invalid/table/duplicate-key-dotted-table2", + "invalid/spec/inline-table-2-0", + "invalid/spec/table-9-1", + "invalid/inline-table/nested_key_conflict", + "invalid/table/append-to-array-with-dotted-keys", }, } if includeNext {