11 ## If the markers used are changed (search for "MARKER1" in regcomp.c),
12 ## update only these two variables, and leave the {#} in the @death/@warning
13 ## arrays below. The {#} is a meta-marker -- it marks where the marker should
16 my $marker1 = "<-- HERE";
17 my $marker2 = " <-- HERE ";
20 ## Key-value pairs of code/error of code that should have fatal errors.
23 eval 'use Config'; # assume defaults if fail
25 my $inf_m1 = ($Config{reg_infty} || 32767) - 1;
26 my $inf_p1 = $inf_m1 + 2;
29 '/[[=foo=]]/' => 'POSIX syntax [= =] is reserved for future extensions in regex; marked by {#} in m/[[=foo=]{#}]/',
31 '/(?<= .*)/' => 'Variable length lookbehind not implemented in regex; marked by {#} in m/(?<= .*){#}/',
33 '/(?<= x{1000})/' => 'Lookbehind longer than 255 not implemented in regex; marked by {#} in m/(?<= x{1000}){#}/',
35 '/(?@)/' => 'Sequence (?@...) not implemented in regex; marked by {#} in m/(?@{#})/',
37 '/(?{ 1/' => 'Sequence (?{...}) not terminated or not {}-balanced in regex; marked by {#} in m/(?{{#} 1/',
39 '/(?(1x))/' => 'Switch condition not recognized in regex; marked by {#} in m/(?(1x{#}))/',
41 '/(?(1)x|y|z)/' => 'Switch (?(condition)... contains too many branches in regex; marked by {#} in m/(?(1)x|y|{#}z)/',
43 '/(?(x)y|x)/' => 'Unknown switch condition (?(x) in regex; marked by {#} in m/(?({#}x)y|x)/',
45 '/(?/' => 'Sequence (? incomplete in regex; marked by {#} in m/(?{#}/',
47 '/(?;x/' => 'Sequence (?;...) not recognized in regex; marked by {#} in m/(?;{#}x/',
48 '/(?<;x/' => 'Sequence (?<;...) not recognized in regex; marked by {#} in m/(?<;{#}x/',
50 '/((x)/' => 'Unmatched ( in regex; marked by {#} in m/({#}(x)/',
52 "/x{$inf_p1}/" => "Quantifier in {,} bigger than $inf_m1 in regex; marked by {#} in m/x{{#}$inf_p1}/",
54 '/x{3,1}/' => 'Can\'t do {n,m} with n > m in regex; marked by {#} in m/x{3,1}{#}/',
56 '/x**/' => 'Nested quantifiers in regex; marked by {#} in m/x**{#}/',
58 '/x[/' => 'Unmatched [ in regex; marked by {#} in m/x[{#}/',
60 '/*/', => 'Quantifier follows nothing in regex; marked by {#} in m/*{#}/',
62 '/\p{x/' => 'Missing right brace on \p{} in regex; marked by {#} in m/\p{{#}x/',
64 '/[\p{x]/' => 'Missing right brace on \p{} in regex; marked by {#} in m/[\p{{#}x]/',
66 '/(x)\2/' => 'Reference to nonexistent group in regex; marked by {#} in m/(x)\2{#}/',
68 'my $m = "\\\"; $m =~ $m', => 'Trailing \ in regex m/\/',
70 '/\x{1/' => 'Missing right brace on \x{} in regex; marked by {#} in m/\x{{#}1/',
72 '/[\x{X]/' => 'Missing right brace on \x{} in regex; marked by {#} in m/[\x{{#}X]/',
74 '/[[:barf:]]/' => 'POSIX class [:barf:] unknown in regex; marked by {#} in m/[[:barf:]{#}]/',
76 '/[[=barf=]]/' => 'POSIX syntax [= =] is reserved for future extensions in regex; marked by {#} in m/[[=barf=]{#}]/',
78 '/[[.barf.]]/' => 'POSIX syntax [. .] is reserved for future extensions in regex; marked by {#} in m/[[.barf.]{#}]/',
80 '/[z-a]/' => 'Invalid [] range "z-a" in regex; marked by {#} in m/[z-a{#}]/',
82 '/\p/' => 'Empty \p{} in regex; marked by {#} in m/\p{#}/',
84 '/\P{}/' => 'Empty \P{} in regex; marked by {#} in m/\P{{#}}/',
88 ## Key-value pairs of code/error of code that should have non-fatal warnings.
91 "m/(?p{ 'a' })/" => "(?p{}) is deprecated - use (??{}) in regex; marked by {#} in m/(?p{#}{ 'a' })/",
93 'm/\b*/' => '\b* matches null string many times in regex; marked by {#} in m/\b*{#}/',
95 'm/[:blank:]/' => 'POSIX syntax [: :] belongs inside character classes in regex; marked by {#} in m/[:blank:]{#}/',
97 "m'[\\y]'" => 'Unrecognized escape \y in character class passed through in regex; marked by {#} in m/[\y{#}]/',
99 'm/[a-\d]/' => 'False [] range "a-\d" in regex; marked by {#} in m/[a-\d{#}]/',
100 'm/[\w-x]/' => 'False [] range "\w-" in regex; marked by {#} in m/[\w-{#}x]/',
101 'm/[a-\pM]/' => 'False [] range "a-\pM" in regex; marked by {#} in m/[a-\pM{#}]/',
102 'm/[\pM-x]/' => 'False [] range "\pM-" in regex; marked by {#} in m/[\pM-{#}x]/',
103 "m'\\y'" => 'Unrecognized escape \y passed through in regex; marked by {#} in m/\y{#}/',
106 my $total = (@death + @warning)/2;
108 # utf8 is a noop on EBCDIC platforms, it is not fatal
109 my $Is_EBCDIC = (ord('A') == 193);
111 my @utf8_death = grep(/utf8/, @death);
112 $total = $total - @utf8_death;
121 my $regex = shift @death;
122 my $result = shift @death;
123 # skip the utf8 test on EBCDIC since they do not die
124 next if ($Is_EBCDIC && $regex =~ /utf8/);
130 print "# oops, $regex didn't die\nnot ok $count\n";
134 $result =~ s/{\#}/$marker1/;
135 $result =~ s/{\#}/$marker2/;
137 if ($@ !~ /^\Q$result/) {
138 print "# For $regex, expected:\n# $result\n# Got:\n# $@\n#\nnot ";
140 print "ok $count - $regex\n";
145 $SIG{__WARN__} = sub { $warning = shift };
150 my $regex = shift @warning;
151 my $result = shift @warning;
159 print "# oops, $regex died with:\n#\t$@#\nnot ok $count\n";
165 print "# oops, $regex didn't generate a warning\nnot ok $count\n";
168 $result =~ s/{\#}/$marker1/;
169 $result =~ s/{\#}/$marker2/;
171 if ($warning !~ /^\Q$result/)
174 # For $regex, expected:
183 print "ok $count - $regex\n";