Skip to content

Commit

Permalink
Renamed class and fixed the two tests that were having failures.
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Sep 21, 2016
1 parent 7e2af79 commit 17126e7
Showing 1 changed file with 91 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,157 +26,161 @@
/**
* Tests error recovery from the parser. All tests in this class are failing, so
* do not add to build. When a test starts passing, remove from this class.
*
*
* @author Andrew Eisenberg
* @created May 17, 2011
*/
public class FailingErrorRecoveryTests extends AbstractGroovyRegressionTest {
public FailingErrorRecoveryTests(String name) {
super(name);
}
public class ErrorRecoveryTests extends AbstractGroovyRegressionTest {

public static Test suite() {
return buildUniqueComplianceTestSuite(testClass(),ClassFileConstants.JDK1_5);
return buildUniqueComplianceTestSuite(testClass(), ClassFileConstants.JDK1_5);
}

public static Class testClass() {
return ErrorRecoveryTests.class;
}

public ErrorRecoveryTests(String name) {
super(name);
}

protected void setUp() throws Exception {
super.setUp();
complianceLevel = ClassFileConstants.JDK1_5;
}

public static Class testClass() {
return FailingErrorRecoveryTests.class;
private ModuleNode getModuleNode(String filename) {
GroovyCompilationUnitDeclaration decl = (GroovyCompilationUnitDeclaration) ((DebugRequestor) GroovyParser.debugRequestor).declarations.get(filename);
if (decl != null) {
return decl.getModuleNode();
} else {
return null;
}
}


//

public void testParsingIncompleteIfCondition_1046() throws Exception {
this.runNegativeTest(new String[]{
"A.groovy",
"A.groovy",
"File f = new File('c:\\test')\n" +
"if (f.isD"
"if (f.isD"
},
"----------\n" +
"1. ERROR in A.groovy (at line 2)\n" +
"\tif (f.isD\n" +
"\t ^\n" +
"Groovy:expecting ')', found '' @ line 2, column 9.\n" +
"----------\n");
//"----------\n" +
//"1. ERROR in A.groovy (at line 2)\n" +
//"\tif (f.isD\n" +
//"\t ^\n" +
//"Groovy:expecting ')', found '' @ line 2, column 9.\n" +
//"----------\n" +
"");
ModuleNode mn = getModuleNode("A.groovy");
assertNotNull(mn);
assertFalse(mn.encounteredUnrecoverableError());
ClassNode cn = (ClassNode)mn.getClasses().get(0);
ClassNode cn = (ClassNode) mn.getClasses().get(0);
assertNotNull(cn);
assertTrue(cn.getName().equals("A"));
}

public void testParsingDotTerminatingIncompleteIfCondition_1046() throws Exception {
this.runNegativeTest(new String[]{
"A.groovy",
"A.groovy",
"File f = new File('c:\\test')\n" +
"if (f."
"if (f."
},
"----------\n" +
"1. ERROR in A.groovy (at line 2)\n" +
"\tif (f.\n" +
"\t ^\n" +
"Groovy:expecting ')', found '' @ line 2, column 6.\n" +
"----------\n" +
"2. ERROR in A.groovy (at line 2)\n" +
"\tif (f.\n" +
"\t ^\n" +
"Groovy:Expecting an identifier, found a trailing '.' instead. @ line 2, column 6.\n" +
"----------\n" +
"1. ERROR in A.groovy (at line 2)\n" +
"\tif (f.\n" +
"\t ^\n" +
"Groovy:Expecting an identifier, found a trailing '.' instead. @ line 2, column 6.\n" +
//"----------\n" +
//"2. ERROR in A.groovy (at line 2)\n" +
//"\tif (f.\n" +
//"\t ^\n" +
//"Groovy:expecting ')', found '' @ line 2, column 6.\n" +
"----------\n");
ModuleNode mn = getModuleNode("A.groovy");
assertNotNull(mn);
assertFalse(mn.encounteredUnrecoverableError());
ClassNode cn = (ClassNode)mn.getClasses().get(0);
ClassNode cn = (ClassNode) mn.getClasses().get(0);
assertNotNull(cn);
assertTrue(cn.getName().equals("A"));
}

public void testGRE941() throws Exception {
this.runNegativeTest(new String[]{
"A.groovy",
"class Foo {\n" +
" def myMethod() {\n" +
" def x = \"\"\n" +
"A.groovy",
"class Foo {\n" +
" def myMethod() {\n" +
" def x = \"\"\n" +
" println x.;\n" + // if a ';' is inserted in this situation, you can get back what you want...
" println x\n" +
" }\n" +
"}"
" println x\n" +
" }\n" +
"}"
},
"----------\n" +
"1. ERROR in A.groovy (at line 4)\n" +
" println x.;\n" +
" ^\n" +
"Groovy:unexpected token: ; @ line 4, column 15.\n" +
"----------\n");
"----------\n" +
"1. ERROR in A.groovy (at line 4)\n" +
"\tprintln x.;\n" +
"\t ^\n" +
"Groovy:unexpected token: ; @ line 4, column 15.\n" +
"----------\n");
ModuleNode mn = getModuleNode("A.groovy");
assertNotNull(mn);
assertFalse(mn.encounteredUnrecoverableError());
ClassNode cn = (ClassNode)mn.getClasses().get(0);
ClassNode cn = (ClassNode) mn.getClasses().get(0);
assertNotNull(cn);
assertEquals("Foo",cn.getName());
}

public void testGRE644() throws Exception {
this.runNegativeTest(new String[]{
"Other.groovy",
"class Test {\n" +
" static String CONST = \"hello\";\n" +
" static double addOne(double a) { return a + 1.0; }\n" +
"Other.groovy",
"class Test {\n" +
" static String CONST = \"hello\";\n" +
" static double addOne(double a) { return a + 1.0; }\n" +
"}",
"A.groovy",
"Test."
},
"----------\n" +
"1. ERROR in A.groovy (at line 1)\n" +
"\tTest.\n" +
"\t ^\n" +
"Groovy:Expecting an identifier, found a trailing '.' instead. @ line 1, column 5.\n" +
"----------\n" +
"1. ERROR in A.groovy (at line 1)\n" +
"\tTest.\n" +
"\t ^\n" +
"Groovy:Expecting an identifier, found a trailing '.' instead. @ line 1, column 5.\n" +
"----------\n");
ModuleNode mn = getModuleNode("A.groovy");
assertNotNull(mn);
assertFalse(mn.encounteredUnrecoverableError());
ClassNode cn = (ClassNode)mn.getClasses().get(0);
ClassNode cn = (ClassNode) mn.getClasses().get(0);
assertNotNull(cn);
assertTrue(cn.getName().equals("A"));
}

public void testGRE1048() throws Exception {
this.runNegativeTest(new String[]{
"A.groovy",
"class TextCompletionTest { \n" +
" String getBla(){\n" +
" return \"bla\"\n" +
" }\n" +
" \n" +
" static void foo(){\n" +
" TextCompletionTest variable = new TextCompletionTest()\n" +
" println variable.bla //works\n" +
" println(variable.)\n" +
" }\n" +
"A.groovy",
"class TextCompletionTest { \n" +
" String getBla(){\n" +
" return \"bla\"\n" +
" }\n" +
" \n" +
" static void foo(){\n" +
" TextCompletionTest variable = new TextCompletionTest()\n" +
" println variable.bla //works\n" +
" println(variable.)\n" +
" }\n" +
"}",
},
"----------\n" +
"1. ERROR in A.groovy (at line 9)\n" +
" println(variable.)\n" +
" ^\n" +
"Groovy:unexpected token: ) @ line 9, column 26.\n" +
"----------\n");
"----------\n" +
"1. ERROR in A.groovy (at line 9)\n" +
"\tprintln(variable.)\n" +
"\t ^\n" +
"Groovy:unexpected token: ) @ line 9, column 26.\n" +
"----------\n");
ModuleNode mn = getModuleNode("A.groovy");
assertNotNull(mn);
assertFalse(mn.encounteredUnrecoverableError());
ClassNode cn = (ClassNode)mn.getClasses().get(0);
ClassNode cn = (ClassNode) mn.getClasses().get(0);
assertNotNull(cn);
assertTrue(cn.getName().equals("TextCompletionTest"));
}

private ModuleNode getModuleNode(String filename) {
GroovyCompilationUnitDeclaration decl = (GroovyCompilationUnitDeclaration)((DebugRequestor)GroovyParser.debugRequestor).declarations.get(filename);
if (decl!=null) {
return decl.getModuleNode();
} else {
return null;
}
}
}

0 comments on commit 17126e7

Please sign in to comment.