[antlr-interest] New release of ANTLR Testing

Jeremy Frens jdfrens at gmail.com
Sun Nov 30 15:04:01 PST 2008


ANTLR Testing is a unit testing library for ANTLR grammars using JUnit
and a fluid interface.  I use it on a couple of my own projects, and I
have students using it as well.

I released version 0.8 today.  You can get it here:
http://antlr-testing.sourceforge.net/ .  It has some nice new
features:

* I'm finally writing tests for my test framework.  (Infer what you
will from this.)
* I've made sure that it works with ANTLR 3.1.
* You no longer have to add a bunch of ugly code to your grammars to
override the normal error handling of ANTLR.
* I've added a refuteToken() method to assist in testing lexers.

I stole a trick from gUnit for the third item on this list.  Previous
versions of ANTLR Testing required you to add some code that would
always throw an exception when something went wrong in processing.
Now I look at standard error for any output; output means something
went wrong.

As for refuteToken(), I wanted to write assertions that said how input
should NOT be scanned.  Since I write my grammars incrementally (as a
good agile developer), refuteToken() is happy to accept a rejection
for a variety of reasons.

For example, if I first implement identifiers, I can write

refuteToken(MyLexer.IDENTIFIER, myTester.scanInput("123"));

Since something like "x123" is probably a valid identifier, I really
want to assert that an identifier cannot start with a digit.  I can do
this refuteToken() without having to define what an integer is!
Later, when INTEGER is defined, this assertion (refutation?) will
still pass because the token types will not match.

jdf

--
Jeremy D. Frens
jdfrens at gmail.com
http://www.norecess.org/


More information about the antlr-interest mailing list