Annotation of embedaddon/php/ext/pcre/tests/preg_split_error1.phpt, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>