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
}
public void checkParse(
char[] source,
- String expectedSyntaxErrorDiagnosis,
- String testName) {
+ String expectedSyntaxErrorDiagnosis) {
+// String testName) {
UnitParser parser =
new UnitParser(
//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);
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"+
String expectedSyntaxErrorDiagnosis =
"";
- String testName = "<test3>";
checkParse(
s.toCharArray(),
- expectedSyntaxErrorDiagnosis,
- testName);
+ expectedSyntaxErrorDiagnosis);
+// testName);
}
}