| 1 | # Copyrights 2006-2024 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.03. | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # This code is part of distribution XML-Compile. Meta-POD processed with | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | package XML::Compile::Schema::BuiltInFacets;{ | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 50 | our $VERSION = '1.64'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 50 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 50 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 50 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 50 | ▶ | no warnings 'recursion'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 50 | our @EXPORT = qw/builtin_facet/; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 50 | ▶ | use Log::Report 'xml-compile'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 50 | ▶ | use Math::BigInt; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 50 | ▶ | use Math::BigFloat; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 50 | ▶ | use XML::LibXML; # for ::RegExp | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 50 | ▶ | use XML::Compile::Util qw/SCHEMA2001 pack_type duration2secs/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 50 | ▶ | use POSIX qw/DBL_MAX_10_EXP DBL_DIG/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | # depend on Perl's compile flags | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 50 | ▶ | use constant INT_MAX => int((sprintf"%u\n",-1)/2); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 50 | ▶ | use constant INT_MIN => -1 - INT_MAX; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 50 | my %facets_simple = | |||||||||||||||||||||||||||||||||||||||||
| 36 | ( enumeration => \&_enumeration | ||||||||||||||||||||||||||||||||||||||||||
| 37 | , fractionDigits => \&_s_fractionDigits | ||||||||||||||||||||||||||||||||||||||||||
| 38 | , length => \&_s_length | ||||||||||||||||||||||||||||||||||||||||||
| 39 | , maxExclusive => \&_s_maxExclusive | ||||||||||||||||||||||||||||||||||||||||||
| 40 | , maxInclusive => \&_s_maxInclusive | ||||||||||||||||||||||||||||||||||||||||||
| 41 | , maxLength => \&_s_maxLength | ||||||||||||||||||||||||||||||||||||||||||
| 42 | , maxScale => undef # ignore | ||||||||||||||||||||||||||||||||||||||||||
| 43 | , minExclusive => \&_s_minExclusive | ||||||||||||||||||||||||||||||||||||||||||
| 44 | , minInclusive => \&_s_minInclusive | ||||||||||||||||||||||||||||||||||||||||||
| 45 | , minLength => \&_s_minLength | ||||||||||||||||||||||||||||||||||||||||||
| 46 | , minScale => undef # ignore | ||||||||||||||||||||||||||||||||||||||||||
| 47 | , pattern => \&_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 48 | , totalDigits => \&_s_totalDigits | ||||||||||||||||||||||||||||||||||||||||||
| 49 | , whiteSpace => \&_s_whiteSpace | ||||||||||||||||||||||||||||||||||||||||||
| 50 | , _totalFracDigits=> \&_s_totalFracDigits | ||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 50 | my %facets_list = | |||||||||||||||||||||||||||||||||||||||||
| 54 | ( enumeration => \&_enumeration | ||||||||||||||||||||||||||||||||||||||||||
| 55 | , length => \&_list_length | ||||||||||||||||||||||||||||||||||||||||||
| 56 | , maxLength => \&_list_maxLength | ||||||||||||||||||||||||||||||||||||||||||
| 57 | , minLength => \&_list_minLength | ||||||||||||||||||||||||||||||||||||||||||
| 58 | , pattern => \&_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 59 | , whiteSpace => \&_list_whiteSpace | ||||||||||||||||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 50 | my %facets_date = # inclusive or exclusive times is rather useless. | |||||||||||||||||||||||||||||||||||||||||
| 63 | ( enumeration => \&_enumeration | ||||||||||||||||||||||||||||||||||||||||||
| 64 | , explicitTimeZone=> \&_date_expl_tz | ||||||||||||||||||||||||||||||||||||||||||
| 65 | , maxExclusive => \&_date_max | ||||||||||||||||||||||||||||||||||||||||||
| 66 | , maxInclusive => \&_date_max | ||||||||||||||||||||||||||||||||||||||||||
| 67 | , minExclusive => \&_date_min | ||||||||||||||||||||||||||||||||||||||||||
| 68 | , minInclusive => \&_date_min | ||||||||||||||||||||||||||||||||||||||||||
| 69 | , pattern => \&_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 70 | , whiteSpace => \&_date_whiteSpace | ||||||||||||||||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 50 | my %facets_duration = | |||||||||||||||||||||||||||||||||||||||||
| 74 | ( enumeration => \&_enumeration | ||||||||||||||||||||||||||||||||||||||||||
| 75 | , maxExclusive => \&_dur_max_excl | ||||||||||||||||||||||||||||||||||||||||||
| 76 | , maxInclusive => \&_dur_max_incl | ||||||||||||||||||||||||||||||||||||||||||
| 77 | , minExclusive => \&_dur_min_excl | ||||||||||||||||||||||||||||||||||||||||||
| 78 | , minInclusive => \&_dur_min_incl | ||||||||||||||||||||||||||||||||||||||||||
| 79 | , pattern => \&_pattern | ||||||||||||||||||||||||||||||||||||||||||
| 80 | , whiteSpace => \&_s_whiteSpace | ||||||||||||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 50 | my $date_time_type = pack_type SCHEMA2001, 'dateTime'; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 50 | my $date_type = pack_type SCHEMA2001, 'date'; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 50 | my $duration_type = pack_type SCHEMA2001, 'duration'; | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | sub builtin_facet($$$$$$$$) | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 243 | ▶ | { my ($path, $args, $facet, $value, $is_list, $type, $nss, $action) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
builtin_facet: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | my $def | ||||||||||||||||||||||||||||||||||||||||||
| 91 | = $is_list ? $facets_list{$facet} | ||||||||||||||||||||||||||||||||||||||||||
| 92 | : $nss->doesExtend($type, $date_time_type) ? $facets_date{$facet} | ||||||||||||||||||||||||||||||||||||||||||
| 93 | : $nss->doesExtend($type, $date_type) ? $facets_date{$facet} | ||||||||||||||||||||||||||||||||||||||||||
| 94 | : $nss->doesExtend($type, $duration_type) ? $facets_duration{$facet} | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 243 | ▶ | : $facets_simple{$facet}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 243 | ▶ | $def or error __x"facet {facet} not implemented at {where}" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | , facet => $facet, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 243 | $def->($path, $args, $value, $type, $nss, $action); | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | sub _list_whiteSpace($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | { my ($path, undef, $ws) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_list_whiteSpace: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | $ws eq 'collapse' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | or error __x"list whiteSpace facet fixed to 'collapse', not '{ws}' in {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 107 | , ws => $ws, path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | (); | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | sub _s_whiteSpace($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 6 | ▶ | { my ($path, undef, $ws) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_s_whiteSpace: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 6 | ▶ | $ws eq 'replace' ? \&_whitespace_replace | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | : $ws eq 'collapse' ? \&_whitespace_collapse | ||||||||||||||||||||||||||||||||||||||||||
| 115 | : $ws eq 'preserve' ? () | ||||||||||||||||||||||||||||||||||||||||||
| 116 | : error __x"illegal whiteSpace facet '{ws}' in {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 117 | , ws => $ws, path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | sub _date_whiteSpace($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | { my ($path, undef, $ws) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_date_whiteSpace: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | # whitespace processing already in the dateTime parser | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | $ws eq 'collapse' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | or error __x"illegal whiteSpace facet '{ws}' in {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 126 | , ws => $ws, path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | (); | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | sub _whitespace_replace($) | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | ▶ | { my $value = ref $_[0] ? $_[0]->textContent : $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_whitespace_replace: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | $value =~ s/[\t\r\n]/ /gs; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | $value; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | sub _whitespace_collapse($) | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 | ▶ | { my $value = ref $_[0] ? $_[0]->textContent : $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_whitespace_collapse: called CC=3 SCAR=11.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | for($value) | |||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | { s/[\t\r\n ]+/ /gs; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | s/^ +//; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | s/ +$//; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | $value; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | sub _maybe_big($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 72 | ▶ | { my ($path, $args, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_big: called CC=14 SCAR=41.9
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 72 | ▶ | return $value if $args->{sloppy_integers}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | # modules Math::Big* loaded by Schema::Spec when not sloppy | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 70 | $value =~ s/\s//g; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 70 | ▶ | if($value =~ m/[.eE]/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | { my $c = $value; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | my $exp = $c =~ s/[eE][+-]?([0-9]+)// ? $1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | my $pre = $c =~ /^[-+]?([0-9]*)/ ? length($1) : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | return Math::BigFloat->new($value) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pre >= 15 or $pre + $exp >= 308
MC/DC0%0/2
$pre >= 15 or $pre + $exp >= 308
$pre >= 15
$pre + $exp >= 308
Truth table0%0/3
A or B
A= $pre >= 15B= $pre + $exp >= 308
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | if $pre >= DBL_DIG || $pre+$exp >= DBL_MAX_10_EXP; | ||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | # compare ints as strings, because they will overflow!! | ||||||||||||||||||||||||||||||||||||||||||
| 161 | elsif(substr($value, 0, 1) eq '-') | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | { return Math::BigInt->new($value) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
length $value > 21 or length $value == 21 and $value gt "-9.22337203685478e+18"
length $value == 21 and $value gt "-9.22337203685478e+18"
MC/DC0%0/3
length $value > 21 or length $value == 21 and $value gt "-9.22337203685478e+18"
length $value > 21
length $value == 21
$value gt "-9.22337203685478e+18"
Truth table0%0/4
A or B and C
A= length $value > 21B= length $value == 21C= $value gt "-9.22337203685478e+18"
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | if length($value) > length(INT_MIN) | ||||||||||||||||||||||||||||||||||||||||||
| 164 | || (length($value)==length(INT_MIN) && $value gt INT_MIN); | ||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | else | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 70 | ▶ | { return Math::BigInt->new($value) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
length $value > 19 or length $value == 19 and $value gt '9223372036854775808'
length $value == 19 and $value gt '9223372036854775808'
MC/DC33%1/3
length $value > 19 or length $value == 19 and $value gt '9223372036854775808'
length $value > 19
length $value == 19
$value gt '9223372036854775808'
Truth table50%2/4
A or B and C
A= length $value > 19B= length $value == 19C= $value gt '9223372036854775808'
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | if length($value) > length(INT_MAX) | ||||||||||||||||||||||||||||||||||||||||||
| 169 | || (length($value)==length(INT_MAX) && $value gt INT_MAX); | ||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 64 | $value; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | sub _s_minInclusive($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 33 | ▶ | { my ($path, $args, $min) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_s_minInclusive: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 33 | $min = _maybe_big $path, $args, $min; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 26 | ▶ | sub { return $_[0] if $_[0] >= $min; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 7 | error __x"too small inclusive {value}, min {min} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 180 | , value => $_[0], min => $min, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 33 | }; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | sub _s_minExclusive($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 6 | ▶ | { my ($path, $args, $min) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_s_minExclusive: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 6 | $min = _maybe_big $path, $args, $min; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 6 | ▶ | sub { return $_[0] if $_[0] > $min; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 2 | error __x"too small exclusive {value}, larger {min} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 189 | , value => $_[0], min => $min, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | sub _s_maxInclusive($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 21 | ▶ | { my ($path, $args, $max) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_s_maxInclusive: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 21 | $max = _maybe_big $path, $args, $max; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 18 | ▶ | sub { return $_[0] if $_[0] <= $max; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 6 | error __x"too large inclusive {value}, max {max} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 198 | , value => $_[0], max => $max, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 21 | }; | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | sub _s_maxExclusive($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 12 | ▶ | { my ($path, $args, $max) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_s_maxExclusive: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 12 | $max = _maybe_big $path, $args, $max; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 5 | ▶ | sub { return $_[0] if $_[0] < $max; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | error __x"too large exclusive {value}, smaller {max} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 207 | , value => $_[0], max => $max, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 50 | my $qname = pack_type SCHEMA2001, 'QName'; | |||||||||||||||||||||||||||||||||||||||||
| 212 | sub _enumeration($$$$$$) | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 62 | ▶ | { my ($path, $args, $enums, $type, $nss, $action) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_enumeration: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 62 | my %enum = map +($_ => 1), @$enums; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 48 | ▶ | sub { my $v = ref $_[0] eq 'ARRAY' ? join(' ', @{$_[0]}) : $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 48 | ▶ | return $v if exists $enum{$v}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 18 | error __x"invalid enumerate `{string}' at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 219 | , string => $v, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 62 | }; | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | sub _s_totalDigits($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 26 | ▶ | { my ($path, undef, $total) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_s_totalDigits: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | # this accidentally also works correctly for NaN +INF -INF | ||||||||||||||||||||||||||||||||||||||||||
| 227 | sub | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 26 | ▶ | { my $v = $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 26 | $v =~ s/[eE].*//; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 26 | $v =~ s/^[+-]?0*//; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 26 | ▶ | return $_[0] if $total >= ($v =~ tr/0-9//); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | error __x"decimal too long, got {length} digits max {max} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 234 | , length => ($v =~ tr/0-9//), max => $total, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 26 | }; | |||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | sub _s_fractionDigits($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | ▶ | { my $frac = $_[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_s_fractionDigits: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | # can be result from Math::BigFloat, so too long to use %f But rounding | ||||||||||||||||||||||||||||||||||||||||||
| 241 | # is very hard to implement. If you need this accuracy, then format your | ||||||||||||||||||||||||||||||||||||||||||
| 242 | # value yourself! | ||||||||||||||||||||||||||||||||||||||||||
| 243 | sub | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 4 | ▶ | { my $v = $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 4 | $v =~ s/(\.[0-9]{$frac}).*/$1/; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 4 | $v; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | sub _s_totalFracDigits($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 3 | ▶ | { my ($path, undef, $dig) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_s_totalFracDigits: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 3 | my ($total, $frac) = @$dig; | |||||||||||||||||||||||||||||||||||||||||
| 253 | sub | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 4 | ▶ | { my $w = $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 4 | my $v = $w; # total is checking length | |||||||||||||||||||||||||||||||||||||||||
| 257 | 4 | $v =~ s/[eE].*//; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 4 | $v =~ s/^[+-]?0*//; | |||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 4 | ▶ | if( $v !~ /^(?:[+-]?)(?:[0-9]*)(?:\.([0-9]*))?$/ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | { error __x"Invalid numeric format, got {value} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 262 | , value => $w, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 4 | ▶ | if($1 && length($1) > $frac) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$1 and length $1 > $frac
MC/DC50%1/2
$1 and length $1 > $frac
$1
length $1 > $frac
Truth table66%2/3
A and B
A= $1B= length $1 > $frac
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | { error __x"fractional part for {value} too long, got {l} digits max {max} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 267 | , value => $w, l => length($1), max => $frac, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 3 | ▶ | return $w if $total >= ($v =~ tr/0-9//); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | error __x"decimal too long, got {length} digits max {max} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 272 | , length => ($v =~ tr/0-9//), max => $total, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | sub _s_length($$$$$$) | ||||||||||||||||||||||||||||||||||||||||||
| 277 | 19 | ▶ | { my ($path, $args, $len, $type, $nss, $action) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_s_length: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 15 | ▶ | sub { return $_[0] if defined $_[0] && length($_[0])==$len; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
Branch: 1 branch
Condition66%2/3
defined $_[0] and length $_[0] == $len
MC/DC50%1/2
defined $_[0] and length $_[0] == $len
defined $_[0]
length $_[0] == $len
Truth table66%2/3
A and B
A= defined $_[0]B= length $_[0] == $len
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 9 | error __x"string `{string}' does not have required length {len} but {size} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 281 | , string => $_[0], len => $len, size => length($_[0]), where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 19 | }; | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | sub _list_length($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 6 | ▶ | { my ($path, $args, $len) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_list_length: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 6 | ▶ | sub { return $_[0] if defined $_[0] && @{$_[0]}==$len; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
Condition66%2/3
defined $_[0] and @{$_[0];} == $len
MC/DC50%1/2
defined $_[0] and @{$_[0];} == $len
defined $_[0]
@{$_[0];} == $len
Truth table66%2/3
A and B
A= defined $_[0]B= @{$_[0];} == $len
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 4 | error __x"list `{list}' does not have required length {len} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 289 | , list => $_[0], len => $len, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | sub _s_minLength($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 8 | ▶ | { my ($path, $args, $len, $type, $nss, $action) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_s_minLength: called CC=1 SCAR=0.8
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 4 | ▶ | sub { return $_[0] if defined $_[0] && length($_[0]) >=$len; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=15.4
Branch: 1 branch
Condition33%1/3
defined $_[0] and length $_[0] >= $len
MC/DC0%0/2
defined $_[0] and length $_[0] >= $len
defined $_[0]
length $_[0] >= $len
Truth table33%1/3
A and B
A= defined $_[0]B= length $_[0] >= $len
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | error __x"string `{string}' does not have minimum length {len} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 298 | , string => $_[0], len => $len, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | sub _list_minLength($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | { my ($path, $args, $len) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_list_minLength: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | sub { return $_[0] if defined $_[0] && @{$_[0]} >=$len; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
Condition0%0/3
defined $_[0] and @{$_[0];} >= $len
MC/DC0%0/2
defined $_[0] and @{$_[0];} >= $len
defined $_[0]
@{$_[0];} >= $len
Truth table0%0/3
A and B
A= defined $_[0]B= @{$_[0];} >= $len
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | error __x"list `{list}' does not have minimum length {len} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 306 | , list => $_[0], len => $len, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | sub _s_maxLength($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | { my ($path, $args, $len, $type, $nss, $action) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_s_maxLength: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | sub { return $_[0] if defined $_[0] && length $_[0] <= $len; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
Condition0%0/3
defined $_[0] and length $_[0] <= $len
MC/DC0%0/2
defined $_[0] and length $_[0] <= $len
defined $_[0]
length $_[0] <= $len
Truth table0%0/3
A and B
A= defined $_[0]B= length $_[0] <= $len
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | error __x"string `{string}' longer than maximum length {len} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 315 | , string => $_[0], len => $len, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | sub _list_maxLength($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | { my ($path, $args, $len) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_list_maxLength: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | sub { return $_[0] if defined $_[0] && @{$_[0]} <= $len; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
Condition0%0/3
defined $_[0] and @{$_[0];} <= $len
MC/DC0%0/2
defined $_[0] and @{$_[0];} <= $len
defined $_[0]
@{$_[0];} <= $len
Truth table0%0/3
A and B
A= defined $_[0]B= @{$_[0];} <= $len
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | error __x"list `{list}' longer than maximum length {len} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 323 | , list => $_[0], len => $len, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | sub _pattern($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 30 | ▶ | { my ($path, $args, $pats) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pattern: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 30 | ▶ | @$pats or return (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 30 | ▶ | my $regex = @$pats==1 ? $pats->[0] : "(".join(')|(', @$pats).")"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 30 | my $compiled = XML::LibXML::RegExp->new($regex); | |||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 26 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 50 | ▶ | use Carp 'cluck'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | 26 | ▶ | defined $_[0] or cluck "PATTERN"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 26 | ▶ | my $v = ref $_[0] ? $_[0]->textContent : $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 26 | ▶ | return $_[0] if $compiled->matches($v); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 6 | error __x"string `{string}' does not match pattern `{pat}' at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 339 | , string => $v, pat => $regex, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 30 | }; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | sub _date_min($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 2 | ▶ | { my ($path, $args, $min) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_date_min: called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 2 | ▶ | sub { return $_[0] if $_[0] gt $min; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=9.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | error __x"too small inclusive {value}, min {min} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 347 | , value => $_[0], min => $min, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | sub _date_max($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 2 | ▶ | { my ($path, $args, $max) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_date_max: called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 2 | ▶ | sub { return $_[0] if $_[0] lt $max; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=9.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | error __x"too large inclusive {value}, max {max} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 355 | , value => $_[0], max => $max, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | sub _date_expl_tz($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | { my ($path, $args, $enum) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_date_expl_tz: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $tz = qr/Z$ | [+-](?:(?:0[0-9]|1[0-3])\:[0-5][0-9] | 14\:00)$/x; | |||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | $enum eq 'optional' ? () | ||||||||||||||||||||||||||||||||||||||||||
| 364 | : $enum eq 'prohibited' | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | ? sub { $_[0] !~ $tz | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | or error __x"timezone forbidden on {date} at {where}" | ||||||||||||||||||||||||||||||||||||||||||
| 367 | , date => $_[0], where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | : $enum eq 'required' | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | ? sub { $_[0] =~ $tz | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | or error __x"timezone required on {date} at {where}" | ||||||||||||||||||||||||||||||||||||||||||
| 372 | , date => $_[0], where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | : error __x"illegal explicitTimeZone facet '{enum}' in {path}" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | , enum => $enum, path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | sub _dur_min_incl($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 5 | ▶ | { my ($path, $args, $min) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dur_min_incl: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 5 | my $secs = duration2secs $min; | |||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 5 | ▶ | sub { return $_[0] if duration2secs $_[0] >= $secs; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 1 | error __x"too small minInclusive duration {value}, min {min} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 384 | , value => $_[0], min => $min, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 385 | 5 | }; | |||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | sub _dur_min_excl($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | { my ($path, $args, $min) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dur_min_excl: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my $secs = duration2secs $min; | |||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | sub { return $_[0] if duration2secs $_[0] > $secs; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | error __x"too small minExclusive duration {value}, min {min} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 395 | , value => $_[0], min => $min, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | sub _dur_max_incl($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | { my ($path, $args, $max) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dur_max_incl: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $secs = duration2secs $max; | |||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | sub { return $_[0] if duration2secs $_[0] <= $secs; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | error __x"too large maxInclusive duration {value}, max {max} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 406 | , value => $_[0], max => $max, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | sub _dur_max_excl($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | { my ($path, $args, $max) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dur_max_excl: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my $secs = duration2secs $max; | |||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | sub { return $_[0] if duration2secs $_[0] < $secs; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | error __x"too large maxExclusive duration {value}, max {max} at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 417 | , value => $_[0], max => $max, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 50 | 1; | |||||||||||||||||||||||||||||||||||||||||