[antlr-interest] JUnit testing of ASTs

Terence Parr parrt at cs.usfca.edu
Tue Dec 21 10:33:07 PST 2004


On Dec 21, 2004, at 10:20 AM, Paul J. Lucas wrote:

> 	Does anybody do JUnit regression testing on their parsers?  If
> 	so, how, exactly?
>
> 	For lack of anything better, *a* way of doing it is to have a
> 	set of files to parse and the pretty-printed output of the
> 	expected ASTs.  Then, when you run the tests, simply diff their
> 	output with the expected output.
>
> 	Anything better?

Hi Paul,

In my debugging with derivations article I allude to something Loring 
suggested, which I think is precisely what you are saying: use parse 
trees / derivations to unit/functional test.  I do that now in ANTLR 
3.0 for testing.  I ask for the parse tree and then do a normalized 
string compare to see if anything has changed.

Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!





More information about the antlr-interest mailing list