From 313767239011a7e044da864629380233cef58092 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 25 Sep 2014 21:47:25 -0500 Subject: [PATCH] Add regression test for #670 --- .../antlr/v4/test/TestCompositeGrammars.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tool/test/org/antlr/v4/test/TestCompositeGrammars.java b/tool/test/org/antlr/v4/test/TestCompositeGrammars.java index b11d9e903..a6eebbc4b 100644 --- a/tool/test/org/antlr/v4/test/TestCompositeGrammars.java +++ b/tool/test/org/antlr/v4/test/TestCompositeGrammars.java @@ -797,4 +797,24 @@ public class TestCompositeGrammars extends BaseTest { assertEquals("", found); assertNull(stderrDuringParse); } + + /** + * This is a regression test for antlr/antlr4#670 "exception when importing + * grammar". + * https://github.com/antlr/antlr4/issues/670 + */ + @Test + public void testImportLargeGrammar() throws Exception { + String slave = load("Java.g4", "UTF-8"); + String master = + "grammar NewJava;\n" + + "import Java;\n"; + + System.out.println("dir "+tmpdir); + mkdir(tmpdir); + writeFile(tmpdir, "Java.g4", slave); + String found = execParser("NewJava.g4", master, "NewJavaParser", "NewJavaLexer", "compilationUnit", "package Foo;", debug); + assertEquals("", found); + assertNull(stderrDuringParse); + } }