Contextual/Diag.pm

filter: Statementstmt 100% 54 / 54 Branchbran 100% 16 / 16 Conditioncond 100% 4 / 4 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 19 / 19 Podpod 100% 1 / 1 totaltotal 100% 96 / 96 CC 11 SCAR 5.6
CC
11
Cov
100%
contextual_diag
3.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.8
↑ Summary Contextual/Diag/Value.pm »
1 package Contextual::Diag;
2 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = "0.04";
7  
8 2 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 our @ISA = qw/Exporter/;
10 2 our @EXPORT = qw/contextual_diag/;
11  
12 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Contextual::Diag::Value;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 42 ▶sub contextual_diag {
Subroutine contextual_diag: called CC=3 SCAR=11.0
Pod documented
16  
17 42 ▶ if (wantarray) {
Branch: 2 branches
BranchTrueFalseTotal
if (wantarray) { } 11 31 42
elsif (not defined wantarray) { } 2 29 31
18 11 _diag('wanted LIST context');
19 11 return @_;
20 }
21 elsif(!defined wantarray) {
22 2 _diag('wanted VOID context');
23 2 return;
24 }
25 else {
26 29 _diag('wanted SCALAR context');
27  
28 return Contextual::Diag::Value->new($_[0],
29 1 ▶ BOOL => sub { _diag('evaluated as BOOL in SCALAR context'); return $_[0] },
Subroutine __ANON__: called CC=1 SCAR=0.0
30 2 ▶ NUM => sub { _diag('evaluated as NUM in SCALAR context'); return $_[0] || 0 },
Subroutine __ANON__: called CC=2 SCAR=6.9
Condition100%2/2
$_[0] || 0
l!l
11
MC/DC100%1/1
$_[0] || 0
$_[0]
Truth table100%2/2
A
A= $_[0]
Aresult
11
00
31 3 ▶ STR => sub { _diag('evaluated as STR in SCALAR context'); return $_[0] || "" },
Subroutine __ANON__: called CC=2 SCAR=6.9
Condition100%2/2
$_[0] || ''
l!l
12
MC/DC100%1/1
$_[0] || ''
$_[0]
Truth table100%2/2
A
A= $_[0]
Aresult
11
00
32 2 ▶ SCALARREF => sub { _diag('scalar ref is evaluated as SCALARREF'); return defined $_[0] ? $_[0] : \"" },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 1 1 2
33 3 ▶ ARRAYREF => sub { _diag('scalar ref is evaluated as ARRAYREF'); return defined $_[0] ? $_[0] : [] },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 1 2 3
34 3 ▶ HASHREF => sub { _diag('scalar ref is evaluated as HASHREF'); return defined $_[0] ? $_[0] : {} },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 1 2 3
35 2 ▶ CODEREF => sub { _diag('scalar ref is evaluated as CODEREF'); return defined $_[0] ? $_[0] : sub { } },
Subroutine __ANON__: called CC=2 SCAR=6.9
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 1 1 2
36 2 ▶ GLOBREF => sub { _diag('scalar ref is evaluated as GLOBREF'); return defined $_[0] ? $_[0] : do { no strict qw/refs/; my $package = __PACKAGE__; \*{$package} } },
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 1 1 2
37 7 ▶ OBJREF => sub { _diag('scalar ref is evaluated as OBJREF'); return defined $_[0] ? $_[0] : bless {}, __PACKAGE__ },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 5 2 7
38 29 );
39 }
40 }
41  
42 67 ▶sub _diag {
Subroutine _diag: called CC=1 SCAR=0.0
43 67 local $Carp::CarpLevel = 2;
44 67 goto &Carp::carp;
45 }
46  
47 2 1;
48 __END__
↑ Summary Contextual/Diag/Value.pm »