test added

This commit is contained in:
ericvergnaud 2015-05-31 17:18:56 +08:00
parent fb0e1c0cdb
commit a63df8b088
1 changed files with 17 additions and 0 deletions

View File

@ -14,6 +14,23 @@ public class TestParserErrors extends BaseTest {
assertEquals("line 1:1 mismatched input 'a' expecting 'b'\n", this.stderrDuringParse); assertEquals("line 1:1 mismatched input 'a' expecting 'b'\n", this.stderrDuringParse);
} }
/* this file and method are generated, any edit will be overwritten by the next generation */
@Test
public void testTokenMismatch2() throws Exception {
String grammar = "grammar T;\n" +
"\n" +
"stat: ( '(' expr? ')' )? EOF ;\n" +
"expr: ID '=' STR ;\n" +
"\n" +
"ERR : '~FORCE_ERROR~' ;\n" +
"ID : [a-zA-Z]+ ;\n" +
"STR : '\"' ~[\"]* '\"' ;\n" +
"WS : [ \\t\\r\\n]+ -> skip ;";
String found = execParser("T.g4", grammar, "TParser", "TLexer", "stat", "( ~FORCE_ERROR~ ", false);
assertEquals("", found);
assertEquals("line 1:2 mismatched input '~FORCE_ERROR~' expecting ')'\n", this.stderrDuringParse);
}
/* this file and method are generated, any edit will be overwritten by the next generation */ /* this file and method are generated, any edit will be overwritten by the next generation */
@Test @Test
public void testSingleTokenDeletion() throws Exception { public void testSingleTokenDeletion() throws Exception {