5 unshift @INC, '../lib';
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
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 before {#} mark in regex m/[[=foo=]{#}]/',
31 '/(?<= .*)/' => 'Variable length lookbehind not implemented before {#} mark in regex m/(?<= .*){#}/',
33 '/(?<= x{1000})/' => 'Lookbehind longer than 255 not implemented before {#} mark in regex m/(?<= x{1000}){#}/',
35 '/(?@)/' => 'Sequence (?@...) not implemented before {#} mark in regex m/(?@{#})/',
37 '/(?{ 1/' => 'Sequence (?{...}) not terminated or not {}-balanced before {#} mark in regex m/(?{{#} 1/',
39 '/(?(1x))/' => 'Switch condition not recognized before {#} mark in regex m/(?(1x{#}))/',
41 '/(?(1)x|y|z)/' => 'Switch (?(condition)... contains too many branches before {#} mark in regex m/(?(1)x|y|{#}z)/',
43 '/(?(x)y|x)/' => 'Unknown switch condition (?(x) before {#} mark in regex m/(?({#}x)y|x)/',
45 '/(?/' => 'Sequence (? incomplete before {#} mark in regex m/(?{#}/',
47 '/(?;x/' => 'Sequence (?;...) not recognized before {#} mark in regex m/(?;{#}x/',
48 '/(?<;x/' => 'Sequence (?<;...) not recognized before {#} mark in regex m/(?<;{#}x/',
50 '/((x)/' => 'Unmatched ( before {#} mark in regex m/({#}(x)/',
52 "/x{$inf_p1}/" => "Quantifier in {,} bigger than $inf_m1 before {#} mark in regex m/x{{#}$inf_p1}/",
54 '/x{3,1}/' => 'Can\'t do {n,m} with n > m before {#} mark in regex m/x{3,1}{#}/',
56 '/x**/' => 'Nested quantifiers before {#} mark in regex m/x**{#}/',
58 '/x[/' => 'Unmatched [ before {#} mark in regex m/x[{#}/',
60 '/*/', => 'Quantifier follows nothing before {#} mark in regex m/*{#}/',
62 '/\p{x/' => 'Missing right brace on \p{} before {#} mark in regex m/\p{{#}x/',
64 'use utf8; /[\p{x]/' => 'Missing right brace on \p{} before {#} mark in regex m/[\p{{#}x]/',
66 '/(x)\2/' => 'Reference to nonexistent group before {#} mark in regex m/(x)\2{#}/',
68 'my $m = chr(92); $m =~ $m', => 'Trailing \ in regex m/\/',
70 '/\x{1/' => 'Missing right brace on \x{} before {#} mark in regex m/\x{{#}1/',
72 'use utf8; /[\x{X]/' => 'Missing right brace on \x{} before {#} mark in regex m/[\x{{#}X]/',
74 '/\x{x}/' => 'Can\'t use \x{} without \'use utf8\' declaration before {#} mark in regex m/\x{x}{#}/',
76 '/[[:barf:]]/' => 'POSIX class [:barf:] unknown before {#} mark in regex m/[[:barf:]{#}]/',
78 '/[[=barf=]]/' => 'POSIX syntax [= =] is reserved for future extensions before {#} mark in regex m/[[=barf=]{#}]/',
80 '/[[.barf.]]/' => 'POSIX syntax [. .] is reserved for future extensions before {#} mark in regex m/[[.barf.]{#}]/',
82 '/[z-a]/' => 'Invalid [] range "z-a" before {#} mark in regex m/[z-a{#}]/',
86 ## Key-value pairs of code/error of code that should have non-fatal warnings.
89 "m/(?p{ 'a' })/" => "(?p{}) is deprecated - use (??{}) before {#} mark in regex m/(?p{#}{ 'a' })/",
91 'm/\b*/' => '\b* matches null string many times before {#} mark in regex m/\b*{#}/',
93 'm/[:blank:]/' => 'POSIX syntax [: :] belongs inside character classes before {#} mark in regex m/[:blank:]{#}/',
95 "m'[\\y]'" => 'Unrecognized escape \y in character class passed through before {#} mark in regex m/[\y{#}]/',
97 'm/[a-\d]/' => 'False [] range "a-\d" before {#} mark in regex m/[a-\d{#}]/',
98 'm/[\w-x]/' => 'False [] range "\w-" before {#} mark in regex m/[\w-{#}x]/',
99 "m'\\y'" => 'Unrecognized escape \y passed through before {#} mark in regex m/\y{#}/',
102 my $total = (@death + @warning)/2;
111 my $regex = shift @death;
112 my $result = shift @death;
117 print "# oops, $regex didn't die\nnot ok $count\n";
121 $result =~ s/{\#}/$marker1/;
122 $result =~ s/{\#}/$marker2/;
123 if ($@ !~ /^\Q$result/) {
124 print "# For $regex, expected:\n# $result\n# Got:\n# $@\n#\nnot ";
131 $SIG{__WARN__} = sub { $warning = shift };
136 my $regex = shift @warning;
137 my $result = shift @warning;
145 print "# oops, $regex died with:\n#\t$@#\nnot ok $count\n";
151 print "# oops, $regex didn't generate a warning\nnot ok $count\n";
154 $result =~ s/{\#}/$marker1/;
155 $result =~ s/{\#}/$marker2/;
156 if ($warning !~ /^\Q$result/)
159 # For $regex, expected: