On Sat, Jun 11, 2011 at 7:10 AM, Andrew Coppin
<[email protected]>wrote:

>
> If you have a function that turns a parse tree back into text again, you
> can try verifying that a round-trip is the identity function. Except perhaps
> sometimes it isn't. Perhaps a given expression has more than one equivalent
> representation. A round-trip from string and back again is even less likely
> to be stable.
>

I find that this kind of testing works quite nicely in practice with
QuickCheck, in the sense that it does a good job of finding bugs in both the
unparser and the parser. It's possible, but unlikely, that you'll have a bug
in the parser and a bug in the unparser that cancel one another out.
Generate the ASTs; parse . unparse ought to be id, or perhaps t = t . parse
. unparse for some simple transformation 't'. For example, if the parser
annotates AST nodes with source positions, you may need 't' to strip them
out.

Kevin
-- 
Kevin Charter
[email protected]
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to