lib/Lingy/HashSet.pm

filter: Statementstmt 94.4% 34 / 36 Branchbran 87.5% 14 / 16 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 2 totaltotal 77.6% 59 / 76 CC 12 SCAR 17.8
CC
12
Cov
84%
_get_key
11.0
new
3.0
_to_seq
2.0
CRAP 6.0
« lib/Lingy/HashMap.pm ↑ Summary blib/lib/Lingy/Regex.pm »
1 57 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Lingy::HashSet;
3  
4 57 ▶use base 'Lingy::Class';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 57 ▶use Lingy::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 57 ▶use Hash::Ordered;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub new {
11 425 ▶ my ($class, $list) = @_;
Subroutine new: called CC=3 SCAR=11.0
Pod undocumented
12 425 tie my %hash, 'Hash::Ordered';
13 425 ▶ for (my $i = 0; $i < @$list; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$list) 453 425 878
14 453 my $val = $list->[$i];
15 453 my $key = $class->_get_key($val);
16 453 ▶ delete $hash{$key} if exists $hash{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $hash{$key} 18 435 453
17 453 $hash{$key} = $val;
18 }
19 425 bless \%hash, $class;
20 }
21  
22 sub clone {
23 0 ▶ HASHSET->new([ %{$_[0]} ]);
Subroutine clone: not called CC=1 SCAR=6.9
Pod undocumented
24 }
25  
26 sub _get_key {
27 453 ▶ my ($self, $key) = @_;
Subroutine _get_key: called CC=9 SCAR=24.0
28 453 my $type = ref($key);
29 $type eq '' ? qq<$key> :
30 $type eq STRING ? qq<"$key> :
31 $type eq SYMBOL ? qq<$key > :
32 $type->isa(SCALARTYPE) ? qq<$key> :
33 ( # Quoted symbol:
34 $type eq LIST and
35 ref($key->[0]) eq SYMBOL and
36 2 ${$key->[0]} eq 'quote' and
37 ref($key->[1]) eq SYMBOL
38 453 ▶ ) ? ${$key->[1]} . ' ' :
Branch: 5 branches
BranchTrueFalseTotal
$type eq '' ? : 16 437 453
$type eq 'Lingy::String' ? : 4 433 437
$type eq 'Lingy::Symbol' ? : 4 429 433
$type->isa('Lingy::ScalarClass') ? : 427 2 429
$type eq 'Lingy::List' && ref $key->[0] eq 'Lingy::Symbol' && ${$key->[0];} eq 'quote' && ref $key->[1] eq 'Lingy::Symbol' ? : 2 0 2
Condition33%3/9
$type eq "Lingy::List" and ref $key->[0] eq "Lingy::Symbol" and ${$key->[0];} eq "quote" and ref $key->[1] eq "Lingy::Symbol"
!ll&&!rl&&r
002
$type eq "Lingy::List" and ref $key->[0] eq "Lingy::Symbol" and ${$key->[0];} eq "quote"
!ll&&!rl&&r
002
$type eq "Lingy::List" and ref $key->[0] eq "Lingy::Symbol"
!ll&&!rl&&r
002
MC/DC0%0/4
$type eq "Lingy::List" and ref $key->[0] eq "Lingy::Symbol" and ${$key->[0];} eq "quote" and ref $key->[1] eq "Lingy::Symbol"
$type eq "Lingy::List" ref $key->[0] eq "Lingy::Symbol" ${$key->[0];} eq "quote" ref $key->[1] eq "Lingy::Symbol"
Truth table20%1/5
A and B and C and D
A= $type eq "Lingy::List"B= ref $key->[0] eq "Lingy::Symbol"C= ${$key->[0];} eq "quote"D= ref $key->[1] eq "Lingy::Symbol"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
39 err "Type '$type' not supported as a hash-map key";
40 }
41  
42 sub _to_seq {
43 1 ▶ my ($map) = @_;
Subroutine _to_seq: called CC=2 SCAR=7.0
44 1 ▶ return nil unless %$map;
Branch: 1 branch
BranchTrueFalseTotal
unless %$map 0 1 1
45 LIST->new([
46 map {
47 4 $map->{$_};
48 1 } keys %{$_[0]}
49 ]);
50 }
51  
52 57 1;
« lib/Lingy/HashMap.pm ↑ Summary blib/lib/Lingy/Regex.pm »