Add a test case for merging clashing channel names during import.

This commit is contained in:
Nicolas 2017-12-04 17:35:08 +13:00
parent 490cd7068c
commit d2685bf37f
1 changed files with 22 additions and 0 deletions

View File

@ -142,6 +142,28 @@ public class TestCompositeGrammars extends BaseJavaToolTest {
assertEquals(0, equeue.errors.size()); assertEquals(0, equeue.errors.size());
} }
@Test public void testImportClashingChannelsIntoLexerGrammar() throws Exception {
BaseRuntimeTest.mkdir(tmpdir);
String master =
"lexer grammar M;\n" +
"import S;\n" +
"channels {CH_A, CH_B, CH_C}\n" +
"A : 'a' -> channel(CH_A);\n" +
"B : 'b' -> channel(CH_B);\n" +
"C : 'C' -> channel(CH_C);\n";
writeFile(tmpdir, "M.g4", master);
String slave =
"lexer grammar S;\n" +
"channels {CH_C}\n" +
"C : 'c' -> channel(CH_C);\n";
writeFile(tmpdir, "S.g4", slave);
ErrorQueue equeue = BaseRuntimeTest.antlrOnString(tmpdir, "Java", "M.g4", false, "-lib", tmpdir);
assertEquals(0, equeue.errors.size());
}
@Test public void testMergeModesIntoLexerGrammar() throws Exception { @Test public void testMergeModesIntoLexerGrammar() throws Exception {
BaseRuntimeTest.mkdir(tmpdir); BaseRuntimeTest.mkdir(tmpdir);