[antlr-interest] gUnit for v4?

Terence Parr parrt at cs.usfca.edu
Thu Apr 19 10:11:48 PDT 2012

Hi Kieran,

thanks very much for the feedback. What exactly were you testing when you say parts of your grammar and in different combinations? Were you testing the ASTs you created? It was very useful for that. Since v4 automatically builds trees, those trees will be correct unless there's a bug so there's nothing really to test as far as I can tell.
On Apr 18, 2012, at 9:56 PM, Kieran Simpson wrote:

> On 23/07/64 5:59 AM, Terence Parr wrote:
>> Hi,
>> I started down the path of building the new version of gUnit for v4, but I'm beginning to question its value for the new version. Because I am pooh-poohing putting actions directly within a grammar, grammar can only yield parse trees. and looks nice to be able to say:
>> expr:
>> 	"1"		->  (expr 1)
>> 	"1+2"	->  (expr (expr 1) + (expr 2))
>> but so what? all that did was confirm that the parser generated by ANTLR works correctly. it's not telling you anything you didn't know by looking at the grammar.
>> In the old days we used to build ASTs and so we needed to check the structure. That need is no longer here. Also, these rules don't generate output and so we can't check input to output translation.
>> What it comes down to is this: we really need functional testing not unit testing for language applications, unless of course each rule returns a string that the translation of the input some phrase or something. But, it's just as easy to write calls to assertEquals() saying that input x should yield input y. If we are doing something other than generating output, such as building up a data structure, then we really do need to manually check that the data structure is solid given some input.
>> I'm trying to find a flaw in my logic. Is there something I'm missing about testing grammars? In v4, they will give you exactly what you want, unless there is a bug in ANTLR. But that's my problem not yours.
>> If we can't find a major benefit, then we should avoid introducing another moving part to the ANTLR ecosystem.
> I find gUnit very helpful in testing parts of my grammar both in 
> isolation and different combinations.  I like being able to test token 
> definitions against different input.
> Where I find functional testing more beneficial is for tree walkers. 
> For my grammars that produce ASTs I've found the grammar tests useful in 
> preventing regression bugs.
> There's also testing in non Java languages to consider.  Having the 
> ability to have tests generated/run via JUnit may be easier than having 
> to piece together your tests in another language (eg: C) which I 
> personally find is more time consuming.
> Just a few thoughts.
> Cheers,
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address

More information about the antlr-interest mailing list