2  * Created on 29.02.2004
 
   4  * To change the template for this generated file go to
 
   5  * Window - Preferences - Java - Code Generation - Code and Comments
 
   7 package net.sourceforge.phpeclipse.phpeditor.php.test;
 
   9 import java.io.PrintWriter;
 
  10 import java.io.StringWriter;
 
  11 import java.util.Locale;
 
  13 import net.sourceforge.phpdt.core.compiler.IProblem;
 
  14 import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest;
 
  15 import net.sourceforge.phpdt.core.tests.util.Util;
 
  16 import net.sourceforge.phpdt.internal.compiler.CompilationResult;
 
  17 import net.sourceforge.phpdt.internal.compiler.DefaultErrorHandlingPolicies;
 
  18 import net.sourceforge.phpdt.internal.compiler.batch.CompilationUnit;
 
  19 import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
 
  20 import net.sourceforge.phpdt.internal.compiler.parser.UnitParser;
 
  21 import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblem;
 
  22 import net.sourceforge.phpdt.internal.compiler.problem.DefaultProblemFactory;
 
  23 import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
 
  24 import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
 
  29  * To change the template for this generated type comment go to
 
  30  * Window - Preferences - Java - Code Generation - Code and Comments
 
  32 public class DualParseSyntaxErrorTest extends AbstractCompilerTest {
 
  33                 public static boolean optimizeStringLiterals = false;
 
  35         public DualParseSyntaxErrorTest(String testName){
 
  39         public void test01() {
 
  42                         "final class test {\n" + 
 
  44                         "private function f1() {\n" + 
 
  47                         "public function f2() {\n" + 
 
  53                 String expectedSyntaxErrorDiagnosis =
 
  56                 String testName = "<test01>";
 
  59                         expectedSyntaxErrorDiagnosis);
 
  62         public void test02() {
 
  70                 String expectedSyntaxErrorDiagnosis =
 
  73                 String testName = "<test02>";
 
  76                         expectedSyntaxErrorDiagnosis);
 
  79         public void test03() {
 
  81         "$chars = ( isset($HTTP_GET_VARS['chars']) ) ? intval($HTTP_GET_VARS['chars']) : 200;";
 
  82         String expectedSyntaxErrorDiagnosis =
 
  87                 expectedSyntaxErrorDiagnosis);
 
  90         public void test96() {
 
  91                 String s = "$str = <<<EOD\n" + "Example of string\n"
 
  92         + "spanning multiple lines\n" + "using heredoc syntax.\n" + "EOD;\n"
 
  93         + "\n" + "/* More complex example, with variables. */\n"
 
  94         + "class foo\n" + "{\n" + "    var $foo;\n" + "    var $bar;\n" + "\n"
 
  95         + "    function foo()\n" + "    {\n" + "        $this->foo = 'Foo';\n"
 
  96         + "        $this->bar = array('Bar1', 'Bar2', 'Bar3');\n" + "    }\n"
 
  97         + "}\n" + "\n" + "$foo = new foo();\n" + "$name = 'MyName';\n" + "\n"
 
  99         + "My name is \"$name\". I am printing some $foo->foo.\n"
 
 100         + "Now, I am printing some {$foo->bar[1]}.\n"
 
 101         + "This should print a capital 'A': \\x41\n" + "EOT;\n";
 
 102                 String expectedSyntaxErrorDiagnosis =
 
 107                         expectedSyntaxErrorDiagnosis);
 
 110         public void test97() {
 
 113                         "       function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n"+
 
 118                 String expectedSyntaxErrorDiagnosis =
 
 123                         expectedSyntaxErrorDiagnosis);
 
 126         public void test98() {
 
 129                         "if(!$result = mysql_query($sql)) return(array());\n";  
 
 131                 String expectedSyntaxErrorDiagnosis =
 
 136                         expectedSyntaxErrorDiagnosis);
 
 140         public void test99() {
 
 144                         "       function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n"+
 
 149                 String expectedSyntaxErrorDiagnosis =
 
 151                         "1. ERROR in  (at line 1)\n" + 
 
 154                         "Parser error \"\'public\' \'private\' or \'protected\' modifier expected for field declarations.\"\n" + 
 
 156                         "2. ERROR in  (at line 1)\n" + 
 
 159                         "Parser error \"Too many closing \'}\'; end-of-file not reached.\"\n" + 
 
 164                         expectedSyntaxErrorDiagnosis);