blib/lib/Set/Select.pm

filter: Statementstmt 100% 32 / 32 Branchbran 50.0% 1 / 2 Conditioncond 66.6% 4 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 86.7% 46 / 53 CC 7 SCAR 13.2
CC
7
Cov
92%
new
6.1
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.00';
8  
9 sub new {
10 5 ▶ my $class = shift;
Subroutine new: called CC=6 SCAR=18.2
Pod documented
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 @_;
Condition66%2/3
$self->{$key}[0] //= 0 x @_
l!l&&r!l&&!r
25071100
MC/DC0%0/2
$self->{$key}[0] //= 0 x @_
$self->{$key}[0] 0 x @_
Truth table66%2/3
A //= B
A= $self->{$key}[0]B= 0 x @_
ABresult
1X1
011
000
19 2617 vec($self->{$key}->[0], $i, 8) = 0x31;
20 }
21 }
22 5 bless $self, $class;
23 }
24  
25 sub select {
26 19 ▶ my ($self, $bits) = @_;
Subroutine select: called CC=1 SCAR=0.0
Pod documented
27 19 return [map { $self->{$_}->[1] } grep { $self->{$_}->[0] =~ /^$bits$/ } keys %$self];
28 }
29  
30 sub all_subsets {
31 4 ▶ my $self = shift;
Subroutine all_subsets: called CC=2 SCAR=6.9
Pod documented
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