bring over test suite from kdl4j

This commit is contained in:
Kat Marchán 2021-08-31 22:18:09 -07:00
parent 129812543f
commit 164d2d202e
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
290 changed files with 426 additions and 0 deletions

View File

@ -32,6 +32,14 @@ free to jump in and give us your 2 cents!
* PHP: [kdl-php](https://github.com/kdl-org/kdl-php)
* Python: [kdl-py](https://github.com/daeken/kdl-py)
## Compatibility Test Suite
There is a [compatibility test suite](tests/README.md) available for KDL
implementors to check that their implementations are actually spec-compatible.
The implementations above are not guaranteed to pass this test suite in its
entirety, but in the future, may be required to in order to be included here.
## Editor Support
* [VS Code](https://marketplace.visualstudio.com/items?itemName=kdl-org.kdl&ssr=false#review-details)

36
tests/README.md Normal file
View File

@ -0,0 +1,36 @@
# Full Document Test Cases
The `input` folder contains test cases for KDL parsers. The `expected_kdl`
folder contains files with the same name as those in `input` with the expected
output after being run through the parser and printed out again. If there's no
file in `expected_kdl` with a name corresponding to one in `input` it
indicates that parsing for that case should fail.
By necessity, the files in `expected_kdl` are not identical to their
corresponding inputs. They are instead pretty-printed according to the
following rules:
* All comments removed
* Extra empty lines removed except for a newline after the last node
* All nodes should be reformatted without escaped newlines
* Node fields should be `identifier <args in same order> <properties in alpha order by key> <children if non-empty>`
* All strings must be represented as regular strings, with appropriate escapes
for invalid bare characters. That means that raw strings must be converted
to plain strings, and escaped.
* Any literal newlines or other ascii escape characters in escaped strings
replaced with their escape sequences.
* All identifiers must be unquoted unless they _must_ be quoted. That means
`"foo"` becomes `foo`, and `"foo bar"` stays that way.
* Any duplicate properties must be removed, with only the rightmost one
remaining. This also means duplicate properties must be allowed.
* 4 space indents
* All numbers must be converted to their simplest decimal representation. That
means that hex, octal, and binary must all be converted to decimals. All
floats must be represented using `E` notation, with a single digit left of
the decimal point if the float is less than 1. While parsers are required to
_consume_ different number syntaxes, they are under no obligation to
represent numbers in any particular way.
Data may be manipulated as you wish in order to output the expected KDL. This
test suite verifies the ability to **parse**, not specific quirks about
internal representations.

View File

@ -0,0 +1 @@
node "\"\\\/\b\f\n\r\t"

View File

@ -0,0 +1,3 @@
node "arg" prop="val" {
inner_node
}

View File

@ -0,0 +1 @@
node "arg" arg="val"

View File

@ -0,0 +1 @@
node

View File

@ -0,0 +1 @@
😁 "happy!"

View File

@ -0,0 +1 @@
node 0b10

View File

@ -0,0 +1 @@
node 0b10

View File

@ -0,0 +1 @@
node 0b10

View File

@ -0,0 +1 @@
node "arg"

View File

@ -0,0 +1 @@
node "arg"

View File

@ -0,0 +1 @@
node

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@
node false true

View File

@ -0,0 +1 @@
node prop1=true prop2=false

View File

@ -0,0 +1 @@
node "arg2"

View File

@ -0,0 +1 @@
node "arg"

View File

@ -0,0 +1 @@
node_2

View File

@ -0,0 +1 @@
node_2

View File

@ -0,0 +1 @@
node "arg"

View File

@ -0,0 +1,2 @@
node1
node2

View File

@ -0,0 +1 @@
node "😀"

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,2 @@
node {
}

View File

@ -0,0 +1,2 @@
node {
}

View File

@ -0,0 +1,2 @@
node {
}

View File

@ -0,0 +1,2 @@
node {
}

View File

@ -0,0 +1 @@
"" "arg"

View File

@ -0,0 +1 @@
node ""="empty"

View File

@ -0,0 +1 @@
node ""

View File

@ -0,0 +1 @@
node "hello\nworld"

View File

@ -0,0 +1 @@
node "hello\nworld"

View File

@ -0,0 +1 @@
node "arg"

View File

@ -0,0 +1,2 @@
node1
node2

View File

@ -0,0 +1 @@
node "arg" "arg2\n"

View File

@ -0,0 +1,2 @@
node1
node2

View File

@ -0,0 +1 @@
node 0xabcdef1234567890

View File

@ -0,0 +1 @@
node 0xabcdef0123456789abcdef

View File

@ -0,0 +1 @@
node 0xabcdef0123

View File

@ -0,0 +1 @@
node 0x1

View File

@ -0,0 +1 @@
node 1234

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,3 @@
node {
inner_node
}

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@
node

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@
node

View File

@ -0,0 +1 @@
node 0b1

View File

@ -0,0 +1 @@
node 11

View File

@ -0,0 +1 @@
node 0o1

View File

@ -0,0 +1 @@
node "arg"

View File

@ -0,0 +1 @@
node "arg1" "arg2"

View File

@ -0,0 +1 @@
node " hey\neveryone\nhow goes?\n"

View File

@ -0,0 +1 @@
node 1.0E-10

View File

@ -0,0 +1 @@
node -1.0 key=-10.0

View File

@ -0,0 +1 @@
node -10 prop=-15

View File

@ -0,0 +1 @@
node "arg"

View File

@ -0,0 +1,5 @@
node1 {
node2 {
node
}
}

View File

@ -0,0 +1 @@
node "arg"

View File

@ -0,0 +1 @@
node "arg"

View File

@ -0,0 +1,2 @@
node1
node2

View File

@ -0,0 +1 @@
node "arg"

View File

@ -0,0 +1 @@
node 1E+10

View File

@ -0,0 +1 @@
node false

View File

@ -0,0 +1 @@
node true

View File

@ -0,0 +1 @@
node null

View File

@ -0,0 +1 @@
node prop=null

View File

@ -0,0 +1 @@
node 15.7

View File

@ -0,0 +1 @@
node prop=10.0

View File

@ -0,0 +1 @@
node 0o76543210

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@
node 1 1.0 1.0E+10 1.0E-10 0x1 0o7 0b10 "arg" "arg\\\\" true false null

View File

@ -0,0 +1 @@
node 1.0E+10

View File

@ -0,0 +1 @@
node 10

View File

@ -0,0 +1 @@
"0node"

View File

@ -0,0 +1 @@
node prop="10.0"

View File

@ -0,0 +1 @@
node "0prop"="val"

View File

@ -0,0 +1 @@
r "arg"

View File

@ -0,0 +1 @@
"\\node"

View File

@ -0,0 +1,3 @@
node_1 "arg\\n"
node_2 "\"arg\\n\"and stuff"
node_3 "#\"arg\\n\"#and stuff"

View File

@ -0,0 +1 @@
node "\\n"

View File

@ -0,0 +1 @@
node "#"

View File

@ -0,0 +1 @@
node "\\"

View File

@ -0,0 +1 @@
node "\""

View File

@ -0,0 +1 @@
node "\"#\"##"

View File

@ -0,0 +1 @@
node "\nhello\nworld\n"

View File

@ -0,0 +1,3 @@
node_1 prop="arg\\n"
node_2 prop="\"arg\"\\n"
node_3 prop="#\"arg\"#\\n"

View File

@ -0,0 +1 @@
node "a\"b"

View File

@ -0,0 +1 @@
node "arg" "arg"

View File

@ -0,0 +1 @@
node prop=11

View File

@ -0,0 +1 @@
node "whee" "whee"

View File

@ -0,0 +1,2 @@
node
node

View File

@ -0,0 +1 @@
node prop=1.23E+1000

View File

@ -0,0 +1 @@
node prop=1.23E-1000

View File

@ -0,0 +1,3 @@
node {
childnode
}

Some files were not shown because too many files have changed in this diff Show More