diff options
Diffstat (limited to 'ext/pcre/tests')
24 files changed, 335 insertions, 476 deletions
diff --git a/ext/pcre/tests/bug47229.phpt b/ext/pcre/tests/bug47229.phpt index 8edd1c0a5a..74dcf20099 100644 --- a/ext/pcre/tests/bug47229.phpt +++ b/ext/pcre/tests/bug47229.phpt @@ -19,7 +19,7 @@ preg_match("/a\-{1,}/", 'a\----a', $m); var_dump($m); ?> ---EXPECTF-- +--EXPECT-- string(13) "\-oh really\?" array(1) { [0]=> diff --git a/ext/pcre/tests/bug61780_1.phpt b/ext/pcre/tests/bug61780_1.phpt index dc5806cb30..17add891a8 100644 --- a/ext/pcre/tests/bug61780_1.phpt +++ b/ext/pcre/tests/bug61780_1.phpt @@ -95,7 +95,11 @@ array ( ), 1 => array ( - 0 => NULL, + 0 => + array ( + 0 => NULL, + 1 => -1, + ), 1 => array ( 0 => NULL, @@ -106,18 +110,34 @@ array ( 0 => '4', 1 => 3, ), - 3 => NULL, + 3 => + array ( + 0 => NULL, + 1 => -1, + ), ), 2 => array ( - 0 => NULL, + 0 => + array ( + 0 => NULL, + 1 => -1, + ), 1 => array ( 0 => '2', 1 => 1, ), - 2 => NULL, - 3 => NULL, + 2 => + array ( + 0 => NULL, + 1 => -1, + ), + 3 => + array ( + 0 => NULL, + 1 => -1, + ), ), ) @@ -125,6 +145,8 @@ array ( 0 => array ( 0 => '1', + 1 => NULL, + 2 => NULL, ), 1 => array ( @@ -136,10 +158,13 @@ array ( array ( 0 => '45', 1 => '4', + 2 => NULL, ), 3 => array ( 0 => '6', + 1 => NULL, + 2 => NULL, ), ) @@ -151,6 +176,16 @@ array ( 0 => '1', 1 => 0, ), + 1 => + array ( + 0 => NULL, + 1 => -1, + ), + 2 => + array ( + 0 => NULL, + 1 => -1, + ), ), 1 => array ( @@ -182,6 +217,11 @@ array ( 0 => '4', 1 => 3, ), + 2 => + array ( + 0 => NULL, + 1 => -1, + ), ), 3 => array ( @@ -190,5 +230,15 @@ array ( 0 => '6', 1 => 5, ), + 1 => + array ( + 0 => NULL, + 1 => -1, + ), + 2 => + array ( + 0 => NULL, + 1 => -1, + ), ), ) diff --git a/ext/pcre/tests/bug61780_2.phpt b/ext/pcre/tests/bug61780_2.phpt index faf44d368b..01d58128c5 100644 --- a/ext/pcre/tests/bug61780_2.phpt +++ b/ext/pcre/tests/bug61780_2.phpt @@ -121,7 +121,11 @@ array ( ), 'a' => array ( - 0 => NULL, + 0 => + array ( + 0 => NULL, + 1 => -1, + ), 1 => array ( 0 => NULL, @@ -132,11 +136,19 @@ array ( 0 => '4', 1 => 3, ), - 3 => NULL, + 3 => + array ( + 0 => NULL, + 1 => -1, + ), ), 1 => array ( - 0 => NULL, + 0 => + array ( + 0 => NULL, + 1 => -1, + ), 1 => array ( 0 => NULL, @@ -147,29 +159,57 @@ array ( 0 => '4', 1 => 3, ), - 3 => NULL, + 3 => + array ( + 0 => NULL, + 1 => -1, + ), ), 'b' => array ( - 0 => NULL, + 0 => + array ( + 0 => NULL, + 1 => -1, + ), 1 => array ( 0 => '2', 1 => 1, ), - 2 => NULL, - 3 => NULL, + 2 => + array ( + 0 => NULL, + 1 => -1, + ), + 3 => + array ( + 0 => NULL, + 1 => -1, + ), ), 2 => array ( - 0 => NULL, + 0 => + array ( + 0 => NULL, + 1 => -1, + ), 1 => array ( 0 => '2', 1 => 1, ), - 2 => NULL, - 3 => NULL, + 2 => + array ( + 0 => NULL, + 1 => -1, + ), + 3 => + array ( + 0 => NULL, + 1 => -1, + ), ), ) @@ -177,6 +217,10 @@ array ( 0 => array ( 0 => '1', + 'a' => NULL, + 1 => NULL, + 'b' => NULL, + 2 => NULL, ), 1 => array ( @@ -191,10 +235,16 @@ array ( 0 => '45', 'a' => '4', 1 => '4', + 'b' => NULL, + 2 => NULL, ), 3 => array ( 0 => '6', + 'a' => NULL, + 1 => NULL, + 'b' => NULL, + 2 => NULL, ), ) @@ -206,6 +256,26 @@ array ( 0 => '1', 1 => 0, ), + 'a' => + array ( + 0 => NULL, + 1 => -1, + ), + 1 => + array ( + 0 => NULL, + 1 => -1, + ), + 'b' => + array ( + 0 => NULL, + 1 => -1, + ), + 2 => + array ( + 0 => NULL, + 1 => -1, + ), ), 1 => array ( @@ -252,6 +322,16 @@ array ( 0 => '4', 1 => 3, ), + 'b' => + array ( + 0 => NULL, + 1 => -1, + ), + 2 => + array ( + 0 => NULL, + 1 => -1, + ), ), 3 => array ( @@ -260,5 +340,25 @@ array ( 0 => '6', 1 => 5, ), + 'a' => + array ( + 0 => NULL, + 1 => -1, + ), + 1 => + array ( + 0 => NULL, + 1 => -1, + ), + 'b' => + array ( + 0 => NULL, + 1 => -1, + ), + 2 => + array ( + 0 => NULL, + 1 => -1, + ), ), ) diff --git a/ext/pcre/tests/bug72463_2.phpt b/ext/pcre/tests/bug72463_2.phpt index 1baeb0f2a1..9b9ac9bdc5 100644 --- a/ext/pcre/tests/bug72463_2.phpt +++ b/ext/pcre/tests/bug72463_2.phpt @@ -1,11 +1,5 @@ --TEST-- Bug #72463 mail fails with invalid argument ---SKIPIF-- -<?php -if(substr(PHP_OS, 0, 3) != "WIN") { - die('skip windows only'); -} -?> --INI-- SMTP=non.existent.smtp.server --FILE-- diff --git a/ext/pcre/tests/bug72685.phpt b/ext/pcre/tests/bug72685.phpt new file mode 100644 index 0000000000..31b2f9b0c7 --- /dev/null +++ b/ext/pcre/tests/bug72685.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #72685: Same string is UTF-8 validated repeatedly +--SKIPIF-- +<?php +if (getenv('SKIP_PERF_SENSITIVE')) die("skip performance sensitive test"); +?> +--FILE-- +<?php + +$input_size = 64 * 1024; +$str = str_repeat('a', $input_size); + +$start = microtime(true); +$pos = 0; +while (preg_match('/\G\w/u', $str, $m, 0, $pos)) ++$pos; +$end = microtime(true); +var_dump(($end - $start) < 0.5); // large margin, more like 0.05 in debug build + +?> +--EXPECT-- +bool(true) diff --git a/ext/pcre/tests/dollar_endonly.phpt b/ext/pcre/tests/dollar_endonly.phpt index 96a52441df..ea2d882574 100644 --- a/ext/pcre/tests/dollar_endonly.phpt +++ b/ext/pcre/tests/dollar_endonly.phpt @@ -1,5 +1,5 @@ --TEST-- -D (PCRE_DOLLAR_ENDONLY) modififer +D (PCRE_DOLLAR_ENDONLY) modifier --FILE-- <?php diff --git a/ext/pcre/tests/pcre_anchored.phpt b/ext/pcre/tests/pcre_anchored.phpt index a609fdbdcd..c03d13501a 100644 --- a/ext/pcre/tests/pcre_anchored.phpt +++ b/ext/pcre/tests/pcre_anchored.phpt @@ -1,5 +1,5 @@ --TEST-- -A (PCRE_ANCHORED) modififer +A (PCRE_ANCHORED) modifier --SKIPIF-- <?php if (@preg_match_all('/\p{N}/', '0123456789', $dummy) === false) { diff --git a/ext/pcre/tests/pcre_extended.phpt b/ext/pcre/tests/pcre_extended.phpt index 6c4b20e7f0..060705ce76 100644 --- a/ext/pcre/tests/pcre_extended.phpt +++ b/ext/pcre/tests/pcre_extended.phpt @@ -1,5 +1,5 @@ --TEST-- -x (PCRE_EXTENDED) modififer +x (PCRE_EXTENDED) modifier --FILE-- <?php diff --git a/ext/pcre/tests/pcre_extra.phpt b/ext/pcre/tests/pcre_extra.phpt index 2bee408fbf..4c5930f975 100644 --- a/ext/pcre/tests/pcre_extra.phpt +++ b/ext/pcre/tests/pcre_extra.phpt @@ -1,5 +1,5 @@ --TEST-- -X (PCRE_EXTRA) modififer +X (PCRE_EXTRA) modifier --FILE-- <?php diff --git a/ext/pcre/tests/preg_grep_error.phpt b/ext/pcre/tests/preg_grep_error.phpt deleted file mode 100644 index 8cc3ffe669..0000000000 --- a/ext/pcre/tests/preg_grep_error.phpt +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -Test preg_grep() function : error conditions - wrong numbers of parameters ---FILE-- -<?php -/* -* proto array preg_grep(string regex, array input [, int flags]) -* Function is implemented in ext/pcre/php_pcre.c -*/ -echo "*** Testing preg_grep() : error conditions ***\n"; -// Zero arguments -echo "\n-- Testing preg_grep() function with Zero arguments --\n"; -var_dump(preg_grep()); -//Test preg_grep with one more than the expected number of arguments -echo "\n-- Testing preg_grep() function with more than expected no. of arguments --\n"; -$regex = '/\d/'; -$input = array(1, 2); -$flags = 0; -$extra_arg = 10; -var_dump(preg_grep($regex, $input, $flags, $extra_arg)); -// Testing preg_grep withone less than the expected number of arguments -echo "\n-- Testing preg_grep() function with less than expected no. of arguments --\n"; -$regex = 'string_val'; -var_dump(preg_grep($regex)); -echo "Done" -?> ---EXPECTF-- -*** Testing preg_grep() : error conditions *** - --- Testing preg_grep() function with Zero arguments -- - -Warning: preg_grep() expects at least 2 parameters, 0 given in %spreg_grep_error.php on line %d -NULL - --- Testing preg_grep() function with more than expected no. of arguments -- - -Warning: preg_grep() expects at most 3 parameters, 4 given in %spreg_grep_error.php on line %d -NULL - --- Testing preg_grep() function with less than expected no. of arguments -- - -Warning: preg_grep() expects at least 2 parameters, 1 given in %spreg_grep_error.php on line %d -NULL -Done diff --git a/ext/pcre/tests/preg_grep_error2.phpt b/ext/pcre/tests/preg_grep_error2.phpt deleted file mode 100644 index 720940800f..0000000000 --- a/ext/pcre/tests/preg_grep_error2.phpt +++ /dev/null @@ -1,42 +0,0 @@ ---TEST-- -Test preg_grep() function : error conditions - wrong arg types ---FILE-- -<?php -/* -* proto array preg_grep(string regex, array input [, int flags]) -* Function is implemented in ext/pcre/php_pcre.c -*/ -error_reporting(E_ALL&~E_NOTICE); -/* -* Testing how preg_grep reacts to being passed the wrong type of input argument -*/ -echo "*** Testing preg_grep() : error conditions ***\n"; -$regex = '/[a-zA-Z]/'; -$input = array('this is a string', array('this is', 'a subarray'),); -foreach($input as $value) { - print "\nArg value is: $value\n"; - var_dump(preg_grep($regex, $value)); -} -$value = new stdclass(); //Object -var_dump(preg_grep($regex, $value)); -echo "Done"; -?> ---EXPECTF-- -*** Testing preg_grep() : error conditions *** - -Arg value is: this is a string - -Warning: preg_grep() expects parameter 2 to be array, string given in %spreg_grep_error2.php on line %d -NULL - -Arg value is: Array -array(2) { - [0]=> - string(7) "this is" - [1]=> - string(10) "a subarray" -} - -Warning: preg_grep() expects parameter 2 to be array, object given in %spreg_grep_error2.php on line %d -NULL -Done diff --git a/ext/pcre/tests/preg_last_error_error.phpt b/ext/pcre/tests/preg_last_error_error.phpt deleted file mode 100644 index 105d5ab1c2..0000000000 --- a/ext/pcre/tests/preg_last_error_error.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Test preg_grep() function : error conditions - wrong numbers of parameters ---FILE-- -<?php - -/* Prototype : int preg_last_error ( void ) - * Description: Returns the error code of the last PCRE regex execution - * Source code: ext/pcre/php_pcre.c - */ - -/* - * Pass an incorrect number of arguments to preg_last_error() to test behaviour - */ - -echo "*** Testing preg_last_error() : error conditions ***\n"; - -// Test preg_last_error with one more than the expected number of arguments -echo "\n-- Testing preg_last_error() function with more than expected no. of arguments --\n"; -$extra_arg = 10; -var_dump( preg_last_error($extra_arg) ); -?> -===Done=== ---EXPECTF-- -*** Testing preg_last_error() : error conditions *** - --- Testing preg_last_error() function with more than expected no. of arguments -- - -Warning: preg_last_error() expects exactly 0 parameters, 1 given in %s on line %d -NULL -===Done=== diff --git a/ext/pcre/tests/preg_match_all_error.phpt b/ext/pcre/tests/preg_match_all_error.phpt deleted file mode 100644 index f6e89284bb..0000000000 --- a/ext/pcre/tests/preg_match_all_error.phpt +++ /dev/null @@ -1,44 +0,0 @@ ---TEST-- -Test preg_match_all() function : error conditions - incorrect number of parameters ---FILE-- -<?php -/* -* proto int preg_match_all(string pattern, string subject, array subpatterns [, int flags [, int offset]]) -* Function is implemented in ext/pcre/php_pcre.c -*/ -echo "*** Testing preg_match_all() : error conditions ***\n"; -// Zero arguments -echo "\n-- Testing preg_match_all() function with Zero arguments --\n"; -var_dump(preg_match_all()); -//Test preg_match_all with one more than the expected number of arguments -echo "\n-- Testing preg_match_all() function with more than expected no. of arguments --\n"; -$pattern = '/\w/'; -$subject = 'string_val'; -$flags = PREG_OFFSET_CAPTURE; -$offset = 10; -$extra_arg = 10; -var_dump(preg_match_all($pattern, $subject, $matches, $flags, $offset, $extra_arg)); -// Testing preg_match_all withone less than the expected number of arguments -echo "\n-- Testing preg_match_all() function with less than expected no. of arguments --\n"; -$pattern = '/\w/'; -var_dump(preg_match_all($pattern)); -echo "Done" -?> ---EXPECTF-- -*** Testing preg_match_all() : error conditions *** - --- Testing preg_match_all() function with Zero arguments -- - -Warning: preg_match_all() expects at least 2 parameters, 0 given in %spreg_match_all_error.php on line %d -bool(false) - --- Testing preg_match_all() function with more than expected no. of arguments -- - -Warning: preg_match_all() expects at most 5 parameters, 6 given in %spreg_match_all_error.php on line %d -bool(false) - --- Testing preg_match_all() function with less than expected no. of arguments -- - -Warning: preg_match_all() expects at least 2 parameters, 1 given in %spreg_match_all_error.php on line %d -bool(false) -Done diff --git a/ext/pcre/tests/preg_match_error.phpt b/ext/pcre/tests/preg_match_error.phpt deleted file mode 100644 index 7d318115f6..0000000000 --- a/ext/pcre/tests/preg_match_error.phpt +++ /dev/null @@ -1,44 +0,0 @@ ---TEST-- -Test preg_match() function : error conditions - wrong numbers of parameters ---FILE-- -<?php -/* - * proto int preg_match(string pattern, string subject [, array subpatterns [, int flags [, int offset]]]) - * Function is implemented in ext/pcre/php_pcre.c -*/ -echo "*** Testing preg_match() : error conditions ***\n"; -// Zero arguments -echo "\n-- Testing preg_match() function with Zero arguments --\n"; -var_dump(preg_match()); -//Test preg_match with one more than the expected number of arguments -echo "\n-- Testing preg_match() function with more than expected no. of arguments --\n"; -$pattern = '/\w/'; -$subject = 'string_val'; -$flags = PREG_OFFSET_CAPTURE; -$offset = 10; -$extra_arg = 10; -var_dump(preg_match($pattern, $subject, $matches, $flags, $offset, $extra_arg)); -// Testing preg_match withone less than the expected number of arguments -echo "\n-- Testing preg_match() function with less than expected no. of arguments --\n"; -$pattern = '/\w/'; -var_dump(preg_match($pattern)); -echo "Done" -?> ---EXPECTF-- -*** Testing preg_match() : error conditions *** - --- Testing preg_match() function with Zero arguments -- - -Warning: preg_match() expects at least 2 parameters, 0 given in %spreg_match_error.php on line %d -bool(false) - --- Testing preg_match() function with more than expected no. of arguments -- - -Warning: preg_match() expects at most 5 parameters, 6 given in %spreg_match_error.php on line %d -bool(false) - --- Testing preg_match() function with less than expected no. of arguments -- - -Warning: preg_match() expects at least 2 parameters, 1 given in %spreg_match_error.php on line %d -bool(false) -Done diff --git a/ext/pcre/tests/preg_quote_error.phpt b/ext/pcre/tests/preg_quote_error.phpt deleted file mode 100644 index b5dd733b2f..0000000000 --- a/ext/pcre/tests/preg_quote_error.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -Test preg_quote() function : error conditions - wrong numbers of parameters ---FILE-- -<?php -/* -* proto string preg_quote(string str [, string delim_char]) -* Function is implemented in ext/pcre/php_pcre.c -*/ -echo "*** Testing preg_quote() : error conditions ***\n"; -// Zero arguments -echo "\n-- Testing preg_quote() function with Zero arguments --\n"; -var_dump(preg_quote()); -//Test preg_quote with one more than the expected number of arguments -echo "\n-- Testing preg_quote() function with more than expected no. of arguments --\n"; -$str = 'string_val'; -$delim_char = '/'; -$extra_arg = 10; -var_dump(preg_quote($str, $delim_char, $extra_arg)); -echo "Done" -?> ---EXPECTF-- -*** Testing preg_quote() : error conditions *** - --- Testing preg_quote() function with Zero arguments -- - -Warning: preg_quote() expects at least 1 parameter, 0 given in %spreg_quote_error.php on line %d -NULL - --- Testing preg_quote() function with more than expected no. of arguments -- - -Warning: preg_quote() expects at most 2 parameters, 3 given in %spreg_quote_error.php on line %d -NULL -Done diff --git a/ext/pcre/tests/preg_quote_error1.phpt b/ext/pcre/tests/preg_quote_error1.phpt deleted file mode 100644 index 6f885f0509..0000000000 --- a/ext/pcre/tests/preg_quote_error1.phpt +++ /dev/null @@ -1,36 +0,0 @@ ---TEST-- -Test preg_quote() function : error conditions - wrong arg types ---FILE-- -<?php -/* -* proto string preg_quote(string str [, string delim_char]) -* Function is implemented in ext/pcre/php_pcre.c -*/ -error_reporting(E_ALL&~E_NOTICE); -/* -* Testing how preg_quote reacts to being passed the wrong type of input argument -*/ -echo "*** Testing preg_quote() : error conditions ***\n"; -$input = array('this is a string', array('this is', 'a subarray'),); -foreach($input as $value) { - print "\nArg value is: $value\n"; - var_dump(preg_quote($value)); -} -$value = new stdclass(); //Object -var_dump(preg_quote($value)); -echo "Done"; -?> ---EXPECTF-- -*** Testing preg_quote() : error conditions *** - -Arg value is: this is a string -string(16) "this is a string" - -Arg value is: Array - -Warning: preg_quote() expects parameter 1 to be string, array given in %spreg_quote_error1.php on line %d -NULL - -Warning: preg_quote() expects parameter 1 to be string, object given in %spreg_quote_error1.php on line %d -NULL -Done diff --git a/ext/pcre/tests/preg_replace_callback_error.phpt b/ext/pcre/tests/preg_replace_callback_error.phpt deleted file mode 100644 index 2834eea4db..0000000000 --- a/ext/pcre/tests/preg_replace_callback_error.phpt +++ /dev/null @@ -1,48 +0,0 @@ ---TEST-- -Test preg_replace_callback() function : error ---FILE-- -<?php -/* -* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]]) -* Function is implemented in ext/pcre/php_pcre.c -*/ -echo "***Testing preg_replace_callback() : error conditions***\n"; -//Zero arguments -echo "\n-- Testing preg_replace_callback() function with Zero arguments --\n"; -var_dump(preg_replace_callback()); -//Test preg_replace_callback() with one more than the expected number of arguments -echo "\n-- Testing preg_replace_callback() function with more than expected no. of arguments --\n"; -$replacement = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'); -function integer_word($matches) { - global $replacement; - return $replacement[$matches[0]]; -} -$regex = '/\d/'; -$subject = 'there are 7 words in this sentence.'; -$limit = 10; -$extra_arg = 10; -var_dump(preg_replace_callback($regex, 'integer_word', $subject, $limit, $count, $extra_arg)); -//Testing preg_replace_callback() with one less than the expected number of arguments -echo "\n-- Testing preg_replace_callback() function with less than expected no. of arguments --\n"; -$regex = '/\d/'; -var_dump(preg_replace_callback($regex, 'integer word')); -echo "Done"; -?> ---EXPECTF-- -***Testing preg_replace_callback() : error conditions*** - --- Testing preg_replace_callback() function with Zero arguments -- - -Warning: preg_replace_callback() expects at least 3 parameters, 0 given in %s on line %d -NULL - --- Testing preg_replace_callback() function with more than expected no. of arguments -- - -Warning: preg_replace_callback() expects at most 5 parameters, 6 given in %s on line %d -NULL - --- Testing preg_replace_callback() function with less than expected no. of arguments -- - -Warning: preg_replace_callback() expects at least 3 parameters, 2 given in %s on line %d -NULL -Done diff --git a/ext/pcre/tests/preg_replace_callback_flags.phpt b/ext/pcre/tests/preg_replace_callback_flags.phpt new file mode 100644 index 0000000000..7e9a130ba7 --- /dev/null +++ b/ext/pcre/tests/preg_replace_callback_flags.phpt @@ -0,0 +1,130 @@ +--TEST-- +Support for flags in preg_replace_callback(_array) +--FILE-- +<?php + +var_dump(preg_replace_callback('/./', function($matches) { + var_dump($matches); + return $matches[0][0]; +}, 'abc', -1, $count, PREG_OFFSET_CAPTURE)); +echo "\n"; + +var_dump(preg_replace_callback_array( + ['/./' => function($matches) { + var_dump($matches); + return $matches[0][0]; + }], + 'abc', -1, $count, PREG_OFFSET_CAPTURE) +); +echo "\n"; + +var_dump(preg_replace_callback('/(a)|(b)/', function($matches) { + var_dump($matches); + return $matches[0]; +}, 'abc', -1, $count, PREG_UNMATCHED_AS_NULL)); +echo "\n"; + +var_dump(preg_replace_callback_array( + ['/(a)|(b)/' => function($matches) { + var_dump($matches); + return $matches[0]; + }], + 'abc', -1, $count, PREG_UNMATCHED_AS_NULL) +); +echo "\n"; + +?> +--EXPECT-- +array(1) { + [0]=> + array(2) { + [0]=> + string(1) "a" + [1]=> + int(0) + } +} +array(1) { + [0]=> + array(2) { + [0]=> + string(1) "b" + [1]=> + int(1) + } +} +array(1) { + [0]=> + array(2) { + [0]=> + string(1) "c" + [1]=> + int(2) + } +} +string(3) "abc" + +array(1) { + [0]=> + array(2) { + [0]=> + string(1) "a" + [1]=> + int(0) + } +} +array(1) { + [0]=> + array(2) { + [0]=> + string(1) "b" + [1]=> + int(1) + } +} +array(1) { + [0]=> + array(2) { + [0]=> + string(1) "c" + [1]=> + int(2) + } +} +string(3) "abc" + +array(3) { + [0]=> + string(1) "a" + [1]=> + string(1) "a" + [2]=> + NULL +} +array(3) { + [0]=> + string(1) "b" + [1]=> + NULL + [2]=> + string(1) "b" +} +string(3) "abc" + +array(3) { + [0]=> + string(1) "a" + [1]=> + string(1) "a" + [2]=> + NULL +} +array(3) { + [0]=> + string(1) "b" + [1]=> + NULL + [2]=> + string(1) "b" +} +string(3) "abc" diff --git a/ext/pcre/tests/preg_replace_error.phpt b/ext/pcre/tests/preg_replace_error.phpt deleted file mode 100644 index fc3427d1c8..0000000000 --- a/ext/pcre/tests/preg_replace_error.phpt +++ /dev/null @@ -1,45 +0,0 @@ ---TEST-- -Test preg_replace() function : error - incorrect number of parameters ---FILE-- -<?php -/* -* proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]]) -* Function is implemented in ext/pcre/php_pcre.c -*/ -echo "*** Testing preg_replace() : error conditions ***\n"; -//Zero arguments -echo "\n-- Testing preg_replace() function with zero arguments --\n"; -var_dump(preg_replace()); -//Test preg_replace() with one more than the expected number of arguments -echo "\n-- Testing preg_replace() function with more than expected no. of arguments --\n"; -$regex = '/\w/'; -$replace = '1'; -$subject = 'string_val'; -$limit = 10; -$extra_arg = 10; -var_dump(preg_replace($regex, $replace, $subject, $limit, $count, $extra_arg)); -//Testing preg_replace() with one less than the expected number of arguments -echo "\n-- Testing preg_replace() function with less than expected no. of arguments --\n"; -$regex = '/\w/'; -$replace = '1'; -var_dump(preg_replace($regex, $replace)); -echo "Done" -?> ---EXPECTF-- -*** Testing preg_replace() : error conditions *** - --- Testing preg_replace() function with zero arguments -- - -Warning: preg_replace() expects at least 3 parameters, 0 given in %s on line %d -NULL - --- Testing preg_replace() function with more than expected no. of arguments -- - -Warning: preg_replace() expects at most 5 parameters, 6 given in %s on line %d -NULL - --- Testing preg_replace() function with less than expected no. of arguments -- - -Warning: preg_replace() expects at least 3 parameters, 2 given in %s on line %d -NULL -Done diff --git a/ext/pcre/tests/preg_replace_error1.phpt b/ext/pcre/tests/preg_replace_error1.phpt index 8e20108b88..780556956a 100644 --- a/ext/pcre/tests/preg_replace_error1.phpt +++ b/ext/pcre/tests/preg_replace_error1.phpt @@ -24,7 +24,11 @@ foreach($regex_array as $regex_value) { var_dump(preg_replace($regex_value, $replace, $subject)); } $regex_value = new stdclass(); //Object -var_dump(preg_replace($regex_value, $replace, $subject)); +try { + var_dump(preg_replace($regex_value, $replace, $subject)); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} ?> --EXPECTF-- *** Testing preg_replace() : error conditions*** @@ -54,5 +58,4 @@ string(1) "a" Arg value is /[a-zA-Z]/ string(1) "1" - -Recoverable fatal error: Object of class stdClass could not be converted to string in %spreg_replace_error1.php on line %d +Object of class stdClass could not be converted to string diff --git a/ext/pcre/tests/preg_replace_error2.phpt b/ext/pcre/tests/preg_replace_error2.phpt index 8c826587ea..a334b2fefd 100644 --- a/ext/pcre/tests/preg_replace_error2.phpt +++ b/ext/pcre/tests/preg_replace_error2.phpt @@ -19,7 +19,11 @@ foreach($replace as $value) { var_dump(preg_replace($regex, $value, $subject)); } $value = new stdclass(); //Object -var_dump(preg_replace($regex, $value, $subject)); +try { + var_dump(preg_replace($regex, $value, $subject)); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} echo "Done"; ?> --EXPECTF-- @@ -32,5 +36,5 @@ Arg value is: Array Warning: preg_replace(): Parameter mismatch, pattern is a string while replacement is an array in %spreg_replace_error2.php on line %d bool(false) - -Recoverable fatal error: Object of class stdClass could not be converted to string in %spreg_replace_error2.php on line %d +Object of class stdClass could not be converted to string +Done diff --git a/ext/pcre/tests/preg_split_error.phpt b/ext/pcre/tests/preg_split_error.phpt deleted file mode 100644 index 45fe6459e6..0000000000 --- a/ext/pcre/tests/preg_split_error.phpt +++ /dev/null @@ -1,44 +0,0 @@ ---TEST-- -Test preg_split() function : error conditions - incorrect number of parameters ---FILE-- -<?php -/* -* proto array preg_split(string pattern, string subject [, int limit [, int flags]]) -* Function is implemented in ext/pcre/php_pcre.c -*/ -echo "*** Testing preg_split() : error conditions ***\n"; -// Zero arguments -echo "\n-- Testing preg_split() function with Zero arguments --\n"; -var_dump(preg_split()); -//Test preg_split with one more than the expected number of arguments -echo "\n-- Testing preg_split() function with more than expected no. of arguments --\n"; -$pattern = '/_/'; -$subject = 'string_val'; -$limit = 10; -$flags = PREG_SPLIT_NO_EMPTY; -$extra_arg = 10; -var_dump(preg_split($pattern, $subject, $limit, $flags, $extra_arg)); -// Testing preg_split withone less than the expected number of arguments -echo "\n-- Testing preg_split() function with less than expected no. of arguments --\n"; -$pattern = '/\./'; -var_dump(preg_split($pattern)); -echo "Done" -?> ---EXPECTF-- -*** Testing preg_split() : error conditions *** - --- Testing preg_split() function with Zero arguments -- - -Warning: preg_split() expects at least 2 parameters, 0 given in %spreg_split_error.php on line %d -bool(false) - --- Testing preg_split() function with more than expected no. of arguments -- - -Warning: preg_split() expects at most 4 parameters, 5 given in %spreg_split_error.php on line %d -bool(false) - --- Testing preg_split() function with less than expected no. of arguments -- - -Warning: preg_split() expects at least 2 parameters, 1 given in %spreg_split_error.php on line %d -bool(false) -Done diff --git a/ext/pcre/tests/preg_split_error2.phpt b/ext/pcre/tests/preg_split_error2.phpt deleted file mode 100644 index 030f757d0a..0000000000 --- a/ext/pcre/tests/preg_split_error2.phpt +++ /dev/null @@ -1,34 +0,0 @@ ---TEST-- -Test preg_split() function : error conditions - wrong arg types ---FILE-- -<?php -/* -* proto array preg_split(string pattern, string subject [, int limit [, int flags]]) -* Function is implemented in ext/pcre/php_pcre.c -*/ -error_reporting(E_ALL&~E_NOTICE); -/* -* Testing how preg_split reacts to being passed the wrong type of input argument -*/ -echo "*** Testing preg_split() : error conditions ***\n"; -$regex = '/[a-zA-Z]/'; -$input = array(array('this is', 'a subarray'),); -foreach($input as $value) { - print "\nArg value is: $value\n"; - var_dump(preg_split($regex, $value)); -} -$value = new stdclass(); //Object -var_dump(preg_split($regex, $value)); -echo "Done"; -?> ---EXPECTF-- -*** Testing preg_split() : error conditions *** - -Arg value is: Array - -Warning: preg_split() expects parameter 2 to be string, array given in %spreg_split_error2.php on line %d -bool(false) - -Warning: preg_split() expects parameter 2 to be string, object given in %spreg_split_error2.php on line %d -bool(false) -Done diff --git a/ext/pcre/tests/ungreedy.phpt b/ext/pcre/tests/ungreedy.phpt index cf5e8adafd..fa39c43efb 100644 --- a/ext/pcre/tests/ungreedy.phpt +++ b/ext/pcre/tests/ungreedy.phpt @@ -1,5 +1,5 @@ --TEST-- -U (PCRE_UNGREEDY) modififer +U (PCRE_UNGREEDY) modifier --FILE-- <?php |