cvs: php-src /ext/pcre/tests locales.phpt match_flags3.phpt preg_replace.phpt preg_replace_callback.phpt preg_replace_callback2.phpt

From: Date: Mon, 03 Jul 2006 14:55:49 +0000
Subject: cvs: php-src /ext/pcre/tests locales.phpt match_flags3.phpt preg_replace.phpt preg_replace_callback.phpt preg_replace_callback2.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-39020@lists.php.net to get a copy of this message
nlopess Mon Jul 3 14:55:49 2006 UTC Modified files: /php-src/ext/pcre/tests match_flags3.phpt preg_replace.phpt preg_replace_callback.phpt preg_replace_callback2.phpt locales.phpt Log: MFB http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/match_flags3.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/pcre/tests/match_flags3.phpt diff -u /dev/null php-src/ext/pcre/tests/match_flags3.phpt:1.2 --- /dev/null Mon Jul 3 14:55:49 2006 +++ php-src/ext/pcre/tests/match_flags3.phpt Mon Jul 3 14:55:49 2006 @@ -0,0 +1,45 @@ +--TEST-- +preg_match() flags 3 +--FILE-- +<?php + +var_dump(preg_match('', '', $match, 0xfff)); + +var_dump(preg_match('/\d+/', '123 456 789 012', $match, 0, -8)); +var_dump($match); + +var_dump(preg_match('/\d+/', '123 456 789 012', $match, 0, -500)); +var_dump($match); + +var_dump(preg_match_all('/\d+/', '123 456 789 012', $match, 0, -8)); +var_dump($match); + +var_dump(preg_match('/(?P<3>)/', '')); + +?> +--EXPECTF-- +Warning: Wrong value for parameter 4 in call to preg_match() in %smatch_flags3.php on line 3 +NULL +int(1) +array(1) { + [0]=> + string(3) "789" +} +int(1) +array(1) { + [0]=> + string(3) "123" +} +int(2) +array(1) { + [0]=> + array(2) { + [0]=> + string(3) "789" + [1]=> + string(3) "012" + } +} + +Warning: preg_match: numeric named subpatterns are not allowed in %smatch_flags3.php on line 14 +bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/preg_replace.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/pcre/tests/preg_replace.phpt diff -u /dev/null php-src/ext/pcre/tests/preg_replace.phpt:1.2 --- /dev/null Mon Jul 3 14:55:49 2006 +++ php-src/ext/pcre/tests/preg_replace.phpt Mon Jul 3 14:55:49 2006 @@ -0,0 +1,35 @@ +--TEST-- +preg_replace() +--FILE-- +<?php + +var_dump(preg_replace('{{\D+}}', 'x', '{abcd}')); +var_dump(preg_replace('{{\D+}}', 'ddd', 'abcd')); + +var_dump(preg_replace('/(ab)(c)(d)(e)(f)(g)(h)(i)(j)(k)/', 'a${1}2$103', 'zabcdefghijkl')); + +var_dump(preg_replace_callback('//e', '', '')); + +var_dump(preg_replace_callback('//e', 'strtolower', '')); + +?> +--EXPECTF-- +string(1) "x" +string(4) "abcd" +string(8) "zaab2k3l" + +Warning: preg_replace_callback(): requires argument 2, '', to be a valid callback in %spreg_replace.php on line 8 +string(0) "" + +Warning: preg_replace_callback(): /e modifier cannot be used with replacement callback in %spreg_replace.php on line 10 +NULL +--EXPECTUF-- +string(1) "x" +string(4) "abcd" +string(8) "zaab2k3l" + +Warning: preg_replace_callback(): requires argument 2, '', to be a valid callback in %spreg_replace.php on line 8 +unicode(0) "" + +Warning: preg_replace_callback(): /e modifier cannot be used with replacement callback in %spreg_replace.php on line 10 +NULL http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/preg_replace_callback.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/pcre/tests/preg_replace_callback.phpt diff -u /dev/null php-src/ext/pcre/tests/preg_replace_callback.phpt:1.2 --- /dev/null Mon Jul 3 14:55:49 2006 +++ php-src/ext/pcre/tests/preg_replace_callback.phpt Mon Jul 3 14:55:49 2006 @@ -0,0 +1,25 @@ +--TEST-- +preg_replace_callback() +--FILE-- +<?php +$input = "plain [indent] deep [indent] [abcd]deeper[/abcd] [/indent] deep [/indent] plain"; + +function parseTagsRecursive($input) +{ + + $regex = '#\[indent]((?:[^[]|\[(?!/?indent])|(?R))+)\[/indent]#'; + + if (is_array($input)) { + $input = '<div style="margin-left: 10px">'.$input[1].'</div>'; + } + + return preg_replace_callback($regex, 'parseTagsRecursive', $input); +} + +$output = parseTagsRecursive($input); + +echo $output, "\n"; + +?> +--EXPECT-- +plain <div style="margin-left: 10px"> deep <div style="margin-left: 10px"> [abcd]deeper[/abcd] </div> deep </div> plain http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/preg_replace_callback2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/pcre/tests/preg_replace_callback2.phpt diff -u /dev/null php-src/ext/pcre/tests/preg_replace_callback2.phpt:1.2 --- /dev/null Mon Jul 3 14:55:49 2006 +++ php-src/ext/pcre/tests/preg_replace_callback2.phpt Mon Jul 3 14:55:49 2006 @@ -0,0 +1,40 @@ +--TEST-- +preg_replace_callback() 2 +--FILE-- +<?php + +function f() { + throw new Exception(); +} + +try { +var_dump(preg_replace_callback('/\w/', 'f', 'z')); +} catch(Exception $e) {} + +function g($x) { + return "'$x[0]'"; +} + +var_dump(preg_replace_callback('@\b\w{1,2}\b@', 'g', array('a b3 bcd', 'v' => 'aksfjk', 12 => 'aa bb'))); + +var_dump(preg_replace_callback('~\A.~', 'g', array(array('xyz')))); + +var_dump(preg_replace_callback('~\A.~', create_function('$m', 'return strtolower($m[0]);'), 'ABC')); +?> +--EXPECTF-- +Warning: preg_replace_callback(): Unable to call custom replacement function ins %preg_replace_callback2.php on line 8 +array(3) { + [0]=> + string(12) "'a' 'b3' bcd" + ["v"]=> + string(6) "aksfjk" + [12]=> + string(9) "'aa' 'bb'" +} + +Notice: Array to string conversion in %spreg_replace_callback2.php on line 17 +array(1) { + [0]=> + string(7) "'A'rray" +} +string(3) "aBC" http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/locales.phpt?r1=1.4&r2=1.5&diff_format=u Index: php-src/ext/pcre/tests/locales.phpt diff -u php-src/ext/pcre/tests/locales.phpt:1.4 php-src/ext/pcre/tests/locales.phpt:1.5 --- php-src/ext/pcre/tests/locales.phpt:1.4 Mon Jun 26 23:42:43 2006 +++ php-src/ext/pcre/tests/locales.phpt Mon Jul 3 14:55:49 2006 @@ -2,10 +2,11 @@ Localized match --SKIPIF-- <?php if (!function_exists('setlocale')) die('skip: setlocale() not available'); ?> +<?php if (!@setlocale(LC_ALL, 'pt_PT', 'pt', 'pt_PT.ISO8859-1', 'portuguese')) die('skip pt locale not available'); --FILE-- <?php -declare(encoding=latin1); +declare(encoding='latin1'); // this tests if the cache is working correctly, as the char tables // must be rebuilt after the locale change

« previous php.cvs (#39020) next »