I have a parser rule in ANTLR that takes a parameter.
tincture [Tinctures tinctures] returns [Tincture tincture]
: { String tinctureName = ""; }
( COLOUR { tinctureName = $COLOUR.text; }
| METAL { tinctureName = $METAL.text; }
| FUR { tinctureName = $FUR.text; }
)
{
try {
$tincture = tinctures.getTincture(tinctureName);
} catch (UnknownTinctureException e) {
throw new MyRecognitionException("Unknown tincture found.", e);
}
}
;
How can I write a test for this in GUnit?
I have successfully written tests for my Lexer rules as they do not have any parameters. If I write the following I get "java.lang.NoSuchMethodException: mypackage.BlazonParser.tincture()"
tincture
: "gules" OK
"sable" OK
"blah" FAIL
I can find very little documentation around GUnit apart from this page, but it hasn't covered this.