[antlr-interest] Status of gUnit?

antlr at xrad.org antlr at xrad.org
Wed Feb 23 11:28:54 PST 2011


Hi there,

I'm wondering what the status of gUnit is these days?  The SimpleC
example on the introductory web page fails when run against
examples-v3/java/LL-star/SimpleC.g, and various experiments of mine
don't seem to come out as expected either.

  http://www.antlr.org/wiki/display/ANTLR3/gUnit+-+Grammar+Unit+Testing

.. as is, this fails because 

  "int x;" -> OK

doesn't appear to be valid in the current grammar (I'm using
antlr-3.3-complete.jar) --- the "->" appears to be the problem, but if I
remove it then I get unexpected failures --- on the above test, for
example, all four of the OKs actually FAIL, even though the web page
suggests that three of them should pass:

  -----------------------------------------------------------------------
  executing testsuite for grammar:SimpleC with 11 tests
  -----------------------------------------------------------------------
  6 failures found:
  test2 (variable, line7) - 
  expected: OK
  actual: FAIL

  test3 (functionHeader, line11) - 
  expected: int
  actual: Invalid input

  test4 (program, line15) - 
  expected: OK
  actual: FAIL

  test5 (program, line20) - 
  expected: OK
  actual: FAIL

  test6 (program, line22) - 
  expected: 
  actual: Invalid input

  test8 (ID, line28) - 
  expected: OK
  actual: extra text found, '@999'

  Tests run: 11, Failures: 6

I get the same experience in my own code.  This grammar:

  grammar Simple;
  input : 'yes' ;

when run with this test:

  gunit Simple;
  input:
  "yes" OK
  "x" FAIL

fails as follows:

  -----------------------------------------------------------------------
  executing testsuite for grammar:Simple with 2 tests
  -----------------------------------------------------------------------
  1 failures found:
  test1 (input, line3) - 
  expected: OK
  actual: FAIL

  Tests run: 2, Failures: 1

Finally, the thing I would really like to do is to test my rewriting
grammar translator.  This doesn't work either --- there seems to be a
fundamental problem with rewriting grammars in gUnit's internals:

  grammar Simple;
  options { output=template; rewrite=true; }
  input : 'yes' -> template() "no" ;

tested with this:

  gunit Simple;
  input:
  "yes" -> "no"

results in this:

  -----------------------------------------------------------------------
  executing testsuite for grammar:Simple with 1 tests
  -----------------------------------------------------------------------
  1 failures found:
  test1 (input, line3) - 
  expected: no
  actual: java.lang.ClassCastException: org.antlr.runtime.CommonTokenStream can
not be cast to org.antlr.runtime.TokenRewriteStream

  Tests run: 1, Failures: 1

... any suggestions?  I tried rebuilding gUnit after editing the
offending CommonTokenStream declarations in gUnitExecutor to
TokenRewriteStreams --- just to see if it helped --- and it does make
things work again, at least with this trivial example.  Not so clear
with more complex stuff though.  Something similar to this seemed to be
reported a few years back (without official response), so I'm wondering
whether gUnit's no longer actively maintained?

Conrad


More information about the antlr-interest mailing list