diff options
| author | Nuno Lopes <nlopess@php.net> | 2006-07-03 14:46:44 +0000 |
|---|---|---|
| committer | Nuno Lopes <nlopess@php.net> | 2006-07-03 14:46:44 +0000 |
| commit | 919d737505e50bb188814dc23c13dfe92d6d2cd4 (patch) | |
| tree | 4eae9311700505e0af00f271ac37380c71f8cdd4 /ext/pcre/tests | |
| parent | 9990b3f43162a53a9e3bce2a469cc7c4a14dff33 (diff) | |
| download | php-git-919d737505e50bb188814dc23c13dfe92d6d2cd4.tar.gz | |
more testing
Diffstat (limited to 'ext/pcre/tests')
| -rw-r--r-- | ext/pcre/tests/match_flags3.phpt | 10 | ||||
| -rw-r--r-- | ext/pcre/tests/preg_replace_callback2.phpt | 40 |
2 files changed, 49 insertions, 1 deletions
diff --git a/ext/pcre/tests/match_flags3.phpt b/ext/pcre/tests/match_flags3.phpt index 8670f0383d..a0fa5a8f3c 100644 --- a/ext/pcre/tests/match_flags3.phpt +++ b/ext/pcre/tests/match_flags3.phpt @@ -8,6 +8,9 @@ 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); @@ -22,6 +25,11 @@ array(1) { [0]=> string(3) "789" } +int(1) +array(1) { + [0]=> + string(3) "123" +} int(2) array(1) { [0]=> @@ -33,5 +41,5 @@ array(1) { } } -Warning: preg_match: numeric named subpatterns are not allowed in %smatch_flags3.php on line 11 +Warning: preg_match: numeric named subpatterns are not allowed in %smatch_flags3.php on line 14 bool(false) diff --git a/ext/pcre/tests/preg_replace_callback2.phpt b/ext/pcre/tests/preg_replace_callback2.phpt new file mode 100644 index 0000000000..65f23ca6cb --- /dev/null +++ b/ext/pcre/tests/preg_replace_callback2.phpt @@ -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" |
