puffnfresh/roy — pull request #198 by kennknowles (2013-09-02 02:51:04+00:00)
Title: Add some basic type parser tests

Hello,

In order to more easily isolate parsing failures when editing the grammar, I thought I would begin a test suite just for the type parser. This is just a skeleton but I hope it is useful anyhow.

Notes and limitations:

- I did not find intentional equality on types in the codebase, so I used `toString()` which is obviously fragile and must be replaced in the long term.
- I just mimicked the parser creation from `compile.js` but am not entirely sure what that's about. Is it because it would take a layer of indirection from the generated parser to encapsulate the extra lexing logic?
- I would love to express all of these tests as the property `identity == parse . pretty` in a QuickCheck-like framework (like I did [here](https://github.com/inkling/scala-relaxng/blob/master/src/test/scala/ParsePrettySpec.scala#L65)).
- We would need to choose/write such a framework. (I've had some success with [killdream/claire](http://github.com/killdream/claire) but could see wanting to avoid a LiveScript dependency and/or create something that just directly mirrors QuickCheck and SmallCheck's concepts.)
- And create a generator for an arbitrary type, which is easy and almost always worthwhile.
- This property, along with just a few regression tests, is great for ensuring the health of a parser without having mountains of test cases to modify whenever you make a change to the language.

\- Kenn