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 net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest;
11 public class DualParseSyntaxErrorTest extends AbstractCompilerTest {
12 public static boolean optimizeStringLiterals = false;
14 public DualParseSyntaxErrorTest(String testName) {
18 public void test01() {
19 String s = "$login =1; " + "final class test {\n" + "\n"
20 + "private function f1() {\n" + "\n" + "}\n"
21 + "public function f2() {\n" + "\n" + " \n" + "} \n" + "}";
23 String expectedSyntaxErrorDiagnosis = "";
25 String testName = "<test01>";
26 checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis);
30 public void test02() {
31 String s = "class test { \n" + " function f0() \n"
35 String expectedSyntaxErrorDiagnosis = "";
37 String testName = "<test02>";
38 checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis);
42 public void test03() {
43 String s = "$chars = ( isset($HTTP_GET_VARS['chars']) ) ? intval($HTTP_GET_VARS['chars']) : 200;";
44 String expectedSyntaxErrorDiagnosis = "";
46 checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis);
50 public void test96() {
51 String s = "$str = <<<EOD\n" + "Example of string\n"
52 + "spanning multiple lines\n" + "using heredoc syntax.\n"
54 + "/* More complex example, with variables. */\n"
55 + "class foo\n" + "{\n" + " var $foo;\n" + " var $bar;\n"
56 + "\n" + " function foo()\n" + " {\n"
57 + " $this->foo = 'Foo';\n"
58 + " $this->bar = array('Bar1', 'Bar2', 'Bar3');\n"
59 + " }\n" + "}\n" + "\n" + "$foo = new foo();\n"
60 + "$name = 'MyName';\n" + "\n" + "echo <<<EOT\n"
61 + "My name is \"$name\". I am printing some $foo->foo.\n"
62 + "Now, I am printing some {$foo->bar[1]}.\n"
63 + "This should print a capital 'A': \\x41\n" + "EOT;\n";
64 String expectedSyntaxErrorDiagnosis = "";
66 checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis);
70 public void test97() {
71 String s = "class momo { \n"
72 + " function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n"
76 String expectedSyntaxErrorDiagnosis = "";
78 checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis);
82 public void test98() {
83 String s = "return(array());"
84 + "if(!$result = mysql_query($sql)) return(array());\n";
86 String expectedSyntaxErrorDiagnosis = "";
88 checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis);
92 public void test99() {
93 String s = "class test { \n"
95 + " function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n"
99 String expectedSyntaxErrorDiagnosis = "----------\n"
100 + "1. ERROR in (at line 1)\n"
103 + "Parser error \"\'public\' \'private\' or \'protected\' modifier expected for field declarations.\"\n"
105 // + "2. ERROR in (at line 1)\n"
108 // + "Parser error \"Too many closing \'}\'; end-of-file not
113 checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis);