blib/lib/Mite/Signature/Compiler.pm

filter: Statementstmt 90.9% 40 / 44 Branchbran 60.0% 6 / 10 Conditioncond 35.2% 6 / 17 MC/DCmcdc 10.0% 1 / 10 Subroutinesub 100% 10 / 10 Podpod 100% 1 / 1 totaltotal 69.5% 64 / 92 CC 12 SCAR 18.7
CC
12
Cov
73%
_make_count_fail
10.6
_make_constraint_fail
8.7
BEGIN
1.0
CRAP 6.5
« lib/Mite/Miteception.pm ↑ Summary lib/Mite/Trait/HasRoles.pm »
1 8 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Mite::Signature::Compiler;
6  
7 8 ▶use Type::Params::Signature 1.016008 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use Types::Standard qw( Slurpy );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 8 our @ISA = 'Type::Params::Signature';
12  
13 10 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod documented
14 10 my $self = shift;
15  
16 10 Scalar::Util::weaken( $self->{mite_signature} );
17  
18 # This is not a Mite class, so manually call
19 # parent BUILD:
20 10 $self->SUPER::BUILD( @_ );
21 }
22  
23 19 ▶sub _make_general_fail {
Subroutine _make_general_fail: called CC=1 SCAR=0.0
24 19 my ( $self, %args ) = @_;
25  
26 19 my $croaker = $self->{mite_signature}->class->_function_for_croak;
27  
28 19 return sprintf '%s( "Failure in signature for %s: " . %s )', $croaker, $self->subname, $args{message};
29 }
30  
31 28 ▶sub _make_constraint_fail {
Subroutine _make_constraint_fail: called CC=5 SCAR=21.6
32 28 my ( $self, %args ) = @_;
33  
34 28 my $type = $args{constraint};
35 28 ▶ if ( $type->parent and $type->parent->{uniq} == Slurpy->{uniq} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type->parent and $type->parent->{"uniq"} == &Slurpy()->{"uniq"}) 0 28 28
Condition33%1/3
$type->parent and $type->parent->{"uniq"} == &Slurpy()->{"uniq"}
!ll&&!rl&&r
0280
MC/DC0%0/2
$type->parent and $type->parent->{"uniq"} == &Slurpy()->{"uniq"}
$type->parent $type->parent->{"uniq"} == &Slurpy()->{"uniq"}
Truth table33%1/3
A and B
A= $type->parentB= $type->parent->{"uniq"} == &Slurpy()->{"uniq"}
ABresult
0X0
100
111
36 0 ▶ $type = $type->type_parameter || $type;
Condition0%0/3
$type->type_parameter || $type
l!l&&r!l&&!r
000
MC/DC0%0/2
$type->type_parameter || $type
$type->type_parameter $type
Truth table0%0/3
A || B
A= $type->type_parameterB= $type
ABresult
1X1
011
000
37 }
38  
39 28 my $croaker = $self->{mite_signature}->class->_function_for_croak;
40  
41 return sprintf '%s( "Type check failed in signature for %s: %%s should be %%s", %s, %s )',
42 28 ▶ $croaker, $self->subname, B::perlstring( $args{display_var} || $args{varname} ), B::perlstring( $type->display_name );
Condition33%1/3
$args{'display_var'} || $args{'varname'}
l!l&&r!l&&!r
2800
MC/DC0%0/2
$args{'display_var'} || $args{'varname'}
$args{'display_var'} $args{'varname'}
Truth table33%1/3
A || B
A= $args{'display_var'}B= $args{'varname'}
ABresult
1X1
011
000
43 }
44  
45 10 ▶sub _make_count_fail {
Subroutine _make_count_fail: called CC=8 SCAR=23.6
46 10 my ( $self, %args ) = @_;
47  
48 10 my $msg;
49 10 my $min = $args{minimum};
50 10 my $max = $args{minimum};
51
52 10 ▶ if ( defined $min and defined $max and $min==$max ) {
Branch: 3 branches
BranchTrueFalseTotal
if (defined $min and defined $max and $min == $max) { } 4 6 10
elsif (defined $max) { } 0 6 6
elsif (defined $min) { } 0 6 6
Condition66%4/6
defined $min and defined $max and $min == $max
!ll&&!rl&&r
604
defined $min and defined $max
!ll&&!rl&&r
604
MC/DC33%1/3
defined $min and defined $max and $min == $max
defined $min defined $max $min == $max
Truth table50%2/4
A and B and C
A= defined $minB= defined $maxC= $min == $max
ABCresult
0XX0
10X0
1100
1111
53 4 $msg = sprintf 'expected exactly %d parameters', $min;
54 }
55 elsif ( defined $max ) {
56 0 ▶ $msg = sprintf 'expected between %d and %d parameters', $min || 0, $max;
Condition0%0/2
$min || 0
l!l
00
MC/DC0%0/1
$min || 0
$min
Truth table0%0/2
A
A= $min
Aresult
11
00
57 }
58 elsif ( defined $min ) {
59 0 $msg = sprintf 'expected at least %d parameters', $min;
60 }
61 else {
62 6 $msg = 'that does not seem right';
63 }
64  
65 10 my $croaker = $self->{mite_signature}->class->_function_for_croak;
66  
67 10 ▶ if ( $args{got} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'got'}) { } 10 0 10
68 return sprintf '%s( "Wrong number of parameters in signature for %%s: got %%d, %%s", %s, %s, %s )',
69 10 $croaker, B::perlstring( $self->subname ), $args{got}, B::perlstring( $msg );
70 }
71 else {
72 0 return sprintf '%s( "Wrong number of parameters in signature for %%s: got ???, %%s", %s, %s )',
73 $croaker, B::perlstring( $self->subname ), B::perlstring( $msg );
74 }
75
76 }
77  
78 8 1;
« lib/Mite/Miteception.pm ↑ Summary lib/Mite/Trait/HasRoles.pm »