forked from jasder/antlr
Add regression test for antlr/antlr4#19 (getter for context is not a list when it should be)
This commit is contained in:
parent
514a1500ea
commit
bfc395d23b
|
@ -271,6 +271,31 @@ public class TestParseErrors extends BaseTest {
|
|||
assertEquals("line 1:0 missing ID at '<EOF>'\n", this.stderrDuringParse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test for "Getter for context is not a list when it should be".
|
||||
* https://github.com/antlr/antlr4/issues/19
|
||||
*/
|
||||
@Test
|
||||
public void testContextListGetters() throws Exception {
|
||||
String grammar =
|
||||
"grammar T;\n" +
|
||||
"@parser::members{\n" +
|
||||
" void foo() {\n" +
|
||||
" SContext s = null;\n" +
|
||||
" List<? extends AContext> a = s.a();\n" +
|
||||
" List<? extends BContext> b = s.b();\n" +
|
||||
" }\n" +
|
||||
"}\n" +
|
||||
"s : (a | b)+;\n" +
|
||||
"a : 'a' {System.out.print('a');};\n" +
|
||||
"b : 'b' {System.out.print('b');};\n" +
|
||||
"";
|
||||
String result = execParser("T.g", grammar, "TParser", "TLexer", "s", "abab", true);
|
||||
String expecting = "abab\n";
|
||||
assertEquals(expecting, result);
|
||||
assertNull(this.stderrDuringParse);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a regression test for #45 "NullPointerException in ATNConfig.hashCode".
|
||||
* https://github.com/antlr/antlr4/issues/45
|
||||
|
|
Loading…
Reference in New Issue