blib/lib/List/AssignRef.pm

filter: Statementstmt 97.3% 36 / 37 Branchbran 50.0% 7 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.8% 13 / 14 Podpod 100% 1 / 1 totaltotal 86.3% 57 / 66 CC 8 SCAR 17.2
CC
8
Cov
84%
__ANON__
20.0
__ANON__
5.0
deref
1.1
CRAP 5.6
↑ Summary
1 package List::AssignRef;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use LV qw( lvalue );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Carp qw( confess );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Scalar::Util qw( reftype );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 SCALAR => 'SCALAR',
12 ARRAY => 'ARRAY',
13 HASH => 'HASH',
14 1 };
15  
16 1 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ERR_UNSUPPORTED => "Unsupported reference type: %s",
18 ERR_MISMATCH => "Reference type mismatch: %s vs %s",
19 1 };
20  
21 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 $List::AssignRef::AUTHORITY = 'cpan:TOBYINK';
23 1 $List::AssignRef::VERSION = '0.005';
24 }
25  
26 1 ▶use Exporter::Shiny our @EXPORT = qw( deref );
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 sub _confessf
29 1 ▶{
Subroutine _confessf: called CC=1 SCAR=0.0
30 1 my $fmt = shift;
31 1 confess sprintf $fmt, @_;
32 }
33  
34 6 ▶sub deref (\[$@%]) :lvalue
Subroutine deref: called CC=1 SCAR=0.6
Pod documented
35 {
36 6 my $given = shift;
37 0 ▶ lvalue get => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
38 0 ▶ reftype($given) eq SCALAR ? $$given :
Branch: 3 branches
BranchTrueFalseTotal
builtin::reftype($given) eq 'SCALAR' ? : 0 0 0
builtin::reftype($given) eq 'ARRAY' ? : 0 0 0
builtin::reftype($given) eq 'HASH' ? : 0 0 0
39 reftype($given) eq ARRAY ? @$given :
40 reftype($given) eq HASH ? %$given :
41 _confessf(ERR_UNSUPPORTED, reftype($given));
42 },
43 6 ▶ set => sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
44 6 my $assign = shift;
45 6 ▶ reftype($given) eq reftype($assign)
Branch: 1 branch
BranchTrueFalseTotal
builtin::reftype($given) eq builtin::reftype($assign) or _confessf("Reference type mismatch: %s vs %s", scalar builtin::reftype($given), scalar builtin::reftype($assign)) 5 1 6
46 or _confessf(ERR_MISMATCH, reftype($given), reftype($assign));
47 5 ▶ reftype($given) eq SCALAR ? ($$given = $$assign):
Branch: 3 branches
BranchTrueFalseTotal
builtin::reftype($given) eq 'SCALAR' ? : 1 4 5
builtin::reftype($given) eq 'ARRAY' ? : 3 1 4
builtin::reftype($given) eq 'HASH' ? : 1 0 1
48 reftype($given) eq ARRAY ? (@$given = @$assign):
49 reftype($given) eq HASH ? (%$given = %$assign):
50 _confessf(ERR_UNSUPPORTED, reftype($given));
51 }
52 6 }
53  
54 1 1;
55  
56 __END__
↑ Summary