| 1 | package DateTime::Format::Natural::Formatted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 27 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 27 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 27 | ▶ | use boolean qw(true false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 27 | our $VERSION = '0.12'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | sub _parse_formatted_ymd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 271 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_formatted_ymd: called CC=18 SCAR=30.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 271 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 271 | my ($date_string, $count) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 271 | my $date = $self->_split_formatted($date_string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 271 | my $date_sep = quotemeta((keys %$count)[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 271 | my @date_chunks = split /$date_sep/, $date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 271 | ▶ | if ($date_chunks[1] =~ /^[a-zA-Z]+$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$date_chunks[1] =~ /^[a-zA-Z]+$/ and my($month_abbrev) = grep({$date_chunks[1] =~ /^$_$/i;} keys %{$$self{"data"}{"months_abbrev"};})
MC/DC50%1/2
$date_chunks[1] =~ /^[a-zA-Z]+$/ and my($month_abbrev) = grep({$date_chunks[1] =~ /^$_$/i;} keys %{$$self{"data"}{"months_abbrev"};})
$date_chunks[1] =~ /^[a-zA-Z]+$/
my($month_abbrev) = grep({$date_chunks[1] =~ /^$_$/i;} keys %{$$self{"data"}{"months_abbrev"};})
Truth table66%2/3
A and B
A= $date_chunks[1] =~ /^[a-zA-Z]+$/B= my($month_abbrev) = grep({$date_chunks[1] =~ /^$_$/i;} keys %{$$self{"data"}{"months_abbrev"};})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 84 | and my ($month_abbrev) = grep { $date_chunks[1] =~ /^${_}$/i } keys %{$self->{data}->{months_abbrev}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 7 | my ($months_abbrev, $months) = map $self->{data}->{$_}, qw(months_abbrev months); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 7 | $date_chunks[1] = sprintf '%02d', $months->{$months_abbrev->{$month_abbrev}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 271 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 271 | my %chunks_length = map { length $_ => $i++ } @date_chunks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 271 | my $format = lc $self->{Format}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 271 | my $format_sep; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 271 | my $lax = false; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 271 | ▶ | if (exists $chunks_length{4}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | $format = join $date_sep, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 253 | ▶ | ($chunks_length{4} == 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ? qw(yyyy mm dd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | : ($format =~ /^m/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ? qw(mm dd yyyy) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | : qw(dd mm yyyy) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 253 | $lax = true; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ▶ | elsif ($date_sep =~ /^\\[-.]$/ && $format !~ /$date_sep/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$date_sep =~ /^\\[-.]$/ and not $format =~ /$date_sep/
MC/DC50%1/2
$date_sep =~ /^\\[-.]$/ and not $format =~ /$date_sep/
$date_sep =~ /^\\[-.]$/
not $format =~ /$date_sep/
Truth table66%2/3
A and not(B)
A= $date_sep =~ /^\\[-.]$/B= not $format =~ /$date_sep/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 12 | $format = join $date_sep, qw(dd mm yy); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 12 | $lax = true; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 6 | $format_sep = do { local $_ = $format; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 6 | tr/a-zA-Z//d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 6 | tr/a-zA-Z//cs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | quotemeta; }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 271 | ▶ | $format_sep ||= $date_sep; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$format_sep ||= $date_sep
MC/DC0%0/2
$format_sep ||= $date_sep
$format_sep
$date_sep
Truth table66%2/3
A ||= B
A= $format_sepB= $date_sep
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 271 | ▶ | if (!$lax && $format_sep ne $date_sep) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $lax and $format_sep ne $date_sep
MC/DC0%0/2
not $lax and $format_sep ne $date_sep
not $lax
$format_sep ne $date_sep
Truth table66%2/3
not(A) and B
A= not $laxB= $format_sep ne $date_sep
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $self->_set_failure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $self->_set_error("(mismatch between format and date separator)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | return $self->_get_datetime_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 271 | my @format_order = split /$format_sep/, $format; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 271 | my ($d, $m, $y) = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 271 | my %f = map { substr($_, 0, 1) => true } @format_order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 271 | ($f{d}, $f{m}, $f{y}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 271 | ▶ | unless (@format_order == 3 and $d && $m && $y) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
@format_order == 3 and ($d and $m and $y)
$d and $m and $y
$d and $m
MC/DC0%0/4
@format_order == 3 and ($d and $m and $y)
@format_order == 3
$d
$m
$y
Truth table20%1/5
A and B and C and D
A= @format_order == 3B= $dC= $mD= $y
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $self->_set_failure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $self->_set_error("('format' parameter invalid)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | return $self->_get_datetime_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 271 | $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 271 | my %format_index = map { substr($_, 0, 1) => $i++ } @format_order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | my $century = $self->{datetime} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 271 | ▶ | ? int($self->{datetime}->year / 100) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | : substr((localtime)[5] + 1900, 0, 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 271 | my ($day, $month, $year) = map $date_chunks[$format_index{$_}], qw(d m y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 271 | ▶ | if (length $year == 2) { $year = "$century$year" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 271 | ▶ | unless ($self->_check_date($year, $month, $day)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | $self->_set_failure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | $self->_set_error("(invalid date)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | return $self->_get_datetime_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | $self->_set( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 270 | year => $year, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | month => $month, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | day => $day, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 270 | $self->{datetime}->truncate(to => 'day'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 270 | $self->_set_truncated; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 270 | $self->_set_valid_exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 270 | $self->_process_tokens; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 270 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | sub _parse_formatted_md | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 193 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_formatted_md: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 193 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 193 | my ($date_string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 193 | my $date = $self->_split_formatted($date_string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 193 | my @date_chunks = split /\//, $date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | my $format = $self->{Format} =~ m{^[dm]{1,2}/[dm]{1,2}$}i | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 193 | ▶ | ? do { local $_ = lc $self->{Format}; tr/dm//s; $_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 193 | ▶ | unless (defined $format && $format =~ m{^(?:(?:m/d)|(?:d/m))$}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $format and $format =~ m[^(?:(?:m/d)|(?:d/m))$]
MC/DC50%1/2
defined $format and $format =~ m[^(?:(?:m/d)|(?:d/m))$]
defined $format
$format =~ m[^(?:(?:m/d)|(?:d/m))$]
Truth table66%2/3
A and B
A= defined $formatB= $format =~ m[^(?:(?:m/d)|(?:d/m))$]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | $self->_set_failure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | $self->_set_error("('format' parameter invalid)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | return $self->_get_datetime_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 192 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 192 | my %format_index = map { $_ => $i++ } split /\//, $format; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 192 | my ($day, $month) = map $date_chunks[$format_index{$_}], qw(d m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 192 | ▶ | unless ($self->_check_date($self->{datetime}->year, $month, $day)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $self->_set_failure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $self->_set_error("(invalid date)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | return $self->_get_datetime_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | $self->_set( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 192 | month => $month, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | day => $day, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 192 | $self->{datetime}->truncate(to => 'day'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 192 | $self->_set_truncated; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 192 | $self->_set_valid_exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 192 | $self->_process_tokens; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 192 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | sub _split_formatted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 464 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_formatted: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 464 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 464 | my ($date_string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 464 | my $date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 464 | ▶ | if ($date_string =~ /^\S+\b \s+ \b\S+/x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 321 | ($date, @{$self->{tokens}}) = split /\s+/, $date_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 321 | $self->{count}{tokens} = 1 + @{$self->{tokens}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 143 | $self->{count}{tokens} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 464 | ▶ | return defined $date ? $date : $date_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | sub _process_tokens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 462 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_tokens: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 462 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 462 | ▶ | if (@{$self->{tokens}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 321 | $self->{count}{tokens}--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 321 | $self->_unset_truncated; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 321 | $self->_unset_valid_exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 321 | $self->_process; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | sub _count_separators | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 515051 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_count_separators: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 515051 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 515051 | my ($formatted) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 515051 | my %count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 515051 | ▶ | if (defined $formatted) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 10664 | my @count = $formatted =~ m![-./]!g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 10664 | $count{$_}++ foreach @count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 515051 | return %count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | sub _check_formatted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 527956 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_formatted: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 527956 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 527956 | my ($check, $count) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | my %checks = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | ymd => sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 515051 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 515051 | my ($count) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 515051 | ▶ | return scalar keys %$count == 1 && $count->{(keys %$count)[0]} == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
scalar keys %$count == 1 && $$count{(keys %$count)[0]} == 2
MC/DC100%2/2
scalar keys %$count == 1 && $$count{(keys %$count)[0]} == 2
scalar keys %$count == 1
$$count{(keys %$count)[0]} == 2
Truth table100%3/3
A && B
A= scalar keys %$count == 1B= $$count{(keys %$count)[0]} == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | md => sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 12905 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 12905 | my ($count) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 12905 | ▶ | return scalar keys %$count == 1 && $count->{(keys %$count)[0]} == 1 && (keys %$count)[0] eq '/'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
scalar keys %$count == 1 && $$count{(keys %$count)[0]} == 1 && (keys %$count)[0] eq '/'
scalar keys %$count == 1 and $$count{(keys %$count)[0]} == 1
MC/DC33%1/3
scalar keys %$count == 1 && $$count{(keys %$count)[0]} == 1 && (keys %$count)[0] eq '/'
scalar keys %$count == 1
$$count{(keys %$count)[0]} == 1
(keys %$count)[0] eq '/'
Truth table50%2/4
A and B && C
A= scalar keys %$count == 1B= $$count{(keys %$count)[0]} == 1C= (keys %$count)[0] eq '/'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 527956 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 527956 | return $checks{$check}->($count); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 27 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||