Browse Source

MFB

migration/RELEASE_1_0_0
Nuno Lopes 20 years ago
parent
commit
57801820f5
  1. 3
      ext/pcre/tests/locales.phpt
  2. 45
      ext/pcre/tests/match_flags3.phpt
  3. 35
      ext/pcre/tests/preg_replace.phpt
  4. 25
      ext/pcre/tests/preg_replace_callback.phpt
  5. 40
      ext/pcre/tests/preg_replace_callback2.phpt

3
ext/pcre/tests/locales.phpt

@ -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

45
ext/pcre/tests/match_flags3.phpt

@ -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)

35
ext/pcre/tests/preg_replace.phpt

@ -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

25
ext/pcre/tests/preg_replace_callback.phpt

@ -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

40
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"
Loading…
Cancel
Save