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

1.1       misho       1: --TEST--
                      2: Test preg_grep() function : error conditions - bad regular expressions
                      3: --FILE--
                      4: <?php
                      5: /*
                      6: * proto array preg_grep(string regex, array input [, 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_grep reacts to being passed bad regexes
                     12: */
                     13: echo "*** Testing preg_grep() : error conditions ***\n";
                     14: $values = 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: $array = array(123, 'abc', 'test');
                     21: foreach($values as $value) {
                     22:     print "\nArg value is $value\n";
                     23:     var_dump(preg_grep($value, $array));
                     24: }
                     25: $value = new stdclass(); //Object
                     26: var_dump(preg_grep($value, $array));
                     27: echo "Done"
                     28: ?>
                     29: --EXPECTF--
                     30: 
                     31: *** Testing preg_grep() : error conditions ***
                     32: 
                     33: Arg value is abcdef
                     34: 
                     35: Warning: preg_grep(): Delimiter must not be alphanumeric or backslash in %spreg_grep_error1.php on line %d
                     36: bool(false)
                     37: 
                     38: Arg value is /[a-zA-Z]
                     39: 
                     40: Warning: preg_grep(): No ending delimiter '/' found in %spreg_grep_error1.php on line %d
                     41: bool(false)
                     42: 
                     43: Arg value is [a-zA-Z]/
                     44: 
                     45: Warning: preg_grep(): Unknown modifier '/' in %spreg_grep_error1.php on line %d
                     46: bool(false)
                     47: 
                     48: Arg value is /[a-zA-Z]/F
                     49: 
                     50: Warning: preg_grep(): Unknown modifier 'F' in %spreg_grep_error1.php on line %d
                     51: bool(false)
                     52: 
                     53: Arg value is Array
                     54: 
                     55: Warning: preg_grep() expects parameter 1 to be string, array given in %spreg_grep_error1.php on line %d
                     56: NULL
                     57: 
                     58: Arg value is /[a-zA-Z]/
                     59: array(2) {
                     60:   [1]=>
                     61:   string(3) "abc"
                     62:   [2]=>
                     63:   string(4) "test"
                     64: }
                     65: 
                     66: Warning: preg_grep() expects parameter 1 to be string, object given in %spreg_grep_error1.php on line %d
                     67: NULL
                     68: Done

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