File Coverage

test/lib/ContentOfRandomFileTestOptions.pm
Criterion Covered Total %
statement 23 23 100.0
branch 9 10 90.0
condition 10 11 90.9
subroutine 9 9 100.0
pod 0 1 0.0
total 51 54 94.4


line stmt bran cond sub pod time code
1             package
2             ContentOfRandomFileTestOptions;
3 1     1   616 use base qw/RandomFileMethodAllTests/;
  1         4  
  1         80  
4              
5 1     1   7 use strict;
  1         1  
  1         20  
6 1     1   4 use warnings;
  1         2  
  1         23  
7              
8 1     1   6 use File::Random;
  1         2  
  1         540  
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     18060 0 126968 my ($self, %args) = @_;
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 100 100     102324 );
23 18024         97989 return _guess_filename @content;
24             }
25              
26             sub _no_cvs_subdir_check($) {
27 84000   100 84000   291121 my $check = shift() || sub {"no checking done - always true"};
  18042     18042   83218  
28             return sub {
29 135000 50   135000   291391 return 0 if /CVS/; # filename seems to be in a CVS subdir
30 135000 100       464922 ref($check) eq 'Regexp' ? return /$check/ : return $check->(@_)
31 18042         79340 };
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 100 100 18024   182271 $_[0] and $_[0] =~ /^Content: (.*)$/ and return $1;
38 5229 100 66     40176 $_[3] and chomp($_[3]),$_[3] =~ /^(\w\.dat)$/ and return $1;
39 2274         9336 return undef;
40             }
41              
42             1;