public void TestNoWildcardAsRootError() /*throws Exception*/ { ErrorQueue equeue = new ErrorQueue(); ErrorManager.SetErrorListener(equeue); string treeGrammar = "tree grammar TP;\n" + "options {output=AST;}\n" + "a : ^(. INT) \n" + " ;\n"; Grammar g = new Grammar(treeGrammar); AntlrTool antlr = newTool(); antlr.SetOutputDirectory(null); // write to /dev/null CodeGenerator generator = new CodeGenerator(antlr, g, "Java"); g.CodeGenerator = generator; generator.GenRecognizer(); Assert.AreEqual(1, equeue.errors.Count, "unexpected errors: " + equeue); int expectedMsgID = ErrorManager.MSG_WILDCARD_AS_ROOT; object expectedArg = null; RecognitionException expectedExc = null; GrammarSyntaxMessage expectedMessage = new GrammarSyntaxMessage(expectedMsgID, g, null, expectedArg, expectedExc); checkError(equeue, expectedMessage); }
public void TestNoWildcardAsRootError() { ErrorQueue equeue = new ErrorQueue(); ErrorManager.SetErrorListener( equeue ); string treeGrammar = "tree grammar TP;\n" + "options {output=AST;}\n" + "a : ^(. INT) \n" + " ;\n"; Grammar g = new Grammar( treeGrammar ); AntlrTool antlr = newTool(); antlr.SetOutputDirectory( null ); // write to /dev/null CodeGenerator generator = new CodeGenerator( antlr, g, "Java" ); g.CodeGenerator = generator; generator.GenRecognizer(); assertEquals( "unexpected errors: " + equeue, 1, equeue.errors.Count ); int expectedMsgID = ErrorManager.MSG_WILDCARD_AS_ROOT; object expectedArg = null; RecognitionException expectedExc = null; GrammarSyntaxMessage expectedMessage = new GrammarSyntaxMessage( expectedMsgID, g, null, expectedArg, expectedExc ); checkError( equeue, expectedMessage ); }