Skip to content

Commit

Permalink
Add compatability on regex checking
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Dec 1, 2024
1 parent e4b20eb commit e56e1f3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions t/build_regex.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ use Test::More tests => 12;
use App::Ack;


# Note: All of the expected strings have to be in the format before Perl 5.14.
# The _check() function does the transformation.
# Old style: (?m-xis:blah.*)
# New style: (?^m:blah.*)
PLAIN: {
_check(
'foo',
Expand Down Expand Up @@ -131,6 +135,16 @@ sub _check {

my ($match, $scan) = App::Ack::build_regex( $str, $opt );

if ( "$]" ge '5.014' ) {
# Passed in expressions are in Perl 5.10 format. If we are running newer
# than that, convert the expected string representations.
for my $re ( $exp_match, $exp_scan ) {
if ( defined($re) ) {
$re =~ s/^\(\?([xism]*)-[xism]*:/(?^$1:/;
}
}
}

is( $match, $exp_match, 'match matches' );
is( $scan, $exp_scan, 'scan matches' );
};
Expand Down

0 comments on commit e56e1f3

Please sign in to comment.