blib/lib/Return/Type/Lexical.pm

filter: Statementstmt 100% 31 / 31 Branchbran 83.3% 5 / 6 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 1 totaltotal 93.1% 54 / 58 CC 6 SCAR 6.6
CC
6
Cov
95%
import
3.0
_in_effect
3.0
ReturnType
2.0
CRAP 1.9
↑ Summary
1 package Return::Type::Lexical;
2 # ABSTRACT: Same thing as Return::Type, but lexical
3  
4 2 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use parent 'Return::Type';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our $VERSION = '0.002'; # VERSION
11  
12 2 ▶sub import {
Subroutine import: called CC=3 SCAR=11.1
13 2 my ($class, %args) = @_;
14 2 ▶ $^H{'Return::Type::Lexical/in_effect'} = exists $args{check} && !$args{check} ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'check'} && !$args{'check'} ? : 1 1 2
Condition66%2/3
exists $args{"check"} and not $args{"check"}
!ll&&!rl&&r
101
MC/DC50%1/2
exists $args{"check"} and not $args{"check"}
exists $args{"check"} not $args{"check"}
Truth table66%2/3
A and not(B)
A= exists $args{"check"}B= not $args{"check"}
ABresult
0X0
100
111
15 }
16  
17 1 ▶sub unimport {
Subroutine unimport: called CC=1 SCAR=0.0
18 1 $^H{'Return::Type::Lexical/in_effect'} = 0;
19 }
20  
21 4 ▶sub _in_effect {
Subroutine _in_effect: called CC=3 SCAR=11.0
22 4 my ($level) = @_;
23 4 ▶ $level = 0 if !defined $level;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $level 0 4 4
24 4 my $hinthash = (caller($level))[10];
25 4 my $in_effect = $hinthash->{'Return::Type::Lexical/in_effect'};
26 4 ▶ return !defined $in_effect || $in_effect;
Condition100%3/3
!defined($in_effect) || $in_effect
l!l&&r!l&&!r
112
MC/DC100%2/2
!defined($in_effect) || $in_effect
!defined($in_effect) $in_effect
Truth table100%3/3
not(A) || B
A= !defined($in_effect)B= $in_effect
ABresult
1X1
011
000
27 }
28  
29 # XXX This is kind of janky. It relies upon Return::Type using Attribute::Handlers, and it assumes
30 # some internal Attribute::Handlers behavior. If it proves to be too fragile, we may need to copy
31 # the Return::Type code to here. Or make Return::Type lexical if that can be done without breaking
32 # backward-compatibility.
33 2 my $handler;
34 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
35 2 $handler = $UNIVERSAL::{ReturnType};
36 2 delete $UNIVERSAL::{ReturnType};
37 2 delete $UNIVERSAL::{_ATTR_CODE_ReturnType};
38 }
39 4 ▶sub UNIVERSAL::ReturnType :ATTR(CODE,BEGIN) {
Subroutine ReturnType: called CC=2 SCAR=6.9
Pod undocumented
40 4 my $in_effect = _in_effect(4);
41 4 ▶ return if !$in_effect;
Branch: 1 branch
BranchTrueFalseTotal
unless $in_effect 2 2 4
42  
43 2 return $handler->(@_);
44 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 2 1;
47  
48 __END__
↑ Summary