From d2685bf37ffdfa23bcacaf494af25473e8a0f4a9 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 4 Dec 2017 17:35:08 +1300 Subject: [PATCH] Add a test case for merging clashing channel names during import. --- .../v4/test/tool/TestCompositeGrammars.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tool-testsuite/test/org/antlr/v4/test/tool/TestCompositeGrammars.java b/tool-testsuite/test/org/antlr/v4/test/tool/TestCompositeGrammars.java index 460d1539d..03368785b 100644 --- a/tool-testsuite/test/org/antlr/v4/test/tool/TestCompositeGrammars.java +++ b/tool-testsuite/test/org/antlr/v4/test/tool/TestCompositeGrammars.java @@ -141,6 +141,28 @@ public class TestCompositeGrammars extends BaseJavaToolTest { ErrorQueue equeue = BaseRuntimeTest.antlrOnString(tmpdir, "Java", "M.g4", false, "-lib", tmpdir); 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 { BaseRuntimeTest.mkdir(tmpdir);