X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/DualParseSyntaxErrorTest.java b/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/DualParseSyntaxErrorTest.java deleted file mode 100644 index 088c75a..0000000 --- a/net.sourceforge.phpeclipse.tests/src/net/sourceforge/phpeclipse/phpeditor/php/test/DualParseSyntaxErrorTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Created on 29.02.2004 - * - * To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package net.sourceforge.phpeclipse.phpeditor.php.test; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Locale; - -import net.sourceforge.phpdt.core.compiler.IProblem; -import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest; -import net.sourceforge.phpdt.core.tests.util.Util; -import net.sourceforge.phpdt.internal.compiler.CompilationResult; -import net.sourceforge.phpdt.internal.compiler.DefaultErrorHandlingPolicies; -import net.sourceforge.phpdt.internal.compiler.batch.CompilationUnit; -import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit; -import net.sourceforge.phpdt.internal.compiler.parser.UnitParser; -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; - -/** - * @author khartlage - * - * To change the template for this generated type comment go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -public class DualParseSyntaxErrorTest extends AbstractCompilerTest { - public static boolean optimizeStringLiterals = false; - - public DualParseSyntaxErrorTest(String testName){ - super(testName); - } - public void checkParse( - char[] source, - String expectedSyntaxErrorDiagnosis) { -// String testName) { - - UnitParser parser = - new UnitParser( - new ProblemReporter( - DefaultErrorHandlingPolicies.proceedWithAllProblems(), - //new CompilerOptions(getCompilerOptions()), - new DefaultProblemFactory(Locale.getDefault()))); - - ICompilationUnit sourceUnit = new CompilationUnit(source, "", null); - CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0); - - CompilationUnitDeclaration computedUnit = parser.dietParse(sourceUnit, compilationResult, true); -// if (computedUnit.types != null) { -// for (int i = computedUnit.types.size(); --i >= 0;){ -// ((TypeDeclaration)computedUnit.types.get(i)).parseMethod(parser, computedUnit); -// } -// } - - StringBuffer buffer = new StringBuffer(100); - if (compilationResult.hasProblems() || compilationResult.hasTasks()) { - IProblem[] problems = compilationResult.getAllProblems(); - int count = problems.length; - int problemCount = 0; - char[] unitSource = compilationResult.compilationUnit.getContents(); - for (int i = 0; i < count; i++) { - if (problems[i] != null) { - if (problemCount == 0) - buffer.append("----------\n"); - problemCount++; - buffer.append(problemCount + (problems[i].isError() ? ". ERROR" : ". WARNING")); - buffer.append(" in " + new String(problems[i].getOriginatingFileName()).replace('/', '\\')); - try { - buffer.append(((DefaultProblem)problems[i]).errorReportSource(unitSource)); - buffer.append("\n"); - buffer.append(problems[i].getMessage()); - buffer.append("\n"); - } catch (Exception e) { - StringWriter stringWriter = new StringWriter(); - e.printStackTrace(new PrintWriter(stringWriter)); - buffer.append(stringWriter.getBuffer()); - } - buffer.append("----------\n"); - } - } - } - String computedSyntaxErrorDiagnosis = buffer.toString(); - if(!expectedSyntaxErrorDiagnosis.equals(computedSyntaxErrorDiagnosis)) { - System.out.println(Util.displayString(computedSyntaxErrorDiagnosis)); - } - assertEquals( - "Invalid syntax error diagnosis", - expectedSyntaxErrorDiagnosis, - computedSyntaxErrorDiagnosis); - } - public void test01() { - String s = - " "; - - String expectedSyntaxErrorDiagnosis = - ""; - - String testName = ""; - checkParse( - s.toCharArray(), - expectedSyntaxErrorDiagnosis); -// testName); - } - public void test02() { - String s = - "class test { \n"+ - " function f0() \n"+ - " { \n"+ - " } \n"+ - "} \n"; - - String expectedSyntaxErrorDiagnosis = - ""; - - String testName = ""; - checkParse( - s.toCharArray(), - expectedSyntaxErrorDiagnosis); -// testName); - } - - public void test97() { - String s = - "class class { \n"+ - " function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n"+ - " { \n"+ - " } \n"+ - "} \n"; - - String expectedSyntaxErrorDiagnosis = - "----------\n" + - "1. ERROR in (at line 1)\n" + - " class class { \n" + - " ^^^^^\n" + - "Parse error \"Don\'t use keyword for class declaration [class].\"\n" + - "----------\n" + - "2. ERROR in (at line 1)\n" + - " class class { \n" + - " ^\n" + - "Parse error \"Class name expected after keyword \'class\'.\"\n" + - "----------\n"; - - checkParse( - s.toCharArray(), - expectedSyntaxErrorDiagnosis); -// testName); - } - public void test98() { - String s = - "if(!$result = mysql_query($sql)) return(array());\n"; - - String expectedSyntaxErrorDiagnosis = - ""; - - checkParse( - s.toCharArray(), - expectedSyntaxErrorDiagnosis); -// testName); - } - - public void test99() { - String s = - "class test { \n"+ - " murks; \n"+ - " function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n"+ - " { \n"+ - " } \n"+ - "} \n"; - - String expectedSyntaxErrorDiagnosis = - ""; - - checkParse( - s.toCharArray(), - expectedSyntaxErrorDiagnosis); -// testName); - } -}