fix test so no error due to EOF.

This commit is contained in:
Terence Parr 2012-07-21 15:36:56 -07:00
parent 8c03dbacf8
commit 7a4a269615
1 changed files with 4 additions and 2 deletions

View File

@ -201,6 +201,7 @@ public class TestParserExec extends BaseTest {
public void testIfIfElse() throws Exception {
String grammar =
"grammar T;\n" +
"s : stmt EOF ;\n" +
"stmt : ifStmt | ID;\n" +
"ifStmt : 'if' ID stmt ('else' stmt | {_input.LA(1) != ELSE}?);\n" +
"ELSE : 'else';\n" +
@ -208,11 +209,12 @@ public class TestParserExec extends BaseTest {
"WS : (' ' | '\\t')+ -> skip;\n"
;
String found = execParser("T.g4", grammar, "TParser", "TLexer", "stmt",
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s",
"if x if x a else b", true);
String expecting = "";
assertEquals(expecting, found);
assertNull(this.stderrDuringParse);
assertEquals("line 1:12 reportAttemptingFullContext d=1, input='else'\n",
this.stderrDuringParse);
}
}