blib/lib/App/TestOnTap/OrderStrategy.pm

filter: Statementstmt 96.6% 29 / 30 Branchbran 75.0% 12 / 16 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 86.4% 51 / 59 SCAR 23.1
CC
10
Cov
90%
orderList
7.3
new
4.0
BEGIN
1.0
CRAP 10.1
« blib/lib/App/TestOnTap/Preprocess.pm ↑ Summary blib/lib/App/TestOnTap/Scheduler.pm »
1 package App::TestOnTap::OrderStrategy;
2  
3 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 19 ▶use List::Util qw(shuffle);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 ▶use Sort::Naturally qw(nsort);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # CTOR
10 #
11 sub new
12 {
13 33 ▶ my $class = shift;
Subroutine new: called CC=4 SCAR=13.9
Pod undocumented
14 33 ▶ my $strategy = shift || 'none';
Condition100%2/2
shift() || 'none'
l!l
627
MC/DC100%1/1
shift() || 'none'
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
15  
16 33 ▶ die("Unknown order strategy: $strategy\n") unless $strategy =~ /^(?:none|(r?)(?:alphabetic|natural)|random)$/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $strategy =~ /^(?:none|(r?)(?:alphabetic|natural)|random)$/i 0 33 33
17  
18 33 ▶ my $self = bless( { strategy => $strategy, reverse => ($1 ? 1 : 0) }, $class);
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 2 31 33
19
20 33 return $self;
21 }
22  
23 # order a list according to the desired strategy
24 #
25 sub orderList
26 {
27 110 ▶ my $self = shift;
Subroutine orderList: called CC=7 SCAR=19.9
Pod undocumented
28 110 my @l = @_;
29  
30 110 ▶ if ($self->{strategy} ne 'none')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"strategy"} ne "none") 36 74 110
31 {
32 36 ▶ if ($self->{strategy} =~ /^r?alphabetic$/)
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'strategy'} =~ /^r?alphabetic$/) { } 12 24 36
elsif ($self->{'strategy'} =~ /^(r?)natural$/) { } 24 0 24
elsif ($self->{'strategy'} eq 'random') { } 0 0 0
33 {
34 12 @l = sort(@l);
35 12 ▶ @l = reverse(@l) if $self->{reverse};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"reverse"} 6 6 12
36 }
37 elsif ($self->{strategy} =~ /^(r?)natural$/)
38 {
39 24 @l = nsort(@l);
40 24 ▶ @l = reverse(@l) if $self->{reverse};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"reverse"} 6 18 24
41 }
42 elsif ($self->{strategy} eq 'random')
43 {
44 0 @l = shuffle(@l);
45 }
46 }
47  
48 110 return @l;
49 }
50  
51 sub getStrategyName
52 {
53 23 ▶ my $self = shift;
Subroutine getStrategyName: called CC=1 SCAR=0.0
Pod undocumented
54
55 23 return $self->{strategy};
56 }
57  
58 19 1;
« blib/lib/App/TestOnTap/Preprocess.pm ↑ Summary blib/lib/App/TestOnTap/Scheduler.pm »