blib/lib/Sub/HandlesVia/XS.pm

filter: Statementstmt 50.0% 31 / 62 Branchbran 16.0% 8 / 50 Conditioncond 11.1% 2 / 18 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 72.7% 8 / 11 Podpod 0.0% 0 / 3 totaltotal 31.8% 49 / 154 CC 32 SCAR 53.7
CC
32
Cov
32%
_type_to_number
365.4
TypeInfo
27.0
__ANON__
6.0
CRAP 214.5
↑ Summary src/types.c »
1 45 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 45 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 45 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Sub::HandlesVia::XS;
6  
7 45 ▶use Types::Common -is, -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 45 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
10 45 our $AUTHORITY = 'cpan:TOBYINK';
11 45 our $VERSION = '0.003004';
12
13 45 require XSLoader;
14 45 __PACKAGE__->XSLoader::load( $VERSION );
15 };
16  
17 0 ▶sub ArraySource {
Subroutine ArraySource: not called CC=1 SCAR=6.9
Pod undocumented
18 0 my ( $class, $string ) = @_;
19 0 my $method = 'ARRAY_SRC_' . uc $string;
20 0 return $class->$method;
21 }
22  
23 0 ▶sub ReturnPattern {
Subroutine ReturnPattern: not called CC=1 SCAR=6.9
Pod undocumented
24 0 my ( $class, $string ) = @_;
25 0 my $method = 'SHOULD_RETURN_' . uc $string;
26 0 return $class->$method;
27 }
28  
29 6 ▶sub TypeInfo {
Subroutine TypeInfo: called CC=8 SCAR=32.9
Pod undocumented
30 6 my ( $class, $type ) = @_;
31
32 6 ▶ die "This method returns a ( coderef, flags ) pair" unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 0 6 6
33
34 6 my $coderef;
35 6 ▶ if ( is_Object $type and $type->can('compiled_check') ) {
Branch: 4 branches
BranchTrueFalseTotal
if (is_Object($type) and $type->can('compiled_check')) { } 6 0 6
elsif (is_Object($type) and $type->can('check')) { } 0 0 0
elsif (is_CodeRef($type)) { } 0 0 0
elsif (is_CodeLike($type)) { } 0 0 0
Condition33%1/3
is_Object($type) and $type->can("compiled_check")
!ll&&!rl&&r
006
MC/DC0%0/2
is_Object($type) and $type->can("compiled_check")
is_Object($type) $type->can("compiled_check")
Truth table33%1/3
A and B
A= is_Object($type)B= $type->can("compiled_check")
ABresult
0X0
100
111
36 6 $coderef = $type->compiled_check;
37 }
38 ▶ elsif ( is_Object $type and $type->can('check') ) {
Condition0%0/3
is_Object($type) and $type->can("check")
!ll&&!rl&&r
000
MC/DC0%0/2
is_Object($type) and $type->can("check")
is_Object($type) $type->can("check")
Truth table0%0/3
A and B
A= is_Object($type)B= $type->can("check")
ABresult
0X0
100
111
39 0 ▶ $coderef = sub { $type->check( @_ ? $_[0] : $_ ) };
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
40 }
41 elsif ( is_CodeRef $type ) {
42 0 $coderef = $type;
43 }
44 elsif ( is_CodeLike $type ) {
45 0 $coderef = \&$type;
46 }
47 else {
48 0 die "Not a type?";
49 }
50
51 6 my $type_flags = _type_to_number( $type );
52 6 return ( $coderef, $type_flags );
53 }
54  
55 6 ▶sub _type_to_number {
Subroutine _type_to_number: called CC=24 SCAR=59.0
56 6 my ( $given_type, $no_recurse ) = @_;
57
58 6 ▶ if ( is_TypeTiny $given_type ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&is_TypeTiny($given_type)) 6 0 6
59 6 my $type = $given_type->find_constraining_type;
60
61 6 ▶ if ( $type == Any or $type == Item ) {
Branch: 17 branches
BranchTrueFalseTotal
if ($type == &Any() or $type == &Item()) { } 0 6 6
elsif ($type == &Defined()) { } 0 6 6
elsif ($type == &Ref()) { } 0 6 6
elsif ($type == &Bool()) { } 0 6 6
elsif ($type == &Int()) { } 6 0 6
elsif ($type == &PositiveOrZeroInt()) { } 0 0 0
elsif ($type == &Num()) { } 0 0 0
elsif ($type == &PositiveOrZeroNum()) { } 0 0 0
elsif ($type == &Str()) { } 0 0 0
elsif ($type == &NonEmptyStr()) { } 0 0 0
elsif ($type == &ClassName()) { } 0 0 0
elsif ($type == &Object()) { } 0 0 0
elsif ($type == &ScalarRef()) { } 0 0 0
elsif ($type == &CodeRef()) { } 0 0 0
elsif ($type == &ArrayRef()) { } 0 0 0
elsif ($type == &HashRef()) { } 0 0 0
elsif ($type->is_parameterized and @{$type->parameters;} == 1 and $type->parameterized_from == &ArrayRef() || $type->parameterized_from == &HashRef()) { } 0 0 0
Condition33%1/3
$type == &Any() or $type == &Item()
l!l&&r!l&&!r
006
MC/DC0%0/2
$type == &Any() or $type == &Item()
$type == &Any() $type == &Item()
Truth table33%1/3
A or B
A= $type == &Any()B= $type == &Item()
ABresult
1X1
011
000
62 0 return TYPE_BASE_ANY;
63 }
64 elsif ( $type == Defined ) {
65 0 return TYPE_BASE_DEFINED;
66 }
67 elsif ( $type == Ref ) {
68 0 return TYPE_BASE_REF;
69 }
70 elsif ( $type == Bool ) {
71 0 return TYPE_BASE_BOOL;
72 }
73 elsif ( $type == Int ) {
74 6 return TYPE_BASE_INT;
75 }
76 elsif ( $type == PositiveOrZeroInt ) {
77 0 return TYPE_BASE_PZINT;
78 }
79 elsif ( $type == Num ) {
80 0 return TYPE_BASE_NUM;
81 }
82 elsif ( $type == PositiveOrZeroNum ) {
83 0 return TYPE_BASE_PZNUM;
84 }
85 elsif ( $type == Str ) {
86 0 return TYPE_BASE_STR;
87 }
88 elsif ( $type == NonEmptyStr ) {
89 0 return TYPE_BASE_NESTR;
90 }
91 elsif ( $type == ClassName ) {
92 0 return TYPE_BASE_CLASSNAME;
93 }
94 elsif ( $type == Object ) {
95 0 return TYPE_BASE_OBJECT;
96 }
97 elsif ( $type == ScalarRef ) {
98 0 return TYPE_BASE_SCALARREF;
99 }
100 elsif ( $type == CodeRef ) {
101 0 return TYPE_BASE_CODEREF;
102 }
103 elsif ( $type == ArrayRef ) {
104 0 return TYPE_ARRAYREF;
105 }
106 elsif ( $type == HashRef ) {
107 0 return TYPE_HASHREF;
108 }
109 0 ▶ elsif ( $type->is_parameterized and @{ $type->parameters } == 1 and (
Condition0%0/9
$type->is_parameterized and @{$type->parameters;} == 1 and $type->parameterized_from == &ArrayRef() || $type->parameterized_from == &HashRef()
!ll&&!rl&&r
000
$type->is_parameterized and @{$type->parameters;} == 1
!ll&&!rl&&r
000
$type->parameterized_from == &ArrayRef() or $type->parameterized_from == &HashRef()
l!l&&r!l&&!r
000
MC/DC0%0/4
$type->is_parameterized and @{$type->parameters;} == 1 and $type->parameterized_from == &ArrayRef() || $type->parameterized_from == &HashRef()
$type->is_parameterized @{$type->parameters;} == 1 $type->parameterized_from == &ArrayRef() $type->parameterized_from == &HashRef()
Truth table0%0/5
A and B and C or D
A= $type->is_parameterizedB= @{$type->parameters;} == 1C= $type->parameterized_from == &ArrayRef()D= $type->parameterized_from == &HashRef()
ABCDresult
0XXX0
10XX0
11000
111X1
11011
110 $type->parameterized_from == ArrayRef
111 or $type->parameterized_from == HashRef
112 ) ) {
113 0 my $container_type = $type->parameterized_from;
114 0 my $element_type = $type->type_parameter;
115 0 ▶ return _type_to_number( $container_type, 1 ) | _type_to_number( $element_type, 1 ) unless $no_recurse;
Branch: 1 branch
BranchTrueFalseTotal
unless $no_recurse 0 0 0
116 }
117 }
118
119 0 return TYPE_OTHER;
120 }
121  
122 45 ▶no Types::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
123  
124 45 1;
125  
126 __END__
↑ Summary src/types.c »