Changeset View
Changeset View
Standalone View
Standalone View
src/parser/xhpast/__tests__/PHPASTParserTestCase.php
Context not available. | |||||
$dir = dirname(__FILE__).'/data/'; | $dir = dirname(__FILE__).'/data/'; | ||||
foreach (Filesystem::listDirectory($dir) as $file) { | foreach (Filesystem::listDirectory($dir) as $file) { | ||||
if (preg_match('/\.test$/', $file)) { | if (@preg_match('/\.test$/', $file)) { | ||||
$this->executeParserTest($file, $dir.$file); | $this->executeParserTest($file, $dir.$file); | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
case 'pass': | case 'pass': | ||||
$this->assertEqual(0, $err, pht('Exit code for "%s".', $name)); | $this->assertEqual(0, $err, pht('Exit code for "%s".', $name)); | ||||
if (!strlen($expect)) { | if (!@strlen($expect)) { | ||||
// If there's no "expect" data in the test case, that's OK. | // If there's no "expect" data in the test case, that's OK. | ||||
break; | break; | ||||
} | } | ||||
Context not available. | |||||
case 'fail-syntax': | case 'fail-syntax': | ||||
$this->assertEqual(1, $err, pht('Exit code for "%s".', $name)); | $this->assertEqual(1, $err, pht('Exit code for "%s".', $name)); | ||||
$this->assertTrue( | $this->assertTrue( | ||||
(bool)preg_match('/syntax error/', $stderr), | (bool)@preg_match('/syntax error/', $stderr), | ||||
pht('Expect "syntax error" in stderr or "%s".', $name)); | pht('Expect "syntax error" in stderr or "%s".', $name)); | ||||
break; | break; | ||||
default: | default: | ||||
Context not available. | |||||
$must_escape = false; | $must_escape = false; | ||||
// We must escape the text if it isn't just simple printable characters. | // We must escape the text if it isn't just simple printable characters. | ||||
if (preg_match('/[ \\\\\\r\\n\\t\\"]/', $text)) { | if (@preg_match('/[ \\\\\\r\\n\\t\\"]/', $text)) { | ||||
$must_escape = true; | $must_escape = true; | ||||
} | } | ||||
// We must escape the text if it has trailing whitespace. | // We must escape the text if it has trailing whitespace. | ||||
if (preg_match('/ \z/', $text)) { | if (@preg_match('/ \z/', $text)) { | ||||
$must_escape = true; | $must_escape = true; | ||||
} | } | ||||
// We must escape the text if it won't fit on a single line. | // We must escape the text if it won't fit on a single line. | ||||
if (strlen($text) > $usable_width) { | if (@strlen($text) > $usable_width) { | ||||
$must_escape = true; | $must_escape = true; | ||||
} | } | ||||
Context not available. | |||||
$line_l = '"'; | $line_l = '"'; | ||||
$line_r = '"'; | $line_r = '"'; | ||||
$max_width = ($usable_width - strlen($line_l) - strlen($line_r)); | $max_width = ($usable_width - @strlen($line_l) - @strlen($line_r)); | ||||
$line = ''; | $line = ''; | ||||
$len = 0; | $len = 0; | ||||
$lines = array(); | $lines = array(); | ||||
foreach ($vector as $word) { | foreach ($vector as $word) { | ||||
$word_length = phutil_utf8_console_strlen($word); | $word_length = phutil_utf8_consolestrlen($word); | ||||
if ($len + $word_length > $max_width) { | if ($len + $word_length > $max_width) { | ||||
$lines[] = $line_l.$line.$line_r; | $lines[] = $line_l.$line.$line_r; | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0