misc parser changes
[phpeclipse.git] / net.sourceforge.phpeclipse.tests / src / net / sourceforge / phpeclipse / phpeditor / php / test / DualParseSyntaxErrorTest.java
index 949a9ad..09830f3 100644 (file)
@@ -22,7 +22,6 @@ import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblem;
 import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory;
 import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
 import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
-import net.sourceforge.phpeclipse.internal.compiler.ast.TypeDeclaration;
 
 /**
  * @author khartlage
@@ -38,8 +37,8 @@ public class DualParseSyntaxErrorTest extends AbstractCompilerTest {
        }
        public void checkParse(
                char[] source, 
-               String expectedSyntaxErrorDiagnosis,
-               String testName) {
+               String expectedSyntaxErrorDiagnosis) {
+//             String testName) {
 
                UnitParser parser = 
                        new UnitParser(
@@ -48,7 +47,7 @@ public class DualParseSyntaxErrorTest extends AbstractCompilerTest {
                                        //new CompilerOptions(getCompilerOptions()), 
                                        new DefaultProblemFactory(Locale.getDefault())));
 
-               ICompilationUnit sourceUnit = new CompilationUnit(source, testName, null);
+               ICompilationUnit sourceUnit = new CompilationUnit(source, "", null);
                CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);       
                
                CompilationUnitDeclaration computedUnit = parser.dietParse(sourceUnit, compilationResult, true);
@@ -90,54 +89,80 @@ public class DualParseSyntaxErrorTest extends AbstractCompilerTest {
                        System.out.println(Util.displayString(computedSyntaxErrorDiagnosis));
                }
                assertEquals(
-                       "Invalid syntax error diagnosis" + testName,
+                       "Invalid syntax error diagnosis",
                        expectedSyntaxErrorDiagnosis,
                        computedSyntaxErrorDiagnosis);
        }
-       
        public void test01() {
                String s = 
-                       "class class {                                                      \n"+
-                       "       function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n"+
+                       "final class test {\n" + 
+                       "\n" + 
+                       "private function f1() {\n" + 
+                       "\n" + 
+                       "}\n" + 
+                       "public function f2() {\n" + 
+                       "\n" +
+                       "  \n" + 
+                       "}  \n" + 
+                       "}";    
+
+               String expectedSyntaxErrorDiagnosis =
+                       "";
+
+               String testName = "<test01>";
+               checkParse(
+                       s.toCharArray(),
+                       expectedSyntaxErrorDiagnosis);
+//                     testName);
+       }
+       public void test02() {
+               String s = 
+                       "class test {                                                       \n"+
+                       "       function f0() \n"+
                        "       {                                                               \n"+
                        "       }                                                                               \n"+
                        "}                                                                                      \n";    
 
                String expectedSyntaxErrorDiagnosis =
-                       "----------\n" + 
-                       "1. ERROR in <test1> (at line 1)\n" + 
-                       "       class class {                                                       \n" + 
-                       "             ^^^^^\n" + 
-                       "Parse error \"Don\'t use keyword for class declaration [class].\"\n" + 
-                       "----------\n" + 
-                       "2. ERROR in <test1> (at line 1)\n" + 
-                       "       class class {                                                       \n" + 
-                       "                   ^\n" + 
-                       "Parse error \"Class name expected after keyword \'class\'.\"\n" + 
-                       "----------\n";
-
-               String testName = "<test1>";
+                       "";
+
+               String testName = "<test02>";
                checkParse(
                        s.toCharArray(),
-                       expectedSyntaxErrorDiagnosis,
-                       testName);
+                       expectedSyntaxErrorDiagnosis);
+//                     testName);
        }
        
-       public void test02() {
+       public void test97() {
+               String s = 
+                       "class momo {                                                       \n"+
+                       "       function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n"+
+                       "       {                                                               \n"+
+                       "       }                                                                               \n"+
+                       "}                                                                                      \n";    
+
+               String expectedSyntaxErrorDiagnosis =
+                       "";
+
+               checkParse(
+                       s.toCharArray(),
+                       expectedSyntaxErrorDiagnosis);
+//                     testName);
+       }
+       public void test98() {
                String s = 
                        "if(!$result = mysql_query($sql)) return(array());\n";  
 
                String expectedSyntaxErrorDiagnosis =
                        "";
 
-               String testName = "<test2>";
                checkParse(
                        s.toCharArray(),
-                       expectedSyntaxErrorDiagnosis,
-                       testName);
+                       expectedSyntaxErrorDiagnosis);
+//                     testName);
        }
        
-       public void test03() {
+       public void test99() {
                String s = 
                        "class test {                                                       \n"+
                        "   murks;                                        \n"+
@@ -149,10 +174,9 @@ public class DualParseSyntaxErrorTest extends AbstractCompilerTest {
                String expectedSyntaxErrorDiagnosis =
                        "";
 
-               String testName = "<test3>";
                checkParse(
                        s.toCharArray(),
-                       expectedSyntaxErrorDiagnosis,
-                       testName);
+                       expectedSyntaxErrorDiagnosis);
+//                     testName);
        }
 }