File Coverage

test/lib/RandomFileMethodAllTests.pm
Criterion Covered Total %
statement 30 30 100.0
branch 2 2 100.0
condition 4 6 66.6
subroutine 8 8 100.0
pod 1 3 33.3
total 45 49 91.8


line stmt bran cond sub pod time code
1             package
2             RandomFileMethodAllTests;
3 1         406 use base qw/RandomFileSimpleDirOption
4             RandomFileCheckOption
5             RandomFileRecursiveOption
6             RandomFilePassesPathsToCheckRoutine
7 1     1   705 RandomFileWithUnknownParameters/;
  1         3  
8            
9 1     1   9 use strict;
  1         2  
  1         25  
10 1     1   5 use warnings;
  1         2  
  1         25  
11              
12 1     1   5 use Test::More;
  1         2  
  1         4  
13              
14 1         350 use constant ALIASES =>({},
15             {-dir => '-d', -recursive => '-r', -check => '-c'},
16 1     1   255 {-dir => '-directory', '-recursive' => '-rec'});
  1         2  
17              
18             my %current_aliases;
19              
20             sub random_file {
21 18060     18060 0 131360 my ($self, %args) = @_;
22 18060         23331 my %alias_args;
23 18060         47158 while (my ($option, $value) = each %args) {
24 30828   66     122982 $alias_args{ $current_aliases{$option} || $option } = $value;
25             }
26 18060         47759 return $self->SUPER::random_file(%alias_args);
27             }
28              
29             sub content_of_random_file {
30 18060     18060 0 41828 my ($self, %args) = @_;
31 18060         22544 my %alias_args;
32 18060         45263 while (my ($option, $value) = each %args) {
33 43620   66     155119 $alias_args{ $current_aliases{$option} || $option } = $value;
34             }
35 18060         45434 return $self->SUPER::content_of_random_file(%alias_args);
36             }
37              
38             # Quite a dirty trick to overwrite runtests
39             # but I want to run all tests for every alias one time
40             #
41             # If you know something better, please email me
42             sub runtests {
43 2     2 1 4145 my $self = shift;
44 2         10 foreach (ALIASES) {
45 6         5219 %current_aliases = %$_;
46 6 100       42 diag("Test aliases: ", %current_aliases) if %current_aliases;
47 6         1601 $self->SUPER::runtests();
48             }
49             }
50              
51             1;