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
16 my $marker1 = "<HERE<";
17 my $marker2 = " <<<HERE<<< ";
20 ## Key-value pairs of code/error of code that should have fatal errors.
24 '/[[=foo=]]/' => 'POSIX syntax [= =] is reserved for future extensions at {#} mark in regex m/[[=foo=]{#}]/',
26 '/(?<= .*)/' => 'Variable length lookbehind not implemented at {#} mark in regex m/(?<= .*){#}/',
28 '/(?<= x{10000})/' => 'Lookbehind longer than 255 not implemented at {#} mark in regex m/(?<= x{10000}){#}/',
30 '/(?@)/' => 'Sequence (?@...) not implemented at {#} mark in regex m/(?@{#})/',
32 '/(?{ 1/' => 'Sequence (?{...}) not terminated or not {}-balanced at {#} mark in regex m/(?{{#} 1/',
34 '/(?(1x))/' => 'Switch condition not recognized at {#} mark in regex m/(?(1x{#}))/',
36 '/(?(1)x|y|z)/' => 'Switch (?(condition)... contains too many branches at {#} mark in regex m/(?(1)x|y|{#}z)/',
38 '/(?(x)y|x)/' => 'Unknown switch condition (?(x) at {#} mark in regex m/(?({#}x)y|x)/',
40 '/(?/' => 'Sequence (? incomplete at {#} mark in regex m/(?{#}/',
42 '/(?;x/' => 'Sequence (?;...) not recognized at {#} mark in regex m/(?;{#}x/',
43 '/(?<;x/' => 'Sequence (?<;...) not recognized at {#} mark in regex m/(?<;{#}x/',
45 '/((x)/' => 'Unmatched ( at {#} mark in regex m/({#}(x)/',
47 '/x{99999}/' => 'Quantifier in {,} bigger than 32766 at {#} mark in regex m/x{{#}99999}/',
49 '/x{3,1}/' => 'Can\'t do {n,m} with n > m at {#} mark in regex m/x{3,1}{#}/',
51 '/x**/' => 'Nested quantifiers at {#} mark in regex m/x**{#}/',
53 '/x[/' => 'Unmatched [ at {#} mark in regex m/x[{#}/',
55 '/*/', => 'Quantifier follows nothing at {#} mark in regex m/*{#}/',
57 '/\p{x/' => 'Missing right brace on \p{} at {#} mark in regex m/\p{{#}x/',
59 'use utf8; /[\p{x]/' => 'Missing right brace on \p{} at {#} mark in regex m/[\p{{#}x]/',
61 '/(x)\2/' => 'Reference to nonexistent group at {#} mark in regex m/(x)\2{#}/',
63 'my $m = chr(92); $m =~ $m', => 'Trailing \ in regex m/\/',
65 '/\x{1/' => 'Missing right brace on \x{} at {#} mark in regex m/\x{{#}1/',
67 'use utf8; /[\x{X]/' => 'Missing right brace on \x{} at {#} mark in regex m/[\x{{#}X]/',
69 '/\x{x}/' => 'Can\'t use \x{} without \'use utf8\' declaration at {#} mark in regex m/\x{x}{#}/',
71 '/[[:barf:]]/' => 'POSIX class [:barf:] unknown at {#} mark in regex m/[[:barf:]{#}]/',
73 '/[[=barf=]]/' => 'POSIX syntax [= =] is reserved for future extensions at {#} mark in regex m/[[=barf=]{#}]/',
75 '/[[.barf.]]/' => 'POSIX syntax [. .] is reserved for future extensions at {#} mark in regex m/[[.barf.]{#}]/',
77 '/[z-a]/' => 'Invalid [] range "z-a" at {#} mark in regex m/[z-a{#}]/',
81 ## Key-value pairs of code/error of code that should have non-fatal warnings.
84 "m/(?p{ 'a' })/" => "(?p{}) is deprecated - use (??{}) at {#} mark in regex m/(?p{#}{ 'a' })/",
86 'm/\b*/' => '\b* matches null string many times at {#} mark in regex m/\b*{#}/',
88 'm/[:blank:]/' => 'POSIX syntax [: :] belongs inside character classes at {#} mark in regex m/[:blank:]{#}/',
90 "m'[\\y]'" => 'Unrecognized escape \y in character class passed through at {#} mark in regex m/[\y{#}]/',
92 'm/[a-\d]/' => 'False [] range "a-\d" at {#} mark in regex m/[a-\d{#}]/',
93 'm/[\w-x]/' => 'False [] range "\w-" at {#} mark in regex m/[\w-{#}x]/',
94 "m'\\y'" => 'Unrecognized escape \y passed through at {#} mark in regex m/\y{#}/',
97 my $total = (@death + @warning)/2;
106 my $regex = shift @death;
107 my $result = shift @death;
114 print "oops, $regex didn't die\n"
116 print "not ok $count\n";
121 $@ =~ s/ at \(.*?\) line \d+\.$//;
122 $result =~ s/{\#}/$marker1/;
123 $result =~ s/{\#}/$marker2/;
126 print "For $regex, expected:\n $result\nGot:\n $@\n\n";
128 print "not ok $count\n";
137 $SIG{__WARN__} = sub { $warning = shift };
142 my $regex = shift @warning;
143 my $result = shift @warning;
152 print "oops, $regex died with:\n\t$@\n";
154 print "not ok $count\n";
162 print "oops, $regex didn't generate a warning\n";
164 print "not ok $count\n";
169 $warning =~ s/ at \(.*?\) line \d+\.$//;
170 $result =~ s/{\#}/$marker1/;
171 $result =~ s/{\#}/$marker2/;
172 if ($warning ne $result)
175 print "For $regex, expected:\n $result\nGot:\n $warning\n\n";
177 print "not ok $count\n";