test/lib/ContentOfRandomFileTestOptions.pm

filter: Statementstmt 100% 24 / 24 Branchbran 90.0% 9 / 10 Conditioncond 83.3% 10 / 12 MC/DCmcdc 62.5% 5 / 8 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 89.0% 57 / 64 SCAR 23.1
CC
10
Cov
93%
_guess_filename
5.0
__ANON__
3.0
random_file
3.0
CRAP 10.0
« blib/lib/File/Random.pm ↑ Summary test/lib/RandomLine.pm »
1 package
2 ContentOfRandomFileTestOptions;
3 1 ▶use base qw/RandomFileMethodAllTests/;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use File::Random;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub _no_cvs_subdir_check($);
11 sub _guess_filename(@);
12  
13 # Replace random_file with calling content_of_random_file
14 # Analyze the content and return the file name because of the analysis
15 sub random_file {
16 18060 ▶ my ($self, %args) = @_;
Subroutine random_file: called CC=3 SCAR=11.0
Pod undocumented
17 my @content = $self->content_of_random_file(
18 %args,
19 (exists($args{-check}) and (ref($args{-check}) !~ /CODE|Regexp/))
20 ? () # -check option without a sensful value, should surely fail
21 : (-check => _no_cvs_subdir_check $args{-check})
22 18060 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'-check'} && !(ref($args{'-check'}) =~ /CODE|Regexp/) ? : 18 18042 18060
Condition100%3/3
exists $args{"-check"} and not ref($args{"-check"}) =~ /CODE|Regexp/
!ll&&!rl&&r
12792525018
MC/DC100%2/2
exists $args{"-check"} and not ref($args{"-check"}) =~ /CODE|Regexp/
exists $args{"-check"} not ref($args{"-check"}) =~ /CODE|Regexp/
Truth table100%3/3
A and not(B)
A= exists $args{"-check"}B= not ref($args{"-check"}) =~ /CODE|Regexp/
ABresult
0X0
100
111
23 18024 return _guess_filename @content;
24 }
25  
26 sub _no_cvs_subdir_check($) {
27 84000 ▶ my $check = shift() || sub {"no checking done - always true"};
Subroutine __ANON__: called CC=1 SCAR=0.1
Subroutine _no_cvs_subdir_check: called CC=2 SCAR=7.0
Condition66%2/3
shift() || sub { 'no checking done - always true'; }
l!l&&r!l&&!r
5250127920
MC/DC0%0/2
shift() || sub { 'no checking done - always true'; }
shift() sub { 'no checking done - always true'; }
Truth table66%2/3
A || B
A= shift()B= sub { 'no checking done - always true'; }
ABresult
1X1
011
000
28 return sub {
29 135000 ▶ return 0 if /CVS/; # filename seems to be in a CVS subdir
Subroutine __ANON__: called CC=3 SCAR=11.1
Branch: 1 branch
BranchTrueFalseTotal
if /CVS/ 0 135000 135000
30 135000 ▶ ref($check) eq 'Regexp' ? return /$check/ : return $check->(@_)
Branch: 1 branch
BranchTrueFalseTotal
ref $check eq 'Regexp' ? : 21000 114000 135000
31 18042 };
32 }
33  
34 # In the fileX files there's only one line "Content: fileX"
35 # In the [xyz].dat files there are some lines, the 4th line contains the fname
36 sub _guess_filename(@) {
37 18024 ▶ $_[0] and $_[0] =~ /^Content: (.*)$/ and return $1;
Subroutine _guess_filename: called CC=5 SCAR=16.1
Branch: 1 branch
BranchTrueFalseTotal
$_[0] and $_[0] =~ /^Content: (.*)$/ and return $1 12840 5184 18024
Condition100%3/3
$_[0] and $_[0] =~ /^Content: (.*)$/
!ll&&!rl&&r
2274291012840
MC/DC100%2/2
$_[0] and $_[0] =~ /^Content: (.*)$/
$_[0] $_[0] =~ /^Content: (.*)$/
Truth table100%3/3
A and B
A= $_[0]B= $_[0] =~ /^Content: (.*)$/
ABresult
0X0
100
111
38 5184 ▶ $_[3] and chomp($_[3]),$_[3] =~ /^(\w\.dat)$/ and return $1;
Branch: 1 branch
BranchTrueFalseTotal
$_[3] and chomp $_[3], $_[3] =~ /^(\w\.dat)$/ and return $1 2910 2274 5184
Condition66%2/3
$_[3] and chomp $_[3], $_[3] =~ /^(\w\.dat)$/
!ll&&!rl&&r
227402910
MC/DC50%1/2
$_[3] and chomp $_[3], $_[3] =~ /^(\w\.dat)$/
$_[3] chomp $_[3], $_[3] =~ /^(\w\.dat)$/
Truth table66%2/3
A and B
A= $_[3]B= chomp $_[3], $_[3] =~ /^(\w\.dat)$/
ABresult
0X0
100
111
39 2274 return undef;
40 }
41  
42 1 1;
« blib/lib/File/Random.pm ↑ Summary test/lib/RandomLine.pm »