blib/lib/Data/RoundRobin.pm

filter: Statementstmt 100% 27 / 27 Branchbran n/a Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 90.7% 39 / 43 CC 3 SCAR 5.3
CC
3
Cov
94%
numerify
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.7
↑ Summary
1 package Data::RoundRobin;
2 7 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 our $VERSION = '0.03';
6  
7 use overload
8 7 ▶ 'eq' => \&next,
Subroutine BEGIN: called CC=1 SCAR=0.0
9 'ne' => \&next,
10 "cmp" => \&next,
11 "<=>" => \&next,
12 '+' => \&numerify,
13 '==' => \&numerify,
14 7 '""' => \&next;
15  
16 7 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
17 7 my ($class, @arr) = @_;
18 7 my $self = {
19 array => \@arr,
20 current => 0,
21 total => scalar(@arr),
22 };
23 7 return bless $self;
24 }
25  
26 63 ▶sub next {
Subroutine next: called CC=1 SCAR=0.0
Pod documented
27 63 my $self = shift;
28 63 my $r = $self->{array}->[$self->{current}];
29 63 $self->{current}++;
30 63 $self->{current} %= $self->{total};
31 63 return $r;
32 }
33  
34 9 ▶sub numerify {
Subroutine numerify: called CC=3 SCAR=11.2
Pod documented
35 9 my $self = shift;
36 9 ▶ my $other = shift || 0;
Condition50%1/2
shift() || 0
l!l
09
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
37 9 my $value = $self->next;
38 9 $value =~ s/^(\d*).*$/$1/;
39 9 ▶ $value ||= 0;
Condition50%1/2
$value ||= 0
l!l
09
MC/DC0%0/1
$value ||= 0
$value
Truth table50%1/2
A
A= $value
Aresult
11
00
40 9 return $value + $other;
41 }
42  
43 7 1;
44  
45 __END__
↑ Summary