| 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'
MC/DC100%1/1
shift() || 'none'
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||
| 15 | |||||||||||||||||||
| 16 | 33 | ▶ | die("Unknown order strategy: $strategy\n") unless $strategy =~ /^(?:none|(r?)(?:alphabetic|natural)|random)$/i; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 17 | |||||||||||||||||||
| 18 | 33 | ▶ | my $self = bless( { strategy => $strategy, reverse => ($1 ? 1 : 0) }, $class); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 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
| |||||||||||||||||||
| 31 | { | ||||||||||||||||||
| 32 | 36 | ▶ | if ($self->{strategy} =~ /^r?alphabetic$/) | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 33 | { | ||||||||||||||||||
| 34 | 12 | @l = sort(@l); | |||||||||||||||||
| 35 | 12 | ▶ | @l = reverse(@l) if $self->{reverse}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 36 | } | ||||||||||||||||||
| 37 | elsif ($self->{strategy} =~ /^(r?)natural$/) | ||||||||||||||||||
| 38 | { | ||||||||||||||||||
| 39 | 24 | @l = nsort(@l); | |||||||||||||||||
| 40 | 24 | ▶ | @l = reverse(@l) if $self->{reverse}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 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; | |||||||||||||||||