Annotation of embedaddon/php/ext/pcre/tests/preg_match_error1.phpt, revision 1.1.1.2

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

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