kdl-org / kdl

the kdl document language specifications
https://kdl.dev
Other
1.14k stars 62 forks source link

Test Case Library #115

Closed zkat closed 3 years ago

zkat commented 3 years ago

We should have a "standard" test case library with KDL examples that implementors can reference against. Possibly with expected transformations to, say, JSON?

Discussed in https://github.com/kdl-org/kdl/discussions/78

Originally posted by **hkolbeck-streem** January 15, 2021 As part of the development of [kdl4j](https://github.com/hkolbeck/kdl4j) I wrote up a fairly large set of test cases with the intent that they be usable by other implementations. At present there are about 160, and I hope they are useful to any other parsing library authors. Each test case consists of an input file and possibly an expected output file. If an output file exists, it means parsing should succeed and result in a document identical to the output file. In no output file exists, it means that parsing should fail. Because there is currently no standard for indentation, the presence of semicolons, etc, I had to pick one. If a standard is ever chosen I will update. I would very much welcome PRs adding additional cases, especially tricky ones that should fail to parse. They can be found here: https://github.com/hkolbeck/kdl4j/tree/trunk/src/test/resources, and the README there explains their usage more completely. The Java code I use to process them can be found here: https://github.com/hkolbeck/kdl4j/blob/trunk/src/test/java/dev/hbeck/kdl/TestRoundTrip.java
zkat commented 3 years ago

Merged: https://github.com/kdl-org/kdl/commit/fd478c29c7c2620f39451b947267325dee3b9ce6

There's a lot of test cases, and I eyeballed them a bit. We'll build up a bigger test suite over time and work out the kinks from there.

If you find a failure that you think disagrees with the current spec, please send a PR to fix the test. If you think the spec is wrong, start an issue so we can discuss.

zkat commented 3 years ago

thank you so much, @hkolbeck for this wonderful thing! It's so handy and I hope it helps implementors going forward!