From 89d80cc8ed64ec07986789677a7f3b8654b3ab20 Mon Sep 17 00:00:00 2001 From: ericvergnaud Date: Sat, 4 Oct 2014 11:42:29 +0800 Subject: [PATCH 1/2] improve test granularity --- .../org/antlr/v4/test/TestParseErrors.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tool/test/org/antlr/v4/test/TestParseErrors.java b/tool/test/org/antlr/v4/test/TestParseErrors.java index fd9f1c8b2..f24058272 100644 --- a/tool/test/org/antlr/v4/test/TestParseErrors.java +++ b/tool/test/org/antlr/v4/test/TestParseErrors.java @@ -304,8 +304,7 @@ public class TestParseErrors extends BaseTest { * This is a regression test for #26 "an exception upon simple rule with double recursion in an alternative". * https://github.com/antlr/antlr4/issues/26 */ - @Test - public void testDuplicatedLeftRecursiveCall() throws Exception { + void testDuplicatedLeftRecursiveCall(String input) throws Exception { String grammar = "grammar T;\n" + "start : expr EOF;\n" + @@ -313,22 +312,25 @@ public class TestParseErrors extends BaseTest { " | expr expr\n" + " ;\n" + "\n"; - - String result = execParser("T.g4", grammar, "TParser", "TLexer", "start", "x", true); + String result = execParser("T.g4", grammar, "TParser", "TLexer", "start", input, true); assertEquals("", result); assertNull(this.stderrDuringParse); + } + - result = execParser("T.g4", grammar, "TParser", "TLexer", "start", "xx", true); - assertEquals("", result); - assertNull(this.stderrDuringParse); + @Test + public void testDuplicatedLeftRecursiveCall1() throws Exception { + testDuplicatedLeftRecursiveCall("xx"); + } + + @Test + public void testDuplicatedLeftRecursiveCall2() throws Exception { + testDuplicatedLeftRecursiveCall("xxx"); + } - result = execParser("T.g4", grammar, "TParser", "TLexer", "start", "xxx", true); - assertEquals("", result); - assertNull(this.stderrDuringParse); - - result = execParser("T.g4", grammar, "TParser", "TLexer", "start", "xxxx", true); - assertEquals("", result); - assertNull(this.stderrDuringParse); + @Test + public void testDuplicatedLeftRecursiveCall3() throws Exception { + testDuplicatedLeftRecursiveCall("xxxx"); } /** From ba5f6d891940165fea4b086b54f2ddec4cd2c599 Mon Sep 17 00:00:00 2001 From: ericvergnaud Date: Sun, 5 Oct 2014 00:36:37 +0800 Subject: [PATCH 2/2] Fixed a discarded test --- tool/test/org/antlr/v4/test/TestParseErrors.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tool/test/org/antlr/v4/test/TestParseErrors.java b/tool/test/org/antlr/v4/test/TestParseErrors.java index f24058272..46df2f970 100644 --- a/tool/test/org/antlr/v4/test/TestParseErrors.java +++ b/tool/test/org/antlr/v4/test/TestParseErrors.java @@ -320,19 +320,24 @@ public class TestParseErrors extends BaseTest { @Test public void testDuplicatedLeftRecursiveCall1() throws Exception { - testDuplicatedLeftRecursiveCall("xx"); + testDuplicatedLeftRecursiveCall("x"); } @Test public void testDuplicatedLeftRecursiveCall2() throws Exception { - testDuplicatedLeftRecursiveCall("xxx"); + testDuplicatedLeftRecursiveCall("xx"); } @Test public void testDuplicatedLeftRecursiveCall3() throws Exception { - testDuplicatedLeftRecursiveCall("xxxx"); + testDuplicatedLeftRecursiveCall("xxx"); } + @Test + public void testDuplicatedLeftRecursiveCall4() throws Exception { + testDuplicatedLeftRecursiveCall("xxxx"); + } + /** * This is a regression test for #45 "NullPointerException in ATNConfig.hashCode". * https://github.com/antlr/antlr4/issues/45