[antlr-interest] gUnit help needed
Meikel
meikel at meikel.at
Sun May 22 04:04:46 PDT 2011
Hello,
I'm a beginner with ANTLR and with gUnit and need some help about gUnit. The
only documentation about gUnit I have is
http://www.antlr.org/wiki/display/ANTLR3/gUnit+-+Grammar+Unit+Testing
To get a better understanding of how gUnit works I created a really small
example which does not work correctly. I have a grammar for parsing language
{ a, A, b, B, ab, Ab, aB, AB } defined in a file Sample.g:
grammar Sample;
@header {
package parser;
}
@lexer::header {
package parser;
}
A : 'a' | 'A';
B : 'b' | 'B';
start : A
| (A B)
| B
;
Further I have some unit tests defined in file Sample.gunit:
gunit Sample;
@header{
package parser;
}
A:
"a" OK
"A" OK
"b" FAIL
B:
"b" OK
"B" OK
"a" FAIL
start:
"a" OK
"ab" OK
When I run the tests using Maven (org.antlr:maven-gunit-plugin:3.3) with
ANTLR 3.3 I get the following failures:
-----------------------------------------------------------------------
executing testsuite for grammar:Sample with 8 tests
-----------------------------------------------------------------------
2 failures found:
test7 (start, line19) -
expected: OK
actual: FAIL
test8 (start, line20) -
expected: OK
actual: FAIL
Tests run: 8, Failures: 2
What is the reason for the last two tests (for rule "start:") failing?
Perhaps this is not a problem with the test case but the grammar doesn't
work as expected?
Cheers,
Meikel
More information about the antlr-interest
mailing list