Annotation of embedaddon/php/ext/pcre/tests/preg_match_all_error1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test preg_match_all() function : error conditions - bad regular expressions
! 3: --FILE--
! 4: <?php
! 5: /*
! 6: * proto int preg_match_all(string pattern, string subject, array subpatterns [, int flags [, int offset]])
! 7: * Function is implemented in ext/pcre/php_pcre.c
! 8: */
! 9: error_reporting(E_ALL&~E_NOTICE);
! 10: /*
! 11: * Testing how preg_match_all reacts to being passed the wrong type of regex argument
! 12: */
! 13: echo "*** Testing preg_match_all() : error conditions ***\n";
! 14: $regex_array = array('abcdef', //Regex without delimeter
! 15: '/[a-zA-Z]', //Regex without closing delimeter
! 16: '[a-zA-Z]/', //Regex without opening delimeter
! 17: '/[a-zA-Z]/F', array('[a-z]', //Array of Regexes
! 18: '[A-Z]', '[0-9]'), '/[a-zA-Z]/', //Regex string
! 19: );
! 20: $subject = 'test';
! 21: foreach($regex_array as $regex_value) {
! 22: print "\nArg value is $regex_value\n";
! 23: var_dump(preg_match_all($regex_value, $subject, $matches1));
! 24: var_dump($matches1);
! 25: }
! 26: $regex_value = new stdclass(); //Object
! 27: var_dump(preg_match_all($regex_value, $subject, $matches));
! 28: var_dump($matches);
! 29: ?>
! 30: --EXPECTF--
! 31: *** Testing preg_match_all() : error conditions ***
! 32:
! 33: Arg value is abcdef
! 34:
! 35: Warning: preg_match_all(): Delimiter must not be alphanumeric or backslash in %spreg_match_all_error1.php on line %d
! 36: bool(false)
! 37: NULL
! 38:
! 39: Arg value is /[a-zA-Z]
! 40:
! 41: Warning: preg_match_all(): No ending delimiter '/' found in %spreg_match_all_error1.php on line %d
! 42: bool(false)
! 43: NULL
! 44:
! 45: Arg value is [a-zA-Z]/
! 46:
! 47: Warning: preg_match_all(): Unknown modifier '/' in %spreg_match_all_error1.php on line %d
! 48: bool(false)
! 49: NULL
! 50:
! 51: Arg value is /[a-zA-Z]/F
! 52:
! 53: Warning: preg_match_all(): Unknown modifier 'F' in %spreg_match_all_error1.php on line %d
! 54: bool(false)
! 55: NULL
! 56:
! 57: Arg value is Array
! 58:
! 59: Warning: preg_match_all() expects parameter 1 to be string, array given in %spreg_match_all_error1.php on line %d
! 60: bool(false)
! 61: NULL
! 62:
! 63: Arg value is /[a-zA-Z]/
! 64: int(4)
! 65: array(1) {
! 66: [0]=>
! 67: array(4) {
! 68: [0]=>
! 69: string(1) "t"
! 70: [1]=>
! 71: string(1) "e"
! 72: [2]=>
! 73: string(1) "s"
! 74: [3]=>
! 75: string(1) "t"
! 76: }
! 77: }
! 78:
! 79: Warning: preg_match_all() expects parameter 1 to be string, object given in %spreg_match_all_error1.php on line %d
! 80: bool(false)
! 81: NULL
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>