Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Add tests from @iarna/toml-spec-tests in prescribed JSON format #8

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.toml text=auto
*.yaml text=auto
values/spec-newline-*.toml binary
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/setup-python@v2
# Setup pre-commit's cache
- name: set PY
run: echo "::set-env name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
run: echo "name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
- uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
Expand Down
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ repos:
- id: check-json
- id: end-of-file-fixer
- id: forbid-new-submodules
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/timothycrosley/isort
rev: 4.3.21-2
Expand Down
4 changes: 3 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2020 Pradyun Gedam
Copyright (c) 2021 Pradyun Gedam and Contributors
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to a strict reading of the MIT licence, the copyright notice should appear exactly as in the original, so something like:

Suggested change
Copyright (c) 2021 Pradyun Gedam and Contributors
Copyright (c) 2021 Pradyun Gedam and Contributors
Copyright Rebecca Turner <me@re-becca.org>

would be more appropriate than adding a new note at the bottom.

Copy link

@CAM-Gerlach CAM-Gerlach Mar 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I am not a licensed attorney, and the following should not be taken as formal legal advice.)

I concur with what you state above, as modifying the license text in this manner while not preserving the copyright notice intact, at its location in the original, is not an accepted approach for what is intended here.

To note, I do offer an alternate suggestion, as multiple copyright lines of text, rather than the single one matching the form of the one specified as variable in the SPDX definition of the MIT license, often breaks programmatic license detection and validation, including GitHub's. An alternative would be placing both complete copyright notices on the same line with clear lexical separation between them, like this:

Suggested change
Copyright (c) 2021 Pradyun Gedam and Contributors
Copyright Rebecca Turner <me@re-becca.org>; Copyright (c) 2021 Pradyun Gedam and Contributors

Given the original copyright notice is preserved and set off with a semicolon, both follow the form of standalone copyright notices, and this one line is permitted to vary without changing the legal effect of the license, it would seem equivalent separation is achieved without resorting to a line break.


Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -19,3 +19,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Portions of the Software include code copyright (c) Rebecca Turner.
4 changes: 4 additions & 0 deletions invalid/array/array-of-tables-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# INVALID TOML DOC
fruit = []

[[fruit]] # Not allowed
10 changes: 10 additions & 0 deletions invalid/array/array-of-tables-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# INVALID TOML DOC
[[fruit]]
name = "apple"

[[fruit.variety]]
name = "red delicious"

# This table conflicts with the previous table
[fruit.variety]
name = "granny smith"
Binary file added invalid/comment/comment-control-1.toml
Binary file not shown.
1 change: 1 addition & 0 deletions invalid/comment/comment-control-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = "ctrl-P" # 
1 change: 1 addition & 0 deletions invalid/comment/comment-control-3.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = "ctrl-_" # 
1 change: 1 addition & 0 deletions invalid/comment/comment-control-4.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = "0x7f" # 
1 change: 1 addition & 0 deletions invalid/integer/int-0-padded.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int = 0123
1 change: 1 addition & 0 deletions invalid/integer/int-signed-bin.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin = +0b10
1 change: 1 addition & 0 deletions invalid/integer/int-signed-hex.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hex = +0xab
1 change: 1 addition & 0 deletions invalid/integer/int-signed-oct.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oct = +0o23
1 change: 1 addition & 0 deletions invalid/key-value/bare-key-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bare!key = 123
2 changes: 2 additions & 0 deletions invalid/key-value/bare-key-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
barekey
= 123
1 change: 1 addition & 0 deletions invalid/key-value/bare-key-3.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
barekey =
1 change: 1 addition & 0 deletions invalid/key-value/key-value-pair-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
key = # INVALID
1 change: 1 addition & 0 deletions invalid/key-value/key-value-pair-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
first = "Tom" last = "Preston-Werner" # INVALID
8 changes: 8 additions & 0 deletions invalid/key-value/multiple-dot-key.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# THE FOLLOWING IS INVALID

# This defines the value of fruit.apple to be an integer.
fruit.apple = 1

