X-Git-Url: http://git.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 index 44df779..15b4590 100644 --- 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 @@ -9,138 +9,108 @@ package net.sourceforge.phpeclipse.phpeditor.php.test; import net.sourceforge.phpdt.core.tests.util.AbstractCompilerTest; public class DualParseSyntaxErrorTest extends AbstractCompilerTest { - public static boolean optimizeStringLiterals = false; - - public DualParseSyntaxErrorTest(String testName){ + public static boolean optimizeStringLiterals = false; + + public DualParseSyntaxErrorTest(String testName) { super(testName); } - + public void test01() { - String s = - "$login =1; " + - "final class test {\n" + - "\n" + - "private function f1() {\n" + - "\n" + - "}\n" + - "public function f2() {\n" + - "\n" + - " \n" + - "} \n" + - "}"; - - String expectedSyntaxErrorDiagnosis = - ""; + String s = "$login =1; " + "final class test {\n" + "\n" + + "private function f1() {\n" + "\n" + "}\n" + + "public function f2() {\n" + "\n" + " \n" + "} \n" + "}"; + + String expectedSyntaxErrorDiagnosis = ""; String testName = ""; - checkParsePHP( - s.toCharArray(), - expectedSyntaxErrorDiagnosis); -// testName); + checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); + // testName); } + public void test02() { - String s = - "class test { \n"+ - " function f0() \n"+ - " { \n"+ - " } \n"+ - "} \n"; + String s = "class test { \n" + " function f0() \n" + + " { \n" + " } \n" + + "} \n"; - String expectedSyntaxErrorDiagnosis = - ""; + String expectedSyntaxErrorDiagnosis = ""; String testName = ""; - checkParsePHP( - s.toCharArray(), - expectedSyntaxErrorDiagnosis); -// testName); + checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); + // testName); } + public void test03() { - String s = - "$chars = ( isset($HTTP_GET_VARS['chars']) ) ? intval($HTTP_GET_VARS['chars']) : 200;"; - String expectedSyntaxErrorDiagnosis = - ""; - - checkParsePHP( - s.toCharArray(), - expectedSyntaxErrorDiagnosis); -// testName); -} + String s = "$chars = ( isset($HTTP_GET_VARS['chars']) ) ? intval($HTTP_GET_VARS['chars']) : 200;"; + String expectedSyntaxErrorDiagnosis = ""; + + checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); + // testName); + } + public void test96() { String s = "$str = <<foo = 'Foo';\n" - + " $this->bar = array('Bar1', 'Bar2', 'Bar3');\n" + " }\n" - + "}\n" + "\n" + "$foo = new foo();\n" + "$name = 'MyName';\n" + "\n" - + "echo <<foo.\n" - + "Now, I am printing some {$foo->bar[1]}.\n" - + "This should print a capital 'A': \\x41\n" + "EOT;\n"; - String expectedSyntaxErrorDiagnosis = - ""; - - checkParsePHP( - s.toCharArray(), - expectedSyntaxErrorDiagnosis); -// testName); + + "spanning multiple lines\n" + "using heredoc syntax.\n" + + "EOD;\n" + "\n" + + "/* More complex example, with variables. */\n" + + "class foo\n" + "{\n" + " var $foo;\n" + " var $bar;\n" + + "\n" + " function foo()\n" + " {\n" + + " $this->foo = 'Foo';\n" + + " $this->bar = array('Bar1', 'Bar2', 'Bar3');\n" + + " }\n" + "}\n" + "\n" + "$foo = new foo();\n" + + "$name = 'MyName';\n" + "\n" + "echo <<foo.\n" + + "Now, I am printing some {$foo->bar[1]}.\n" + + "This should print a capital 'A': \\x41\n" + "EOT;\n"; + String expectedSyntaxErrorDiagnosis = ""; + + checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); + // testName); } + public void test97() { - String s = - "class momo { \n"+ - " function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n"+ - " { \n"+ - " } \n"+ - "} \n"; - - String expectedSyntaxErrorDiagnosis = - ""; - - checkParsePHP( - s.toCharArray(), - expectedSyntaxErrorDiagnosis); -// testName); + String s = "class momo { \n" + + " function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n" + + " { \n" + " } \n" + + "} \n"; + + String expectedSyntaxErrorDiagnosis = ""; + + checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); + // testName); } + public void test98() { - String s = - "return(array());"+ - "if(!$result = mysql_query($sql)) return(array());\n"; + String s = "return(array());" + + "if(!$result = mysql_query($sql)) return(array());\n"; - String expectedSyntaxErrorDiagnosis = - ""; + String expectedSyntaxErrorDiagnosis = ""; - checkParsePHP( - s.toCharArray(), - expectedSyntaxErrorDiagnosis); -// testName); + checkParsePHP(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 = "----------\n" - + "1. ERROR in (at line 1)\n" - + " murks; \n" - + " ^^^^^^\n" - + "Parser error \"\'public\' \'private\' or \'protected\' modifier expected for field declarations.\"\n" - + "----------\n" -// + "2. ERROR in (at line 1)\n" -// + " } \n" -// + " ^\n" -// + "Parser error \"Too many closing \'}\'; end-of-file not reached.\"\n" -// + "----------\n" - ; - - checkParsePHP( - s.toCharArray(), - expectedSyntaxErrorDiagnosis); -// testName); + String s = "class test { \n" + + " murks; \n" + + " function &fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) \n" + + " { \n" + " } \n" + + "} \n"; + + String expectedSyntaxErrorDiagnosis = "----------\n" + + "1. ERROR in (at line 1)\n" + + " murks; \n" + + " ^^^^^^\n" + + "Parser error \"\'public\' \'private\' or \'protected\' modifier expected for field declarations.\"\n" + + "----------\n" + // + "2. ERROR in (at line 1)\n" + // + " } \n" + // + " ^\n" + // + "Parser error \"Too many closing \'}\'; end-of-file not + // reached.\"\n" + // + "----------\n" + ; + + checkParsePHP(s.toCharArray(), expectedSyntaxErrorDiagnosis); + // testName); } }