| 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
Condition0%0/3
defined $time and $time =~ /$re/
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/
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | my ( $hours, $minutes, $seconds ) = ( $1, $2, $3 ); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | $seconds ||= '00'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$seconds ||= "00"
MC/DC0%0/1
$seconds ||= "00"
$seconds
Truth table0%0/2
A
A= $seconds
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
int $hours >= 0 and int $hours <= 23
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
| |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | die "Minutes must be bettween 0 and 23. Current value is $minutes." unless int( $minutes ) >= 0 && int( $minutes ) <= 59; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
int $minutes >= 0 and int $minutes <= 59
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
| |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | die "Seconds must be bettween 0 and 23. Current value is $seconds." unless int( $seconds ) >= 0 && int( $seconds ) <= 59; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
int $seconds >= 0 and int $seconds <= 59
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
| |||||||||||||||||||||||||||||
| 25 | }; | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if( $@ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | Salvation::TC::Exception::WrongType -> throw( type => 'Time', value => $time ); | |||||||||||||||||||||||||||
| 30 | }; | ||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 4 | 1; | |||||||||||||||||||||||||||
| 34 | __END__ | ||||||||||||||||||||||||||||