xref: /php-src/ext/pcre/tests/grep2.phpt (revision 598175ef)
1--TEST--
2preg_grep() 2nd test
3--SKIPIF--
4<?php if (!PCRE_JIT_SUPPORT) die("skip no pcre jit support"); ?>
5--INI--
6pcre.jit=1
7--FILE--
8<?php
9
10var_dump(preg_grep('/+/', array()));
11
12$array = array(5=>'a', 'x' => '1', 'xyz'=>'q6', 'h20');
13
14var_dump(preg_grep('@^[a-z]+@', $array));
15var_dump(preg_grep('@^[a-z]+@', $array, PREG_GREP_INVERT));
16
17ini_set('pcre.recursion_limit', 1);
18var_dump(preg_last_error() == PREG_NO_ERROR);
19var_dump(preg_grep('@^[a-z]+@', $array));
20var_dump(preg_last_error() == PREG_RECURSION_LIMIT_ERROR);
21
22?>
23--EXPECTF--
24Warning: preg_grep(): Compilation failed: quantifier does not follow a repeatable item at offset 0 in %sgrep2.php on line %d
25bool(false)
26array(3) {
27  [5]=>
28  string(1) "a"
29  ["xyz"]=>
30  string(2) "q6"
31  [6]=>
32  string(3) "h20"
33}
34array(1) {
35  ["x"]=>
36  string(1) "1"
37}
38bool(true)
39array(3) {
40  [5]=>
41  string(1) "a"
42  ["xyz"]=>
43  string(2) "q6"
44  [6]=>
45  string(3) "h20"
46}
47bool(false)
48