| 1 | package Salvation::TC::Type::Date::Reverse; | ||||||||||||||||||||||||||||
| 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::Date'; | ||||||||||||||||||||||||||
|
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 | 4 | my $re = qr/^(\d{4})[\.\/\-](\d{1,2})[\.\/\-](\d{1,2})\s*(\d+:\d+(:\d+)*?)?$/; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | sub Check { | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 0 | ▶ | my ( $class, $date ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
Check: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 0 | eval { | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | die "Wrong date format. Expected year[.-/]month[./-]day time" if ( ! defined( $date ) || $date !~ $re ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $date and $date =~ /$re/
MC/DC0%0/2
defined $date and $date =~ /$re/
defined $date
$date =~ /$re/
Truth table0%0/3
A and B
A= defined $dateB= $date =~ /$re/
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | my ( $year, $month, $day, $time ) = ( $1, $2, $3, $4 ); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | $class->SUPER::Check( "$day.$month.$year $time" ); | |||||||||||||||||||||||||||
| 23 | }; | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | if( $@ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | Salvation::TC::Exception::WrongType -> throw( type => 'Date::Reverse', value => $date ); | |||||||||||||||||||||||||||
| 28 | }; | ||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 4 | 1; | |||||||||||||||||||||||||||
| 32 | __END__ | ||||||||||||||||||||||||||||