blib/lib/Salvation/TC/Type/Text.pm

filter: Statementstmt 90.4% 19 / 21 Branchbran 50.0% 2 / 4 Conditioncond 72.7% 8 / 11 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 85.7% 6 / 7 Podpod 50.0% 1 / 2 totaltotal 76.4% 39 / 51 SCAR 20.0
CC
7
Cov
81%
Check
12.0
__ANON__
5.0
BEGIN
1.0
CRAP 7.4
« blib/lib/Salvation/TC/Type/Bool.pm ↑ Summary blib/lib/Salvation/TC/Type/Date/Reverse.pm »
1 package Salvation::TC::Type::Text;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use base 'Salvation::TC::Type';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use Salvation::TC::Exception::WrongType ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 sub Check {
12 0 ▶ my ( $class, $value ) = @_;
Subroutine Check: not called CC=3 SCAR=24.8
Pod documented
13 0 ▶ ( ! ref( $value ) && $value ne '' ) || Salvation::TC::Exception::WrongType -> throw( 'type' => 'Text', 'value' => $value );
Branch: 1 branch
BranchTrueFalseTotal
not ref $value and $value ne "" or "Salvation::TC::Exception::WrongType"->throw("type", "Text", "value", $value) 0 0 0
Condition0%0/3
not ref $value and $value ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
not ref $value and $value ne ""
not ref $value $value ne ""
Truth table0%0/3
not(A) and B
A= not ref $valueB= $value ne ""
ABresult
0X0
100
111
14 }
15  
16 sub create_length_validator {
17  
18 9 ▶ my ( $class, $min, $max ) = @_;
Subroutine create_length_validator: called CC=1 SCAR=0.0
Pod undocumented
19  
20 return sub {
21  
22 22 ▶ my $len = length( $_[ 0 ] );
Subroutine __ANON__: called CC=5 SCAR=16.1
23  
24 22 ▶ if( ( $len < $min ) || ( defined $max && ( $len > $max ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len < $min or defined $max and $len > $max) 7 15 22
Condition100%6/6
$len < $min or defined $max and $len > $max
l!l&&r!l&&!r
3415
defined $max and $len > $max
!ll&&!rl&&r
2134
MC/DC66%2/3
$len < $min or defined $max and $len > $max
$len < $min defined $max $len > $max
Truth table75%3/4
A or B and C
A= $len < $minB= defined $maxC= $len > $max
ABCresult
1XX1
0111
00X0
0100
25  
26 7 ▶ Salvation::TC::Exception::WrongType -> throw(
Condition100%2/2
$max // ""
l!l
61
MC/DC100%1/1
$max // ""
$max
Truth table100%2/2
A
A= $max
Aresult
11
00
27 'type' => sprintf( 'Text{%s,%s}', $min, ( $max // '' ) ),
28 'value' => $_[ 0 ]
29 );
30 }
31  
32 15 1;
33 9 };
34 }
35  
36 4 1
37 __END__
« blib/lib/Salvation/TC/Type/Bool.pm ↑ Summary blib/lib/Salvation/TC/Type/Date/Reverse.pm »