| 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"} // ""
MC/DC0%0/1
$ENV{"VERBOSE_KEYWORD_VALUE"} // ""
$ENV{"VERBOSE_KEYWORD_VALUE"}
Truth table50%1/2
A
A= $ENV{"VERBOSE_KEYWORD_VALUE"}
| |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||
| 25 | # lvalue delays dlock until after state sets its own magic flag. | ||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||
| 27 | 30 | ▶ | $_[0] = $_[1] if @_ > 1; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||
| 29 | 30 | ▶ | $_[0] // carp "Fixing undefined value" | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
$verbose && ($_[0] // carp('Fixing undefined value'))
$_[0] // carp("Fixing undefined value")
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")
| |||||||||||||||||||||||||||||||||||||||||
| 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
Condition50%1/2
(caller 0)[3] // ""
MC/DC0%0/1
(caller 0)[3] // ""
(caller 0)[3]
Truth table50%1/2
A
A= (caller 0)[3]
| |||||||||||||||||||||||||||||||||||||||||
| 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
Condition50%1/2
(caller 0)[3] // ""
MC/DC0%0/1
(caller 0)[3] // ""
(caller 0)[3]
Truth table50%1/2
A
A= (caller 0)[3]
| |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | {{{ | |||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $Keyword::Value::const->( <{$expr}> ) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 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__ | |||||||||||||||||||||||||||||||||||||||