Fix bug #1385272: Parsing of short open tags not fully compatible to PHP parse
[phpeclipse.git] / net.sourceforge.phpeclipse.tests / src / net / sourceforge / phpdt / core / tests / util / AbstractCompilerTest.java
index b563138..8659637 100644 (file)
@@ -1,10 +1,10 @@
 /*******************************************************************************
  * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
+ * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/cpl-v10.html
- * 
+ *
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
@@ -24,46 +24,39 @@ import junit.framework.TestSuite;
 import net.sourceforge.phpdt.core.compiler.IProblem;
 import net.sourceforge.phpdt.internal.compiler.CompilationResult;
 import net.sourceforge.phpdt.internal.compiler.DefaultErrorHandlingPolicies;
+import net.sourceforge.phpdt.internal.compiler.ast.CompilationUnitDeclaration;
 import net.sourceforge.phpdt.internal.compiler.batch.CompilationUnit;
 import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
 import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
+import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
 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;
 
 //import net.sourceforge.phpdt.core.tests.junit.extension.TestCase;
 //import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
 
 public class AbstractCompilerTest extends TestCase {
 
-//     public static final String COMPLIANCE_1_3 = "1.3";
-//     public static final String COMPLIANCE_1_4 = "1.4";
-//     public static final String COMPLIANCE_1_5 = "1.5";
-//
-//     public static final int F_1_3 = 0x1;
-//     public static final int F_1_4 = 0x2;
-//     public static final int F_1_5 = 0x4;
-
        private static int possibleComplianceLevels = -1;
 
        protected String complianceLevel;
        public void checkParsePHP(
-               char[] source, 
+               char[] source,
                String expectedSyntaxErrorDiagnosis) {
 //             String testName) {
 
-               UnitParser parser = 
+               UnitParser parser =
                        new UnitParser(
                                new ProblemReporter(
-                                       DefaultErrorHandlingPolicies.proceedWithAllProblems(), 
-                                       new CompilerOptions(getCompilerOptions()), 
+                                       DefaultErrorHandlingPolicies.proceedWithAllProblems(),
+                                       new CompilerOptions(getCompilerOptions()),
                                        new DefaultProblemFactory(Locale.getDefault())));
 
                ICompilationUnit sourceUnit = new CompilationUnit(source, "", null);
-               CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);       
-               
+               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;){
@@ -77,7 +70,7 @@ public class AbstractCompilerTest extends TestCase {
                        int count = problems.length;
                        int problemCount = 0;
                        char[] unitSource = compilationResult.compilationUnit.getContents();
-                       for (int i = 0; i < count; i++) { 
+                       for (int i = 0; i < count; i++) {
                                if (problems[i] != null) {
                                        if (problemCount == 0)
                                                buffer.append("----------\n");
@@ -108,20 +101,20 @@ public class AbstractCompilerTest extends TestCase {
                        computedSyntaxErrorDiagnosis);
        }
        public void checkParseHTML(
-               char[] source, 
+               char[] source,
                String expectedSyntaxErrorDiagnosis) {
 //             String testName) {
 
-               UnitParser parser = 
+               UnitParser parser =
                        new UnitParser(
                                new ProblemReporter(
-                                       DefaultErrorHandlingPolicies.proceedWithAllProblems(), 
-                                       new CompilerOptions(getCompilerOptions()), 
+                                       DefaultErrorHandlingPolicies.proceedWithAllProblems(),
+                                       new CompilerOptions(getCompilerOptions()),
                                        new DefaultProblemFactory(Locale.getDefault())));
 
                ICompilationUnit sourceUnit = new CompilationUnit(source, "", null);
-               CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);       
-               
+               CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0);
+
                CompilationUnitDeclaration computedUnit = parser.dietParse(sourceUnit, compilationResult, false);
 //             if (computedUnit.types != null) {
 //                     for (int i = computedUnit.types.size(); --i >= 0;){
@@ -135,7 +128,7 @@ public class AbstractCompilerTest extends TestCase {
                        int count = problems.length;
                        int problemCount = 0;
                        char[] unitSource = compilationResult.compilationUnit.getContents();
-                       for (int i = 0; i < count; i++) { 
+                       for (int i = 0; i < count; i++) {
                                if (problems[i] != null) {
                                        if (problemCount == 0)
                                                buffer.append("----------\n");
@@ -201,26 +194,7 @@ public class AbstractCompilerTest extends TestCase {
 //     }
 
        /*
-        * Returns a test suite including the tests defined by the given classes for all possible complianceLevels
-        * and using the given setup class (CompilerTestSetup or a subclass)
-        */
-//     public static Test suite(String suiteName, Class setupClass, ArrayList testClasses) {
-//             TestSuite all = new TestSuite(suiteName);
-//             int complianceLevels = AbstractCompilerTest.getPossibleComplianceLevels();
-//             if ((complianceLevels & AbstractCompilerTest.F_1_3) != 0) {
-//                     all.addTest(suiteForComplianceLevel(COMPLIANCE_1_3, setupClass, testClasses));
-//             }
-//             if ((complianceLevels & AbstractCompilerTest.F_1_4) != 0) {
-//                     all.addTest(suiteForComplianceLevel(COMPLIANCE_1_4, setupClass, testClasses));
-//             }
-//             if ((complianceLevels & AbstractCompilerTest.F_1_5) != 0) {
-//                     all.addTest(suiteForComplianceLevel(COMPLIANCE_1_5, setupClass, testClasses));
-//             }
-//             return all;
-//     }
-
-       /*
-        * Returns a test suite including the tests defined by the given classes for the given complianceLevel 
+        * Returns a test suite including the tests defined by the given classes for the given complianceLevel
         * (see AbstractCompilerTest for valid values) and using the given setup class (CompilerTestSetup or a subclass)
         */
        public static Test suiteForComplianceLevel(String complianceLevel, Class setupClass, ArrayList testClasses) {
@@ -266,7 +240,7 @@ public class AbstractCompilerTest extends TestCase {
                options.put(CompilerOptions.OPTION_PHPBadStyleUppercaseIdentifierWarning, CompilerOptions.IGNORE);
                options.put(CompilerOptions.OPTION_PHPIncludeNotExistWarning, CompilerOptions.IGNORE);
                options.put(CompilerOptions.OPTION_UninitializedLocalVariableWarning, CompilerOptions.IGNORE);
-                   
+               options.put(CompilerOptions.OPTION_CodeCannotBeReachedWarning, CompilerOptions.IGNORE);
                return options;
        }
 
@@ -277,6 +251,29 @@ public class AbstractCompilerTest extends TestCase {
                }
                return name;
        }
+       protected void checkHTML(String strEval) {
+           if (Scanner.DEBUG) {
+             System.out.println("\n------------------------------------");
+             System.out.println(strEval);
+           }
+           checkParseHTML(
+               strEval.toCharArray(),
+                       "");
+       //    parser.phpParserTester(strEval, 1);
+         }
+       //  private void checkHTML(String strEval) {
+       //    if (Scanner.DEBUG) {
+       //      System.out.println("\n------------------------------------");
+       //      System.out.println(strEval);
+       //    }
+       //    parser.parse(strEval);
+       //  }
+       //  /**
+       //   * The JUnit setup method
+       //   */
+       //  protected void setUp() {
+       //    parser = new Parser(null);
+       //  }
 
 //     public void initialize(CompilerTestSetup setUp) {
 //             this.complianceLevel = setUp.complianceLevel;