| 1 | ## no critic: ValuesAndExpressions::ProhibitCommaSeparatedStatements BuiltinFunctions::RequireBlockMap | |||||||||||||||||||||||||||||||||
| 2 | ||||||||||||||||||||||||||||||||||
| 3 | package Test::Regexp::Pattern; | |||||||||||||||||||||||||||||||||
| 4 | ||||||||||||||||||||||||||||||||||
| 5 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | ||||||||||||||||||||||||||||||||
| 6 | 1 | our $DATE = '2022-07-24'; # DATE | ||||||||||||||||||||||||||||||||
| 7 | 1 | our $DIST = 'Test-Regexp-Pattern'; # DIST | ||||||||||||||||||||||||||||||||
| 8 | 1 | our $VERSION = '0.010'; # VERSION | ||||||||||||||||||||||||||||||||
| 9 | ||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use 5.010001; | |||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use strict 'subs', 'vars'; | |||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use warnings; | |||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||
| 13 | ||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use File::Spec; | |||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Hash::DefHash; # exports defhash() | |||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Regexp::Pattern qw(re); | |||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Test::Builder; | |||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Test::More (); | |||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||
| 19 | ||||||||||||||||||||||||||||||||||
| 20 | 1 | my $Test = Test::Builder->new; | ||||||||||||||||||||||||||||||||
| 21 | ||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub import { | |||||||||||||||||||||||||||||||
|
Subroutine
import: not called CC=1 SCAR=3.3
| ||||||||||||||||||||||||||||||||||
| 23 | 0 | my $self = shift; | ||||||||||||||||||||||||||||||||
| 24 | 0 | my $caller = caller; | ||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | no strict 'refs'; | |||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||
| 26 | 0 | *{$caller.'::regexp_patterns_in_module_ok'} = \®exp_patterns_in_module_ok; | ||||||||||||||||||||||||||||||||
| 27 | 0 | *{$caller.'::regexp_patterns_in_all_modules_ok'} = \®exp_patterns_in_all_modules_ok; | ||||||||||||||||||||||||||||||||
| 28 | ||||||||||||||||||||||||||||||||||
| 29 | 0 | $Test->exported_to($caller); | ||||||||||||||||||||||||||||||||
| 30 | 0 | $Test->plan(@_); | ||||||||||||||||||||||||||||||||
| 31 | } | |||||||||||||||||||||||||||||||||
| 32 | ||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub _test_regexp_pattern { | |||||||||||||||||||||||||||||||
|
Subroutine
_test_regexp_pattern: not called CC=13 SCAR=52.0
| ||||||||||||||||||||||||||||||||||
| 34 | 0 | my ($re, $parent, $fqname, $opts) = @_; | ||||||||||||||||||||||||||||||||
| 35 | 0 | my $ok = 1; | ||||||||||||||||||||||||||||||||
| 36 | ||||||||||||||||||||||||||||||||||
| 37 | GENERAL: { | |||||||||||||||||||||||||||||||||
| 38 | 0 | my $dh; | ||||||||||||||||||||||||||||||||
| 39 | 0 | eval { $dh = Hash::DefHash->new($re, parent=>$parent); 1 }; | ||||||||||||||||||||||||||||||||
| 40 | 0 | my $eval_err = $@; | ||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | $Test->ok(!$eval_err, "Must be a valid defhash") or do { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 42 | 0 | $Test->diag("error in defhash check: $eval_err"); | ||||||||||||||||||||||||||||||||
| 43 | 0 | $ok = 0; | ||||||||||||||||||||||||||||||||
| 44 | }; | |||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | $Test->ok(($re->{pat} xor $re->{gen}), "Must declare pat OR gen but not both") or $ok = 0; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/4
$re->{"pat"} ^^ $re->{"gen"}
MC/DC0%0/2
$re->{"pat"} ^^ $re->{"gen"}
$re->{"pat"}
$re->{"gen"}
Truth table0%0/4
A ^^ B
A= $re->{"pat"}B= $re->{"gen"}
| ||||||||||||||||||||||||||||||||||
| 46 | } | |||||||||||||||||||||||||||||||||
| 47 | ||||||||||||||||||||||||||||||||||
| 48 | EXAMPLES: { | |||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | last unless $opts->{test_examples} && $re->{examples}; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opts->{"test_examples"} and $re->{"examples"}
MC/DC0%0/2
$opts->{"test_examples"} and $re->{"examples"}
$opts->{"test_examples"}
$re->{"examples"}
Truth table0%0/3
A and B
A= $opts->{"test_examples"}B= $re->{"examples"}
| ||||||||||||||||||||||||||||||||||
| 50 | 0 | my $i = 0; | ||||||||||||||||||||||||||||||||
| 51 | 0 | for my $eg (@{ $re->{examples} }) { | ||||||||||||||||||||||||||||||||
| 52 | 0 | $i++; | ||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | next unless $eg->{test} // 1; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$eg->{"test"} // 1
MC/DC0%0/1
$eg->{"test"} // 1
$eg->{"test"}
Truth table0%0/2
A
A= $eg->{"test"}
| ||||||||||||||||||||||||||||||||||
| 54 | $Test->subtest( | |||||||||||||||||||||||||||||||||
| 55 | "example #$i" . | |||||||||||||||||||||||||||||||||
| 56 | ($eg->{name} ? " ($eg->{name})" : | |||||||||||||||||||||||||||||||||
| 57 | ($eg->{summary} ? " ($eg->{summary})" : | |||||||||||||||||||||||||||||||||
| 58 | (defined $eg->{str} ? " (str $eg->{str})" : | |||||||||||||||||||||||||||||||||
| 59 | ""))), | |||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub { | |||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=22 SCAR=62.3
| ||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $Test->ok(defined($eg->{str}), 'example provides string to match') or do { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 62 | 0 | $ok = 0; | ||||||||||||||||||||||||||||||||
| 63 | 0 | return; | ||||||||||||||||||||||||||||||||
| 64 | }; | |||||||||||||||||||||||||||||||||
| 65 | ||||||||||||||||||||||||||||||||||
| 66 | 0 | my %args; | ||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if ($eg->{gen_args}) { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 68 | 0 | $args{$_} = $eg->{gen_args}{$_} for keys %{$eg->{gen_args}}; | ||||||||||||||||||||||||||||||||
| 69 | } | |||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if (defined $eg->{anchor}) { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 71 | 0 | $args{-anchor} = $eg->{anchor}; | ||||||||||||||||||||||||||||||||
| 72 | } | |||||||||||||||||||||||||||||||||
| 73 | 0 | my $pat = re($fqname, %args); | ||||||||||||||||||||||||||||||||
| 74 | ||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | my $actual_match = $eg->{str} =~ $pat ? 1:0; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if (ref $eg->{matches} eq 'ARRAY') { | |||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||
| 77 | 0 | my $len = @{ $eg->{matches} }; | ||||||||||||||||||||||||||||||||
| 78 | 0 | my @actual_matches; | ||||||||||||||||||||||||||||||||
| 79 | 0 | for (1..$len) { | ||||||||||||||||||||||||||||||||
| 80 | 0 | push @actual_matches, ${$_}; | ||||||||||||||||||||||||||||||||
| 81 | } | |||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | my $should_match = $len ? 1:0; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if ($should_match) { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | $Test->ok( $actual_match, 'string should match') or do { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 85 | 0 | $ok = 0; | ||||||||||||||||||||||||||||||||
| 86 | 0 | return; | ||||||||||||||||||||||||||||||||
| 87 | }; | |||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | Test::More::is_deeply(\@actual_matches, $eg->{matches}, 'matches') or do { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 89 | 0 | $Test->diag($Test->explain(\@actual_matches)); | ||||||||||||||||||||||||||||||||
| 90 | 0 | $ok = 0; | ||||||||||||||||||||||||||||||||
| 91 | }; | |||||||||||||||||||||||||||||||||
| 92 | } else { | |||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | $Test->ok(!$actual_match, 'string should not match') or do { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 94 | 0 | $ok = 0; | ||||||||||||||||||||||||||||||||
| 95 | 0 | return; | ||||||||||||||||||||||||||||||||
| 96 | }; | |||||||||||||||||||||||||||||||||
| 97 | } | |||||||||||||||||||||||||||||||||
| 98 | } elsif (ref $eg->{matches} eq 'HASH') { | |||||||||||||||||||||||||||||||||
| 99 | 0 | my %actual_matches = %+; | ||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | my $should_match = %{ $eg->{matches} } ? 1:0; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if ($should_match) { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | $Test->ok( $actual_match, 'string should match') or do { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 103 | 0 | $ok = 0; | ||||||||||||||||||||||||||||||||
| 104 | 0 | return; | ||||||||||||||||||||||||||||||||
| 105 | }; | |||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | Test::More::is_deeply(\%actual_matches, $eg->{matches}, 'matches') or do { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 107 | 0 | $Test->diag($Test->explain(\%actual_matches)); | ||||||||||||||||||||||||||||||||
| 108 | 0 | $ok = 0; | ||||||||||||||||||||||||||||||||
| 109 | }; | |||||||||||||||||||||||||||||||||
| 110 | } else { | |||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | $Test->ok(!$actual_match, 'string should not match') or do { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 112 | 0 | $ok = 0; | ||||||||||||||||||||||||||||||||
| 113 | 0 | return; | ||||||||||||||||||||||||||||||||
| 114 | }; | |||||||||||||||||||||||||||||||||
| 115 | } | |||||||||||||||||||||||||||||||||
| 116 | } else { | |||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if ($eg->{matches}) { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | $Test->ok( $actual_match, 'string should match') or do { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 119 | 0 | $ok = 0; | ||||||||||||||||||||||||||||||||
| 120 | 0 | return; | ||||||||||||||||||||||||||||||||
| 121 | }; | |||||||||||||||||||||||||||||||||
| 122 | } else { | |||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | $Test->ok(!$actual_match, 'string should not match') or do { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 124 | 0 | $ok = 0; | ||||||||||||||||||||||||||||||||
| 125 | 0 | return; | ||||||||||||||||||||||||||||||||
| 126 | }; | |||||||||||||||||||||||||||||||||
| 127 | } | |||||||||||||||||||||||||||||||||
| 128 | } | |||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | }) or $ok = 0; | |||||||||||||||||||||||||||||||
|
Branch: 4 branches
| ||||||||||||||||||||||||||||||||||
| 130 | } | |||||||||||||||||||||||||||||||||
| 131 | } | |||||||||||||||||||||||||||||||||
| 132 | 0 | $ok; | ||||||||||||||||||||||||||||||||
| 133 | } | |||||||||||||||||||||||||||||||||
| 134 | ||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | sub regexp_patterns_in_module_ok { | |||||||||||||||||||||||||||||||
|
Subroutine
regexp_patterns_in_module_ok: not called CC=6 SCAR=37.4
Pod
documented
| ||||||||||||||||||||||||||||||||||
| 136 | 0 | my $module = shift; | ||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | my %opts = (@_ && (ref $_[0] eq "HASH")) ? %{(shift)} : (); | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ and ref $_[0] eq "HASH"
@_
ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= @_B= ref $_[0] eq "HASH"
| ||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | my $msg = @_ ? shift : "Regexp patterns in module $module"; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 139 | 0 | my $res; | ||||||||||||||||||||||||||||||||
| 140 | 0 | my $ok = 1; | ||||||||||||||||||||||||||||||||
| 141 | ||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $opts{test_examples} //= 1; | |||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"test_examples"} //= 1
MC/DC0%0/1
$opts{"test_examples"} //= 1
$opts{"test_examples"}
Truth table0%0/2
A
A= $opts{"test_examples"}
| ||||||||||||||||||||||||||||||||||
| 143 | ||||||||||||||||||||||||||||||||||
| 144 | 0 | my $has_tests; | ||||||||||||||||||||||||||||||||
| 145 | ||||||||||||||||||||||||||||||||||
| 146 | $Test->subtest( | |||||||||||||||||||||||||||||||||
| 147 | $msg, | |||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | sub { | |||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| ||||||||||||||||||||||||||||||||||
| 149 | 0 | (my $modulepm = "$module.pm") =~ s!::!/!g; | ||||||||||||||||||||||||||||||||
| 150 | 0 | require $modulepm; | ||||||||||||||||||||||||||||||||
| 151 | ||||||||||||||||||||||||||||||||||
| 152 | 0 | my $prefix = ''; | ||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | if ($module =~ /\ARegexp::Pattern::(.+)/) { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 154 | 0 | $prefix = "$1\::"; | ||||||||||||||||||||||||||||||||
| 155 | } else { | |||||||||||||||||||||||||||||||||
| 156 | 0 | goto L1; | ||||||||||||||||||||||||||||||||
| 157 | } | |||||||||||||||||||||||||||||||||
| 158 | ||||||||||||||||||||||||||||||||||
| 159 | 0 | my $RE = \%{ "$module\::RE" }; | ||||||||||||||||||||||||||||||||
| 160 | 0 | my $dh = defhash($RE); | ||||||||||||||||||||||||||||||||
| 161 | 0 | for my $name ($dh->props) { | ||||||||||||||||||||||||||||||||
| 162 | 0 | my $re = $RE->{$name}; | ||||||||||||||||||||||||||||||||
| 163 | 0 | $has_tests++; | ||||||||||||||||||||||||||||||||
| 164 | $Test->subtest( | |||||||||||||||||||||||||||||||||
| 165 | "pattern $prefix$name", | |||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | sub { | |||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| ||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | _test_regexp_pattern($re, $RE, "$prefix$name", \%opts) or $ok = 0; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 168 | }, | |||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | ) or $ok = 0; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 170 | } | |||||||||||||||||||||||||||||||||
| 171 | ||||||||||||||||||||||||||||||||||
| 172 | L1: | |||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | unless ($has_tests) { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 174 | 0 | $Test->ok(1); | ||||||||||||||||||||||||||||||||
| 175 | 0 | $Test->diag("No regexp patterns to test in $modulepm"); | ||||||||||||||||||||||||||||||||
| 176 | } | |||||||||||||||||||||||||||||||||
| 177 | } # subtest | |||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | ) or $ok = 0; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 179 | ||||||||||||||||||||||||||||||||||
| 180 | 0 | $ok; | ||||||||||||||||||||||||||||||||
| 181 | } | |||||||||||||||||||||||||||||||||
| 182 | ||||||||||||||||||||||||||||||||||
| 183 | # BEGIN copy-pasted from Test::Pod::Coverage, with a bit modification | |||||||||||||||||||||||||||||||||
| 184 | ||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | sub all_modules { | |||||||||||||||||||||||||||||||
|
Subroutine
all_modules: not called CC=16 SCAR=56.1
Pod
undocumented
| ||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | my @starters = @_ ? @_ : _starting_points(); | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 187 | 0 | my %starters = map {$_,1} @starters; | ||||||||||||||||||||||||||||||||
| 188 | ||||||||||||||||||||||||||||||||||
| 189 | 0 | my @queue = @starters; | ||||||||||||||||||||||||||||||||
| 190 | ||||||||||||||||||||||||||||||||||
| 191 | 0 | my @modules; | ||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | while ( @queue ) { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 193 | 0 | my $file = shift @queue; | ||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ( -d $file ) { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 195 | 0 | local *DH; | ||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | opendir DH, $file or next; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 197 | 0 | my @newfiles = readdir DH; | ||||||||||||||||||||||||||||||||
| 198 | 0 | closedir DH; | ||||||||||||||||||||||||||||||||
| 199 | ||||||||||||||||||||||||||||||||||
| 200 | 0 | @newfiles = File::Spec->no_upwards( @newfiles ); | ||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | @newfiles = grep { $_ ne "CVS" && $_ ne ".svn" } @newfiles; | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$_ ne 'CVS' && $_ ne '.svn'
MC/DC0%0/2
$_ ne 'CVS' && $_ ne '.svn'
$_ ne 'CVS'
$_ ne '.svn'
Truth table0%0/3
A && B
A= $_ ne 'CVS'B= $_ ne '.svn'
| ||||||||||||||||||||||||||||||||||
| 202 | ||||||||||||||||||||||||||||||||||
| 203 | 0 | push @queue, map "$file/$_", @newfiles; | ||||||||||||||||||||||||||||||||
| 204 | } | |||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ( -f $file ) { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | next unless $file =~ /\.pm$/; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 207 | ||||||||||||||||||||||||||||||||||
| 208 | 0 | my @parts = File::Spec->splitdir( $file ); | ||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | shift @parts if @parts && exists $starters{$parts[0]}; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@parts and exists $starters{$parts[0]}
MC/DC0%0/2
@parts and exists $starters{$parts[0]}
@parts
exists $starters{$parts[0]}
Truth table0%0/3
A and B
A= @partsB= exists $starters{$parts[0]}
| ||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | shift @parts if @parts && $parts[0] eq "lib"; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@parts and $parts[0] eq "lib"
MC/DC0%0/2
@parts and $parts[0] eq "lib"
@parts
$parts[0] eq "lib"
Truth table0%0/3
A and B
A= @partsB= $parts[0] eq "lib"
| ||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | $parts[-1] =~ s/\.pm$// if @parts; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 212 | ||||||||||||||||||||||||||||||||||
| 213 | # Untaint the parts | |||||||||||||||||||||||||||||||||
| 214 | 0 | for ( @parts ) { | ||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | if ( /^([a-zA-Z0-9_\.\-]*)$/ && ($_ eq $1) ) { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
/^([a-zA-Z0-9_\.\-]*)$/ and $_ eq $1
MC/DC0%0/2
/^([a-zA-Z0-9_\.\-]*)$/ and $_ eq $1
/^([a-zA-Z0-9_\.\-]*)$/
$_ eq $1
Truth table0%0/3
A and B
A= /^([a-zA-Z0-9_\.\-]*)$/B= $_ eq $1
| ||||||||||||||||||||||||||||||||||
| 216 | 0 | $_ = $1; # Untaint the original | ||||||||||||||||||||||||||||||||
| 217 | } | |||||||||||||||||||||||||||||||||
| 218 | else { | |||||||||||||||||||||||||||||||||
| 219 | 0 | die qq{Invalid and untaintable filename "$file"!}; | ||||||||||||||||||||||||||||||||
| 220 | } | |||||||||||||||||||||||||||||||||
| 221 | } | |||||||||||||||||||||||||||||||||
| 222 | 0 | my $module = join( "::", grep {length} @parts ); | ||||||||||||||||||||||||||||||||
| 223 | 0 | push( @modules, $module ); | ||||||||||||||||||||||||||||||||
| 224 | } | |||||||||||||||||||||||||||||||||
| 225 | } # while | |||||||||||||||||||||||||||||||||
| 226 | ||||||||||||||||||||||||||||||||||
| 227 | 0 | return @modules; | ||||||||||||||||||||||||||||||||
| 228 | } | |||||||||||||||||||||||||||||||||
| 229 | ||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | sub _starting_points { | |||||||||||||||||||||||||||||||
|
Subroutine
_starting_points: not called CC=2 SCAR=17.9
| ||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | return 'blib' if -e 'blib'; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 232 | 0 | return 'lib'; | ||||||||||||||||||||||||||||||||
| 233 | } | |||||||||||||||||||||||||||||||||
| 234 | ||||||||||||||||||||||||||||||||||
| 235 | # END copy-pasted from Test::Pod::Coverage | |||||||||||||||||||||||||||||||||
| 236 | ||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | sub regexp_patterns_in_all_modules_ok { | |||||||||||||||||||||||||||||||
|
Subroutine
regexp_patterns_in_all_modules_ok: not called CC=5 SCAR=34.0
Pod
documented
| ||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | my $opts = (@_ && (ref $_[0] eq "HASH")) ? shift : {}; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ and ref $_[0] eq "HASH"
@_
ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= @_B= ref $_[0] eq "HASH"
| ||||||||||||||||||||||||||||||||||
| 239 | 0 | my $msg = shift; | ||||||||||||||||||||||||||||||||
| 240 | 0 | my $ok = 1; | ||||||||||||||||||||||||||||||||
| 241 | ||||||||||||||||||||||||||||||||||
| 242 | 0 | my @starters = _starting_points(); | ||||||||||||||||||||||||||||||||
| 243 | 0 | local @INC = (@starters, @INC); | ||||||||||||||||||||||||||||||||
| 244 | ||||||||||||||||||||||||||||||||||
| 245 | 0 | $Test->plan(tests => 1); | ||||||||||||||||||||||||||||||||
| 246 | ||||||||||||||||||||||||||||||||||
| 247 | 0 | my @modules = all_modules(@starters); | ||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if (@modules) { | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 249 | $Test->subtest( | |||||||||||||||||||||||||||||||||
| 250 | "Regexp patterns on all dist's modules", | |||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | sub { | |||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| ||||||||||||||||||||||||||||||||||
| 252 | 0 | for my $module (@modules) { | ||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | my $thismsg = defined $msg ? $msg : | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 254 | "Regexp patterns in module $module"; | |||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | my $thisok = regexp_patterns_in_module_ok( | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 256 | $module, $opts, $thismsg) | |||||||||||||||||||||||||||||||||
| 257 | or $ok = 0; | |||||||||||||||||||||||||||||||||
| 258 | } | |||||||||||||||||||||||||||||||||
| 259 | } | |||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | ) or $ok = 0; | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||
| 261 | } else { | |||||||||||||||||||||||||||||||||
| 262 | 0 | $Test->ok(1, "No modules found."); | ||||||||||||||||||||||||||||||||
| 263 | } | |||||||||||||||||||||||||||||||||
| 264 | 0 | $ok; | ||||||||||||||||||||||||||||||||
| 265 | } | |||||||||||||||||||||||||||||||||
| 266 | ||||||||||||||||||||||||||||||||||
| 267 | 1 | 1; | ||||||||||||||||||||||||||||||||
| 268 | # ABSTRACT: Test Regexp::Pattern patterns | |||||||||||||||||||||||||||||||||
| 269 | ||||||||||||||||||||||||||||||||||
| 270 | __END__ | |||||||||||||||||||||||||||||||||