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

filter: Statementstmt 52.3% 11 / 21 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 25.4% 15 / 59 SCAR 41.5
CC
11
Cov
24%
Check
132.0
BEGIN
1.0
BEGIN
1.0
CRAP 63.2
« blib/lib/Salvation/TC/Parser/PP.pm ↑ Summary blib/lib/Salvation/TC/Type/Date.pm »
1 package Salvation::TC::Type::Time;
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 my $re = qr/^(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/;
9  
10 sub Check {
11  
12 0 ▶ my ( $class, $time ) = @_;
Subroutine Check: not called CC=11 SCAR=48.8
Pod documented
13  
14 0 eval {
15  
16 0 ▶ die 'Wrong time format.' if ( ! defined( $time ) || $time !~ $re );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $time and $time =~ /$re/ 0 0 0
Condition0%0/3
defined $time and $time =~ /$re/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $time and $time =~ /$re/
defined $time $time =~ /$re/
Truth table0%0/3
A and B
A= defined $timeB= $time =~ /$re/
ABresult
0X0
100
111
17  
18 0 my ( $hours, $minutes, $seconds ) = ( $1, $2, $3 );
19  
20 0 ▶ $seconds ||= '00';
Condition0%0/2
$seconds ||= "00"
l!l
00
MC/DC0%0/1
$seconds ||= "00"
$seconds
Truth table0%0/2
A
A= $seconds
Aresult
11
00
21  
22 0 ▶ die "Hours must be bettween 0 and 23. Current value is $hours." unless int( $hours ) >= 0 && int( $hours ) <= 23;
Branch: 1 branch
BranchTrueFalseTotal
unless int $hours >= 0 and int $hours <= 23 0 0 0
Condition0%0/3
int $hours >= 0 and int $hours <= 23
!ll&&!rl&&r
000
MC/DC0%0/2
int $hours >= 0 and int $hours <= 23
int $hours >= 0 int $hours <= 23
Truth table0%0/3
A and B
A= int $hours >= 0B= int $hours <= 23
ABresult
0X0
100
111
23 0 ▶ die "Minutes must be bettween 0 and 23. Current value is $minutes." unless int( $minutes ) >= 0 && int( $minutes ) <= 59;
Branch: 1 branch
BranchTrueFalseTotal
unless int $minutes >= 0 and int $minutes <= 59 0 0 0
Condition0%0/3
int $minutes >= 0 and int $minutes <= 59
!ll&&!rl&&r
000
MC/DC0%0/2
int $minutes >= 0 and int $minutes <= 59
int $minutes >= 0 int $minutes <= 59
Truth table0%0/3
A and B
A= int $minutes >= 0B= int $minutes <= 59
ABresult
0X0
100
111
24 0 ▶ die "Seconds must be bettween 0 and 23. Current value is $seconds." unless int( $seconds ) >= 0 && int( $seconds ) <= 59;
Branch: 1 branch
BranchTrueFalseTotal
unless int $seconds >= 0 and int $seconds <= 59 0 0 0
Condition0%0/3
int $seconds >= 0 and int $seconds <= 59
!ll&&!rl&&r
000
MC/DC0%0/2
int $seconds >= 0 and int $seconds <= 59
int $seconds >= 0 int $seconds <= 59
Truth table0%0/3
A and B
A= int $seconds >= 0B= int $seconds <= 59
ABresult
0X0
100
111
25 };
26  
27 0 ▶ if( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
28  
29 0 Salvation::TC::Exception::WrongType -> throw( type => 'Time', value => $time );
30 };
31 }
32  
33 4 1;
34 __END__
« blib/lib/Salvation/TC/Parser/PP.pm ↑ Summary blib/lib/Salvation/TC/Type/Date.pm »