blib/lib/Keyword/Value.pm

filter: Statementstmt 57.7% 41 / 71 Branchbran 33.3% 4 / 12 Conditioncond 36.3% 4 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 75.0% 9 / 12 Podpod n/a totaltotal 51.7% 58 / 112 CC 11 SCAR 16.0
CC
11
Cov
52%
import
10.2
__ANON__
7.1
__ANON__
3.5
CRAP 4.9
↑ Summary
1 ########################################################################
2 # housekeeping
3 ########################################################################
4 package Keyword::Value v0.1.2;
5 10 ▶use v5.22;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 ▶use Keyword::Declare;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 10 ▶use Data::Lock qw( dlock );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 10 ▶use Carp qw( carp croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 ########################################################################
13 # package variables
14 ########################################################################
15  
16 10 our @CARP_NOT = ( __PACKAGE__ );
17  
18 # variable avoids having to export the sub into every caller's space.
19  
20 our $const
21 30 ▶= sub : lvalue
Subroutine __ANON__: called CC=5 SCAR=19.6
22 {
23 30 ▶ state $verbose = $ENV{ VERBOSE_KEYWORD_VALUE } // '';
Condition50%1/2
$ENV{"VERBOSE_KEYWORD_VALUE"} // ""
l!l
010
MC/DC0%0/1
$ENV{"VERBOSE_KEYWORD_VALUE"} // ""
$ENV{"VERBOSE_KEYWORD_VALUE"}
Truth table50%1/2
A
A= $ENV{"VERBOSE_KEYWORD_VALUE"}
Aresult
11
00
24  
25 # lvalue delays dlock until after state sets its own magic flag.
26  
27 30 ▶ $_[0] = $_[1] if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 30 30
28  
29 30 ▶ $_[0] // carp "Fixing undefined value"
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 30 30
Condition20%1/5
$verbose && ($_[0] // carp('Fixing undefined value'))
!ll
300
$_[0] // carp("Fixing undefined value")
l!l&&r!l&&!r
000
MC/DC0%0/3
$verbose && ($_[0] // carp('Fixing undefined value'))
$verbose $_[0] carp("Fixing undefined value")
Truth table0%0/4
A && B // C
A= $verboseB= $_[0]C= carp("Fixing undefined value")
ABCresult
0XX0
1000
11X1
1011
30 if $verbose;
31  
32 30 dlock $_[0];
33  
34 # returns ref from stack to allow assignment via lvalue.
35  
36 30 $_[0]
37 10 };
38  
39 ########################################################################
40 # exported subs
41 ########################################################################
42  
43 sub import
44 10 ▶{
Subroutine import: called CC=5 SCAR=23.3
45 # defined inside of "import" this pushes the "value" keyword
46 # into the caller's space.
47 #
48 # lock a variable (i.e., with a sigil).
49 # lacking a leading variable, constify the entire expression.
50 10  
51 0 ▶ keyword value( Var $var, Expr $expr )
Subroutine __ANON__: not called CC=2 SCAR=12.4
Subroutine __ANON__: not called CC=2 SCAR=12.4
Branch: 1 branch
BranchTrueFalseTotal
if (((caller 0)[3] // "") =~ /\b(?:un)?import\Z/u) 10 0 10
Condition50%1/2
(caller 0)[3] // ""
l!l
100
MC/DC0%0/1
(caller 0)[3] // ""
(caller 0)[3]
Truth table50%1/2
A
A= (caller 0)[3]
Aresult
11
00
52 0 {
53 0 ( 0 > index "$var", '::' )
54 ? "\$Keyword::Value::const->( my $var $expr )"
55 0 : "\$Keyword::Value::const->( $var $expr )"
56 0 }
57 0  
58 0 ▶ keyword value ( Expr $expr )
Subroutine __ANON__: called CC=1 SCAR=1.6
Subroutine __ANON__: not called CC=1 SCAR=1.6
Branch: 1 branch
BranchTrueFalseTotal
if (((caller 0)[3] // "") =~ /\b(?:un)?import\Z/u) 10 0 10
Condition50%1/2
(caller 0)[3] // ""
l!l
100
MC/DC0%0/1
(caller 0)[3] // ""
(caller 0)[3]
Truth table50%1/2
A
A= (caller 0)[3]
Aresult
11
00
59 0 {{{
60 0 ▶ $Keyword::Value::const->( <{$expr}> )
Branch: 2 branches
BranchTrueFalseTotal
(index("$var", '::') == -1) ? : 0 0 0
(index("$var", '::') == -1) ? : 0 0 0
61 }}}
62 0 }
63 0  
64 10 ▶# keep require happy
Subroutine BEGIN: called CC=1 SCAR=0.0
65 10 ▶1
Subroutine BEGIN: called CC=1 SCAR=0.0
66 10 __END__
↑ Summary