blib/lib/Set/Select.pm

filter: Statementstmt 100% 32 / 32 Branchbran 50.0% 1 / 2 Conditioncond 80.0% 4 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 92.1% 47 / 51 CC 7 SCAR 13.1
CC
7
Cov
95%
new
6.0
all_subsets
2.0
BEGIN
1.0
CRAP 3.7
↑ Summary
1 package Set::Select;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '1.01';
8  
9 5 ▶sub new {
Subroutine new: called CC=6 SCAR=18.0
Pod documented
10 5 my $class = shift;
11  
12 5 my $self = {};
13 5 for my $i (0..$#_) {
14 58 ▶ croak "Arguments must be array references (argument $i is not)" if not ref $_[$i] eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_[$i] eq "ARRAY" 0 58 58
15 58 for my $elem (@{$_[$i]}) {
16 2617 my $key = $elem;
17 2617 ▶ $self->{$key}->[1] //= $elem;
Condition66%2/3
$self->{$key}[1] //= $elem
l!l&&r!l&&!r
25071100
MC/DC0%0/2
$self->{$key}[1] //= $elem
$self->{$key}[1] $elem
Truth table66%2/3
A //= B
A= $self->{$key}[1]B= $elem
ABresult
1X1
011
000
18 2617 ▶ $self->{$key}->[0] //= '0' x @_;
Condition100%2/2
$self->{$key}[0] //= 0 x @_
l!l
2507110
MC/DC100%1/1
$self->{$key}[0] //= 0 x @_
$self->{$key}[0]
Truth table100%2/2
A
A= $self->{$key}[0]
Aresult
11
00
19 2617 vec($self->{$key}->[0], $i, 8) = 0x31;
20 }
21 }
22 5 bless $self, $class;
23 }
24  
25 19 ▶sub select {
Subroutine select: called CC=1 SCAR=0.0
Pod documented
26 19 my ($self, $bits) = @_;
27 19 return [map { $self->{$_}->[1] } grep { $self->{$_}->[0] =~ /^$bits$/ } keys %$self];
28 }
29  
30 4 ▶sub all_subsets {
Subroutine all_subsets: called CC=2 SCAR=6.9
Pod documented
31 4 my $self = shift;
32 4 my %keys;
33 4 for my $e (values %$self) {
34 9 push @{$keys{$e->[0]}}, $e->[1];
35 }
36 4 return \%keys;
37 }
38  
39 1 1;
40  
41 __END__
↑ Summary