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

Add tests for v1.0.0-rc from iarna's repository #5

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
378b885
initial
iarna Sep 3, 2018
8a5e3ed
Update docs
iarna Sep 4, 2018
0026b66
Start adding QA tests
iarna Sep 4, 2018
597013f
Add test for escaped line-ending backslashes
goodmami Apr 18, 2020
7ce51ef
Add test for invalid line-ending backslash
goodmami Apr 18, 2020
18c70a3
Add missing toml half of test for signed positive infinity
iarna Apr 20, 2020
58ef20e
Add tests for both CR and CR/LF line endings
iarna Apr 20, 2020
297ef38
Add missing YAML pair for first newline test
iarna Apr 21, 2020
318a34b
Add test for clarified non-use of comments in the middle of strings
iarna Apr 21, 2020
f2278bc
Clarify the content of the invalid control chars in strings tests
iarna Apr 21, 2020
881eaaa
Comments may only contain tab control chars and no others
iarna Apr 21, 2020
5ba6a43
Add test for spec all out of multiple key/value pairs on a line as in…
iarna Apr 21, 2020
63f5b00
Add test for new spec example of key sequences that look like floats
iarna Apr 21, 2020
a3ef632
Updated spec object extension tests
iarna Apr 21, 2020
115ec28
Update examples in spec tests to match spec updates
iarna Apr 21, 2020
864eaf2
Add error checks for trying to sign hex/bin/oct numbers
iarna Apr 21, 2020
b878057
Add tests to verify that tab characters are valid in strings
iarna Apr 21, 2020
cd17ff1
Add updated spec tests for multiline strings
iarna Apr 21, 2020
67a8c42
Rename array spec tests to follow spec updates
iarna Apr 21, 2020
60a7f79
Allow heterogenous values in arrays
iarna Apr 21, 2020
ad39d95
Add new example from the spec's table section
iarna Apr 21, 2020
49055d5
Add new sub-table additions from spec examples
iarna Apr 21, 2020
f5d6834
Add new examples of invalid table extensions
iarna Apr 21, 2020
e1ca901
Add new examples of invalid inline table extensions
iarna Apr 21, 2020
4fbba72
Trailing commas in inline tables are invalid
iarna Apr 21, 2020
6edea42
Some more examples of invalid ways of extending tables
iarna Apr 21, 2020
1880b1a
Correct immutable table test
iarna Apr 22, 2020
1c5e0da
Add 'tests/v1.0.0-rc/' from commit '1880b1a17849f6ad49a7a5e87d6a3ac39…
amanbh Jun 24, 2020
ef41980
Rename values, errors to valid, invalid
amanbh Jun 24, 2020
f3e2207
Move tests out of v1.0.0-rc/
amanbh Jun 25, 2020
174fdb8
Update path to tests directory
amanbh Jun 25, 2020
1a786b6
Merge LICENSE files
amanbh Jul 17, 2020
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: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
The MIT License

Copyright (c) 2020 Pradyun Gedam

Copyright Rebecca Turner <me@re-becca.org>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
Expand Down
8 changes: 4 additions & 4 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def colored(s, *, fg=None, bg=None, bold=False):
# --------------------------------------------------------------------------------------
# Filesystem interaction
# --------------------------------------------------------------------------------------
here = Path(__file__).parent
tests_dir = Path(__file__).parent / "tests"


def ensure_executable(path):
Expand All @@ -98,12 +98,12 @@ def ensure_executable(path):


def _locate_test_pairs():
for path in (here / "invalid").glob("*.toml"):
for path in (tests_dir / "invalid").glob("*.toml"):
yield path, None
for path in (here / "invalid").glob("*.json"):
for path in (tests_dir / "invalid").glob("*.json"):
yield None, path

for path in (here / "valid").glob("*.toml"):
for path in (tests_dir / "valid").glob("*.toml"):
json_equivalent = path.with_suffix(".json")
assert json_equivalent.exists(), f"Missing: {json_equivalent}"
yield path, json_equivalent
Expand Down
3 changes: 3 additions & 0 deletions tests/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.toml text=auto
*.yaml text=auto
valid/spec-newline-*.toml binary
4 changes: 4 additions & 0 deletions tests/invalid/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 tests/invalid/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"
1 change: 1 addition & 0 deletions tests/invalid/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 tests/invalid/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 tests/invalid/bare-key-3.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
barekey =
Binary file added tests/invalid/comment-control-1.toml
Binary file not shown.
1 change: 1 addition & 0 deletions tests/invalid/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 tests/invalid/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 tests/invalid/comment-control-4.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = "0x7f" # 
3 changes: 3 additions & 0 deletions tests/invalid/inline-table-imutable-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 tests/invalid/inline-table-imutable-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 tests/invalid/inline-table-trailing-comma.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
abc = { abc = 123, }
1 change: 1 addition & 0 deletions tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/no-key-name.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= "no key name" # INVALID
Binary file added tests/invalid/string-basic-control-1.toml
Binary file not shown.
1 change: 1 addition & 0 deletions tests/invalid/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 tests/invalid/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 tests/invalid/string-basic-control-4.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = "0x7f"
Binary file added tests/invalid/string-basic-multiline-control-1.toml
Binary file not shown.
1 change: 1 addition & 0 deletions tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/string-basic-unknown-escape.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = "\@"
Binary file added tests/invalid/string-literal-control-1.toml
Binary file not shown.
1 change: 1 addition & 0 deletions tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/string-literal-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 tests/invalid/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 tests/invalid/string-literal-multiline-quotes.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID
7 changes: 7 additions & 0 deletions tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/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 tests/invalid/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"
Loading