# But then this treats fruit.apple like it's a table.
# You can't turn an integer into a table.
fruit.apple.smooth = true
3 changes: 3 additions & 0 deletions invalid/key-value/multiple-key.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DO NOT DO THIS
name = "Tom"
name = "Pradyun"
1 change: 1 addition & 0 deletions invalid/key-value/no-key-name.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= "no key name" # INVALID
Binary file added invalid/string/string-basic-control-1.toml
Binary file not shown.
1 change: 1 addition & 0 deletions invalid/string/string-basic-control-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = "ctrl-P"
1 change: 1 addition & 0 deletions invalid/string/string-basic-control-3.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = "ctrl-_"
1 change: 1 addition & 0 deletions invalid/string/string-basic-control-4.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = "0x7f"
Binary file not shown.
1 change: 1 addition & 0 deletions invalid/string/string-basic-multiline-control-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = """null"""
1 change: 1 addition & 0 deletions invalid/string/string-basic-multiline-control-3.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = """null"""
1 change: 1 addition & 0 deletions invalid/string/string-basic-multiline-control-4.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = """null"""
3 changes: 3 additions & 0 deletions invalid/string/string-basic-multiline-invalid-backslash.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a = """
foo \ \n
bar"""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = """\UFFFFFFFF"""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = """\U00D80000"""
1 change: 1 addition & 0 deletions invalid/string/string-basic-multiline-quotes.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
str5 = """Here are three quotation marks: """."""
1 change: 1 addition & 0 deletions invalid/string/string-basic-multiline-unknown-escape.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = """\@"""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = "\UFFFFFFFF"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = "\U00D80000"
1 change: 1 addition & 0 deletions invalid/string/string-basic-unknown-escape.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = "\@"
Binary file added invalid/string/string-literal-control-1.toml
Binary file not shown.
1 change: 1 addition & 0 deletions invalid/string/string-literal-control-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = 'null'
1 change: 1 addition & 0 deletions invalid/string/string-literal-control-3.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = 'null'
1 change: 1 addition & 0 deletions invalid/string/string-literal-control-4.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = 'null'
Binary file not shown.
1 change: 1 addition & 0 deletions invalid/string/string-literal-multiline-control-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = '''null'''
1 change: 1 addition & 0 deletions invalid/string/string-literal-multiline-control-4.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = '''null'''
1 change: 1 addition & 0 deletions invalid/string/string-literal-multiline-quotes.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID
3 changes: 3 additions & 0 deletions invalid/table/inline-table-immutable-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[product]
type = { name = "Nail" }
type.edible = false # INVALID
3 changes: 3 additions & 0 deletions invalid/table/inline-table-immutable-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[product]
type.name = "Nail"
type = { edible = false } # INVALID
1 change: 1 addition & 0 deletions invalid/table/inline-table-trailing-comma.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
abc = { abc = 123, }
7 changes: 7 additions & 0 deletions invalid/table/table-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# DO NOT DO THIS

[fruit]
apple = "red"

[fruit]
orange = "orange"
7 changes: 7 additions & 0 deletions invalid/table/table-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# DO NOT DO THIS EITHER

[fruit]
apple = "red"

[fruit.apple]
texture = "smooth"
5 changes: 5 additions & 0 deletions invalid/table/table-3.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[fruit]
apple.color = "red"
apple.taste.sweet = true

[fruit.apple] # INVALID
5 changes: 5 additions & 0 deletions invalid/table/table-4.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[fruit]
apple.color = "red"
apple.taste.sweet = true

[fruit.apple.taste] # INVALID
7 changes: 7 additions & 0 deletions invalid/table/table-invalid-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[fruit.physical] # subtable, but to which parent element should it belong?
color = "red"
shape = "round"

[[fruit]] # parser must throw an error upon discovering that "fruit" is
# an array rather than a table
name = "apple"
4 changes: 4 additions & 0 deletions invalid/table/table-invalid-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# INVALID TOML DOC
fruit = []

[[fruit]] # Not allowed
14 changes: 14 additions & 0 deletions invalid/table/table-invalid-3.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# INVALID TOML DOC
[[fruit]]
name = "apple"

[[fruit.variety]]
name = "red delicious"

# INVALID: This table conflicts with the previous array of tables
[fruit.variety]
name = "granny smith"

[fruit.physical]
color = "red"
shape = "round"
14 changes: 14 additions & 0 deletions invalid/table/table-invalid-4.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# INVALID TOML DOC
[[fruit]]
name = "apple"

[[fruit.variety]]
name = "red delicious"

[fruit.physical]
color = "red"
shape = "round"

# INVALID: This array of tables conflicts with the previous table
[[fruit.physical]]
color = "green"
5 changes: 5 additions & 0 deletions valid/array/spec-array-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"integers":
{"type":"array","value":[
{"type":"integer","value":"1"},
{"type":"integer","value":"2"},
{"type":"integer","value":"3"}]}}
1 change: 1 addition & 0 deletions valid/array/spec-array-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
integers = [ 1, 2, 3 ]
5 changes: 5 additions & 0 deletions valid/array/spec-array-2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"colors":
{"type":"array","value":[
{"type":"string","value":"red"},
{"type":"string","value":"yellow"},
{"type":"string","value":"green"}]}}
1 change: 1 addition & 0 deletions valid/array/spec-array-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colors = [ "red", "yellow", "green" ]
9 changes: 9 additions & 0 deletions valid/array/spec-array-3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{"nested_array_of_int":
{"type":"array","value":[
{"type":"array","value":[
{"type":"integer","value":"1"},
{"type":"integer","value":"2"}]},
{"type":"array","value":[
{"type":"integer","value":"3"},
{"type":"integer","value":"4"},
{"type":"integer","value":"5"}]}]}}
1 change: 1 addition & 0 deletions valid/array/spec-array-3.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nested_array_of_int = [ [ 1, 2 ], [3, 4, 5] ]
6 changes: 6 additions & 0 deletions valid/array/spec-array-4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{"string_array":
{"type":"array","value":[
{"type":"string","value":"all"},
{"type":"string","value":"strings"},
{"type":"string","value":"are the same"},
{"type":"string","value":"type"}]}}
1 change: 1 addition & 0 deletions valid/array/spec-array-4.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
string_array = [ "all", 'strings', """are the same""", '''type''']
9 changes: 9 additions & 0 deletions valid/array/spec-array-5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{"nested_mixed_array":
{"type":"array","value":[
{"type":"array","value":[
{"type":"integer","value":"1"},
{"type":"integer","value":"2"}]},
{"type":"array","value":[
{"type":"string","value":"a"},
{"type":"string","value":"b"},
{"type":"string","value":"c"}]}]}}
1 change: 1 addition & 0 deletions valid/array/spec-array-5.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nested_mixed_array = [ [ 1, 2 ], ["a", "b", "c"] ]
5 changes: 5 additions & 0 deletions valid/array/spec-array-7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"integers2":
{"type":"array","value":[
{"type":"integer","value":"1"},
{"type":"integer","value":"2"},
{"type":"integer","value":"3"}]}}
3 changes: 3 additions & 0 deletions valid/array/spec-array-7.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
integers2 = [
1, 2, 3
]
4 changes: 4 additions & 0 deletions valid/array/spec-array-8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{"integers3":
{"type":"array","value":[
{"type":"integer","value":"1"},
{"type":"integer","value":"2"}]}}
4 changes: 4 additions & 0 deletions valid/array/spec-array-8.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
integers3 = [
1,
2, # this is ok
]
8 changes: 8 additions & 0 deletions valid/array/spec-array-mixed-number-types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{"numbers":
{"type":"array","value":[
{"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"}]}}
1 change: 1 addition & 0 deletions valid/array/spec-array-mixed-number-types.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ]
9 changes: 9 additions & 0 deletions valid/array/spec-array-more-mixed-types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{"contributors":
{"type":"array","value":[
{"type":"string","value":"Foo Bar <foo@example.com>"},
{"name":
{"type":"string","value":"Baz Qux"},
"email":
{"type":"string","value":"bazqux@example.com"},
"url":
{"type":"string", "value":"https://example.com/bazqux"}}]}}
4 changes: 4 additions & 0 deletions valid/array/spec-array-more-mixed-types.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
contributors = [
"Foo Bar <foo@example.com>",
{ name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" }
]
13 changes: 13 additions & 0 deletions valid/array/spec-array-of-tables-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{"products":
{"type":"array","value":[
{"name":
{"type":"string","value":"Hammer"},
"sku":
{"type":"integer","value":"738594937"}},
{},
{"name":
{"type":"string","value":"Nail"},
"sku":
{"type":"integer","value":"284758393"},
"color":
{"type":"string","value":"gray"}}]}}
10 changes: 10 additions & 0 deletions valid/array/spec-array-of-tables-1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[[products]]
name = "Hammer"
sku = 738594937

[[products]]

[[products]]
name = "Nail"
sku = 284758393
color = "gray"
21 changes: 21 additions & 0 deletions valid/array/spec-array-of-tables-2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{"fruit":
{"type":"array","value":[
{"name":
{"type":"string","value":"apple"},
"physical":
{"color":
{"type":"string","value":"red"},
"shape":
{"type":"string","value":"round"}},
"variety":
{"type":"array","value":[
{"name":
{"type":"string","value":"red delicious"}},
{"name":
{"type":"string","value":"granny smith"}}]}},
{"name":
{"type":"string","value":"banana"},
"variety":
{"type":"array","value":[
{"name":
{"type":"string","value":"plantain"}}]}}]}}
18 changes: 18 additions & 0 deletions valid/array/spec-array-of-tables-2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[[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"
20 changes: 20 additions & 0 deletions valid/array/spec-array-of-tables-3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{"points":
{"type":"array","value":[
{"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"}}]}}
Loading