diff options
Diffstat (limited to 'ext/pcre/tests')
-rw-r--r-- | ext/pcre/tests/preg_replace_callback_array.phpt | 39 | ||||
-rw-r--r-- | ext/pcre/tests/preg_replace_callback_array2.phpt | 40 | ||||
-rw-r--r-- | ext/pcre/tests/preg_replace_callback_array3.phpt | 39 | ||||
-rw-r--r-- | ext/pcre/tests/preg_replace_callback_array4.phpt | 40 |
4 files changed, 158 insertions, 0 deletions
diff --git a/ext/pcre/tests/preg_replace_callback_array.phpt b/ext/pcre/tests/preg_replace_callback_array.phpt new file mode 100644 index 0000000000..04ee8465ea --- /dev/null +++ b/ext/pcre/tests/preg_replace_callback_array.phpt @@ -0,0 +1,39 @@ +--TEST-- +preg_replace_callback_array() +--FILE-- +<?php + +function f() { + throw new Exception(); +} + +try { +var_dump(preg_replace_callback_array(array('/\w/' => 'f'), 'z')); +} catch(Exception $e) {} + +function g($x) { + return "'$x[0]'"; +} + +var_dump(preg_replace_callback_array(array('@\b\w{1,2}\b@' => 'g'), array('a b3 bcd', 'v' => 'aksfjk', 12 => 'aa bb'))); + +var_dump(preg_replace_callback_array(array('~\A.~' => 'g'), array(array('xyz')))); + +var_dump(preg_replace_callback_array(array('~\A.~' => create_function('$m', 'return strtolower($m[0]);')), 'ABC')); +?> +--EXPECTF-- +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_callback_array.php on line %d +array(1) { + [0]=> + string(7) "'A'rray" +} +string(3) "aBC" diff --git a/ext/pcre/tests/preg_replace_callback_array2.phpt b/ext/pcre/tests/preg_replace_callback_array2.phpt new file mode 100644 index 0000000000..dc6cbde85c --- /dev/null +++ b/ext/pcre/tests/preg_replace_callback_array2.phpt @@ -0,0 +1,40 @@ +--TEST-- +preg_replace_callback_array() 2 +--FILE-- +<?php + +var_dump(preg_replace_callback_array()); +var_dump(preg_replace_callback_array(1)); +var_dump(preg_replace_callback_array(1,2)); +var_dump(preg_replace_callback_array(1,2,3)); +$a = 5; +var_dump(preg_replace_callback_array(1,2,3,$a)); +$a = ""; +var_dump(preg_replace_callback_array(array("" => ""),"","",$a)); +$a = array(); +var_dump(preg_replace_callback($a,$a,$a,$a)); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: preg_replace_callback_array() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: preg_replace_callback_array() expects at least 2 parameters, 1 given in %s on line %d +NULL + +Warning: preg_replace_callback_array() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: preg_replace_callback_array() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: preg_replace_callback_array() expects parameter 1 to be array, integer given in %s on line %d +NULL + +Warning: preg_replace_callback_array() expects parameter 3 to be integer, string given in %s on line %d +NULL + +Warning: preg_replace_callback() expects parameter 4 to be integer, array given in %s on line %d +NULL +Done diff --git a/ext/pcre/tests/preg_replace_callback_array3.phpt b/ext/pcre/tests/preg_replace_callback_array3.phpt new file mode 100644 index 0000000000..b0834327ff --- /dev/null +++ b/ext/pcre/tests/preg_replace_callback_array3.phpt @@ -0,0 +1,39 @@ +--TEST-- +preg_replace_callback_array() 3 +--FILE-- +<?php +$code = "test-EXECUTE_DATA-xcvxcv-ZEND_VM_DISPATCH_TO_HELPER"; + +$code = preg_replace_callback_array( + array( + "/EXECUTE_DATA/m" => function($matches) { return "execute_data";}, + "/ZEND_VM_DISPATCH_TO_HANDLER/m" => function($matches) { return "handler"; }, + "/ZEND_VM_DISPATCH_TO_HELPER/m" => function($matches) { return "helper"; }, + "/ZEND_VM_DISPATCH_TO_HELPER_EX/m" => function($matches) { return "helper_ex"; }, + ), + $code); + +var_dump($code); +$code = array("test-EXECUTE_DATA-ZEND_VM_DISPATCH_TO_HELPER_EX-test", + "test-sdf-xcvxcv-ZEND_VM_DISPATCH_TO_HELPER_EX-test-EXECUTE_DATA-test"); + +$code = preg_replace_callback_array( + array( + "/EXECUTE_DATA/m" => function($matches) { return "execute_data";}, + "/ZEND_VM_DISPATCH_TO_HANDLER/m" => function($matches) { return "handler"; }, + "/ZEND_VM_DISPATCH_TO_HELPER/m" => function($matches) { return "helper"; }, + ), + $code, -1, $count); + +var_dump($code, $count); + +?> +--EXPECTF-- +string(31) "test-execute_data-xcvxcv-helper" +array(2) { + [0]=> + string(32) "test-execute_data-helper_EX-test" + [1]=> + string(48) "test-sdf-xcvxcv-helper_EX-test-execute_data-test" +} +int(4) diff --git a/ext/pcre/tests/preg_replace_callback_array4.phpt b/ext/pcre/tests/preg_replace_callback_array4.phpt new file mode 100644 index 0000000000..12065ab36b --- /dev/null +++ b/ext/pcre/tests/preg_replace_callback_array4.phpt @@ -0,0 +1,40 @@ +--TEST-- +preg_replace_callback_array() 4 +--FILE-- +<?php +$code = "test-EXECUTE_DATA-xcvxcv-ZEND_VM_DISPATCH_TO_HELPER"; + +$code = preg_replace_callback_array( + array( + "/EXECUTE_DATA/m" => function($matches) { return "execute_data";}, + "/ZEND_VM_DISPATCH_TO_HANDLER/m" => function($matches) { return "handler"; }, + "/ZEND_VM_DISPATCH_TO_HELPER/m" => function($matches) { return "helper"; }, + "/ZEND_VM_DISPATCH_TO_HELPER_EX/m" => function($matches) { return "helper_ex"; }, + ), + $code); + +var_dump($code); +$code = array("test-EXECUTE_DATA-ZEND_VM_DISPATCH_TO_HELPER_EX-test", + "test-sdf-xcvxcv-ZEND_VM_DISPATCH_TO_HELPER_EX-test-EXECUTE_DATA-test"); + +$code = preg_replace_callback_array( + array( + "/ZEND_VM_DISPATCH_TO_HANDLER/m" => function($matches) { return "handler"; }, + 23234 => function($matches) { return "execute_data";}, + "/ZEND_VM_DISPATCH_TO_HELPER/m" => function($matches) { return "helper"; }, + ), + $code, -1, $count); + +var_dump($code, $count); +?> +--EXPECTF-- +string(31) "test-execute_data-xcvxcv-helper" + +Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric or backslash in %s on line %d +array(2) { + [0]=> + string(52) "test-EXECUTE_DATA-ZEND_VM_DISPATCH_TO_HELPER_EX-test" + [1]=> + string(68) "test-sdf-xcvxcv-ZEND_VM_DISPATCH_TO_HELPER_EX-test-EXECUTE_DATA-test" +} +int(0) |