Any/Context.pm

filter: Statementstmt 87.8% 36 / 41 Branchbran 50.0% 5 / 10 Conditioncond 33.3% 4 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 83.3% 10 / 12 Podpod 25.0% 1 / 4 totaltotal 64.3% 56 / 87 SCAR 25.1
CC
10
Cov
71%
is_true
6.3
is_false
6.3
_throw_if_bad_name
2.9
CRAP 12.3
↑ Summary Any/Context/JE.pm »
1 1 ▶use 5.008003;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package JavaScript::Any::Context;
6  
7 1 our $AUTHORITY = 'cpan:TOBYINK';
8 1 our $VERSION = '0.001';
9  
10 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 requires 'eval';
14 1 requires 'define';
15  
16 1 ▶use Ref::Util qw( is_plain_scalarref );
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 # convenience methods here
19  
20 sub implementation {
21 0 ▶ ref shift;
Subroutine implementation: not called CC=1 SCAR=6.9
Pod documented
22 }
23  
24 sub is_true {
25 1 ▶ shift;
Subroutine is_true: called CC=5 SCAR=18.4
Pod undocumented
26 1 my ($value) = @_;
27 1 ▶ return !!1 if is_plain_scalarref($value) && $$value == 1;
Branch: 1 branch
BranchTrueFalseTotal
if Ref::Util::XS::is_plain_scalarref($value) and $$value == 1 0 1 1
Condition33%1/3
Ref::Util::XS::is_plain_scalarref($value) and $$value == 1
!ll&&!rl&&r
100
MC/DC0%0/2
Ref::Util::XS::is_plain_scalarref($value) and $$value == 1
Ref::Util::XS::is_plain_scalarref($value) $$value == 1
Truth table33%1/3
A and B
A= Ref::Util::XS::is_plain_scalarref($value)B= $$value == 1
ABresult
0X0
100
111
28 1 require JSON::PP;
29 1 ▶ return !!1 if JSON::PP::is_bool($value) && $value == JSON::PP::true();
Branch: 1 branch
BranchTrueFalseTotal
if JSON::PP::is_bool($value) and $value == JSON::PP::true() 0 1 1
Condition33%1/3
JSON::PP::is_bool($value) and $value == JSON::PP::true()
!ll&&!rl&&r
100
MC/DC0%0/2
JSON::PP::is_bool($value) and $value == JSON::PP::true()
JSON::PP::is_bool($value) $value == JSON::PP::true()
Truth table33%1/3
A and B
A= JSON::PP::is_bool($value)B= $value == JSON::PP::true()
ABresult
0X0
100
111
30 1 return !!0;
31 }
32  
33 sub is_false {
34 1 ▶ shift;
Subroutine is_false: called CC=5 SCAR=18.4
Pod undocumented
35 1 my ($value) = @_;
36 1 ▶ return !!1 if is_plain_scalarref($value) && $$value == 0;
Branch: 1 branch
BranchTrueFalseTotal
if Ref::Util::XS::is_plain_scalarref($value) and $$value == 0 0 1 1
Condition33%1/3
Ref::Util::XS::is_plain_scalarref($value) and $$value == 0
!ll&&!rl&&r
100
MC/DC0%0/2
Ref::Util::XS::is_plain_scalarref($value) and $$value == 0
Ref::Util::XS::is_plain_scalarref($value) $$value == 0
Truth table33%1/3
A and B
A= Ref::Util::XS::is_plain_scalarref($value)B= $$value == 0
ABresult
0X0
100
111
37 1 require JSON::PP;
38 1 ▶ return !!1 if JSON::PP::is_bool($value) && $value == JSON::PP::false();
Branch: 1 branch
BranchTrueFalseTotal
if JSON::PP::is_bool($value) and $value == JSON::PP::false() 0 1 1
Condition33%1/3
JSON::PP::is_bool($value) and $value == JSON::PP::false()
!ll&&!rl&&r
100
MC/DC0%0/2
JSON::PP::is_bool($value) and $value == JSON::PP::false()
JSON::PP::is_bool($value) $value == JSON::PP::false()
Truth table33%1/3
A and B
A= JSON::PP::is_bool($value)B= $value == JSON::PP::false()
ABresult
0X0
100
111
39 1 return !!0;
40 }
41  
42 sub is_null {
43 1 ▶ return !defined $_[1];
Subroutine is_null: called CC=1 SCAR=0.0
Pod undocumented
44 }
45  
46 sub _throw_if_bad_name {
47 2 ▶ return if $_[1] =~ /\A\w+\z/;
Subroutine _throw_if_bad_name: called CC=2 SCAR=10.5
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] =~ /\A\w+\z/ 2 0 2
48 0 require Carp;
49 0 Carp::croak("Bad name: " . ref($_[1]));
50 }
51  
52 sub _throw_because_bad_value {
53 0 ▶ require Carp;
Subroutine _throw_because_bad_value: not called CC=1 SCAR=6.9
54 0 Carp::croak("Cannot define values of type " . ref($_[1]));
55 # ref should always be defined because non-ref scalars will be good values
56 }
57  
58 1 1;
59  
60 __END__
↑ Summary Any/Context/JE.pm »