line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::TestOnTap::OrderStrategy; |
2
|
|
|
|
|
|
|
|
3
|
19
|
|
|
19
|
|
117
|
use strict; |
|
19
|
|
|
|
|
36
|
|
|
19
|
|
|
|
|
502
|
|
4
|
19
|
|
|
19
|
|
88
|
use warnings; |
|
19
|
|
|
|
|
215
|
|
|
19
|
|
|
|
|
1080
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.001'; |
7
|
|
|
|
|
|
|
my $version = $VERSION; |
8
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
9
|
|
|
|
|
|
|
|
10
|
19
|
|
|
19
|
|
115
|
use List::Util qw(shuffle); |
|
19
|
|
|
|
|
39
|
|
|
19
|
|
|
|
|
1942
|
|
11
|
19
|
|
|
19
|
|
10016
|
use Sort::Naturally qw(nsort); |
|
19
|
|
|
|
|
81457
|
|
|
19
|
|
|
|
|
6858
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# CTOR |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
sub new |
16
|
|
|
|
|
|
|
{ |
17
|
33
|
|
|
33
|
0
|
112
|
my $class = shift; |
18
|
33
|
|
100
|
|
|
348
|
my $strategy = shift || 'none'; |
19
|
|
|
|
|
|
|
|
20
|
33
|
50
|
|
|
|
395
|
die("Unknown order strategy: $strategy\n") unless $strategy =~ /^(?:none|(r?)(?:alphabetic|natural)|random)$/i; |
21
|
|
|
|
|
|
|
|
22
|
33
|
100
|
|
|
|
447
|
my $self = bless( { strategy => $strategy, reverse => ($1 ? 1 : 0) }, $class); |
23
|
|
|
|
|
|
|
|
24
|
33
|
|
|
|
|
212
|
return $self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# order a list according to the desired strategy |
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
sub orderList |
30
|
|
|
|
|
|
|
{ |
31
|
110
|
|
|
110
|
0
|
254
|
my $self = shift; |
32
|
110
|
|
|
|
|
346
|
my @l = @_; |
33
|
|
|
|
|
|
|
|
34
|
110
|
100
|
|
|
|
386
|
if ($self->{strategy} ne 'none') |
35
|
|
|
|
|
|
|
{ |
36
|
36
|
100
|
|
|
|
357
|
if ($self->{strategy} =~ /^r?alphabetic$/) |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
37
|
|
|
|
|
|
|
{ |
38
|
12
|
|
|
|
|
43
|
@l = sort(@l); |
39
|
12
|
100
|
|
|
|
37
|
@l = reverse(@l) if $self->{reverse}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
elsif ($self->{strategy} =~ /^(r?)natural$/) |
42
|
|
|
|
|
|
|
{ |
43
|
24
|
|
|
|
|
965
|
@l = nsort(@l); |
44
|
24
|
100
|
|
|
|
1411
|
@l = reverse(@l) if $self->{reverse}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
elsif ($self->{strategy} eq 'random') |
47
|
|
|
|
|
|
|
{ |
48
|
0
|
|
|
|
|
0
|
@l = shuffle(@l); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
110
|
|
|
|
|
353
|
return @l; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub getStrategyName |
56
|
|
|
|
|
|
|
{ |
57
|
23
|
|
|
23
|
0
|
126
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
23
|
|
|
|
|
1513
|
return $self->{strategy}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |