Branch Coverage

blib/lib/Data/Domain.pm
Criterion Covered Total %
branch 279 342 81.5


line true false branch
14 4 0 $] < 5.037 ? :
70 1 4 !ref($_->[0]) && $_->[0] =~ /^!/ ? :
211 0 3 if ref $class or $class ne "Data::Domain"
215 1 2 ref $new_messages ? :
0 3 unless $global_msgs = ref $new_messages ? $new_messages : $builtin_msgs->{$new_messages}
224 33 957 if (not defined $data) { }
226 7 26 if $self->{'-optional'}
229 17 9 unless $self->isa("Data::Domain::Whatever")
234 2 955 if (my $isa = $self->{'-isa'})
236 1 1 unless &try(sub { $data->isa($isa); } )
238 4 952 if (my $role = $self->{'-does'})
239 2 2 unless &does($data, $role)
242 3 951 if (my $can = $self->{'-can'})
243 1 2 unless &does($can, "ARRAY")
246 1 4 unless &try(sub { $data->can($method); } )
249 2 951 if (my $match_target = $self->{'-matches'})
250 1 1 unless match::simple::match($data, $match_target)
253 1 951 if ($self->{'-has'})
256 1 0 if @msgs
258 8 943 if (defined $self->{'-blessed'})
260 4 4 if &Scalar::Util::blessed($data) xor $self->{'-blessed'}
262 3 944 if (defined $self->{'-package'})
264 2 1 if not ref $data and $data->isa($data) xor $self->{'-package'}
266 0 945 if (defined $self->{'-isweak'})
268 0 0 if &Scalar::Util::isweak($data) xor $self->{'-isweak'}
270 0 945 if (defined $self->{'-readonly'})
272 0 0 if &Scalar::Util::readonly($data) xor $self->{'-readonly'}
274 0 945 if (defined $self->{'-tainted'})
276 0 0 if &Scalar::Util::readonly($data) xor $self->{'-tainted'}
281 11 943 if (defined $self->{'-true'})
283 5 6 if $data xor $self->{'-true'}
285 6 943 if (defined $self->{'-ref'})
287 3 3 if ref $data xor $self->{'-ref'}
301 1 2 &does($meth_to_call, 'ARRAY') ? :
304 0 3 if (&does($expectation, 'ARRAY')) { }
315 2 1 if $msg
329 0 0 if (&does($expectation, 'ARRAY')) { }
340 0 0 if $msg
365 11 231 if (defined $msgs)
367 1 10 if /^CODE/
368 8 2 if /^$/
369 2 0 if $msg = $msgs->{$msg_id}
2 0 if (/^HASH/)
378 1 230 if ref $global_msgs eq "CODE"
380 0 230 unless $msg = $global_msgs->{$subclass}{$msg_id} || $global_msgs->{'Generic'}{$msg_id}
400 13 114 if (my $range = delete $self->{$range_field})
402 0 26 if defined $self->{$_}
405 0 13 unless &does($range, "ARRAY") and @$range == 2
416 88 38 if ($cmp_func eq '<=') { }
25 13 elsif ($cmp_func eq 'le') { }
13 0 elsif (&does($cmp_func, 'CODE')) { }
423 21 105 if (defined $min and defined $max)
424 5 16 unless &$cmp_func($min, $max)
435 1 475 unless @{$context->{'path'};} < $MAX_DEEP
439 239 236 if (&does($domain, 'Data::Domain')) { }
230 6 elsif (&does($domain, 'CODE')) { }
6 0 elsif (not ref $domain) { }
452 0 230 unless &does($domain, "Data::Domain")
457 3 3 &Scalar::Util::looks_like_number($domain) ? :
487 0 123 unless &any(sub { $args_ref->[0] eq $_; } , @$options_ref, @common_options)
494 24 129 if (@$args_ref)
495 0 24 unless $default_option
496 0 24 if exists $parsed{$default_option}
498 18 0 $arg_type eq 'arrayref' ? :
6 18 $arg_type eq 'scalar' ? :
510 0 0 unless defined $path0
511 0 0 unless defined $root
512 0 0 if &does($root, "HASH")
514 0 0 if &does($root, "ARRAY")
554 0 2 if $self->{'-defined'} and $self->{'-optional'}
562 9 23 if (defined $self->{'-defined'})
564 5 4 if defined $data xor $self->{'-defined'}
614 1 48 if ($self->{'-not_in'})
616 1 0 if @$vals > 0
617 0 1 unless &try(sub { my $vals = $self->{'-not_in'}; not grep({not &looks_like_number($_);} @$vals) if @$vals > 0; } )
626 107 193 unless &looks_like_number($data)
629 31 162 if (defined $self->{'-min'})
631 6 25 unless $data >= $self->{'-min'}
633 12 175 if (defined $self->{'-max'})
635 4 8 unless $data <= $self->{'-max'}
637 5 178 if (defined $self->{'-not_in'})
638 2 3 if grep {$data == $_;} @{$$self{"-not_in"};}
657 21 62 unless defined $data and $data =~ /^-?\d+$/
674 1 2 unless defined $data and $data =~ /^\d+$/
710 3 159 unless not ref $data or overload::Method($data, "\"\"")
712 6 153 if ($self->{'-min_length'})
714 1 5 unless length $data >= $self->{'-min_length'}
716 5 153 if (defined $self->{'-max_length'})
718 3 2 unless length $data <= $self->{'-max_length'}
720 132 23 if ($self->{'-regex'})
722 13 119 unless $data =~ /$self->{'-regex'}/
724 2 140 if ($self->{'-antiregex'})
726 1 1 if $data =~ /$self->{'-antiregex'}/
728 4 137 if (defined $self->{'-min'})
730 1 3 unless $data ge $self->{'-min'}
732 3 137 if (defined $self->{'-max'})
734 1 2 unless $data le $self->{'-max'}
736 1 138 if ($self->{'-not_in'})
737 0 1 if grep {$data eq $_;} @{$$self{"-not_in"};}
774 7 35 unless (ref $date)
779 0 7 unless $date = {"today", [Today()], "yesterday", [Add_Delta_Days(Today(), -1)], "tomorrow", [Add_Delta_Days(Today(), 1)]}->{$date}
796 0 1 if ref $class
802 1 0 ref $new_parser eq 'CODE' ? :
0 1 unless $date_parser = ref $new_parser eq "CODE" ? $new_parser : {"US", \&Data::Domain::Date::Decode_Date_US, "EU", \&Data::Domain::Date::Decode_Date_EU}->{$new_parser}
818 6 15 if ($self->{$bound} and not $self->{$bound} =~ /$dynamic_date/)
819 1 5 unless my(@date) = &$date_parser($self->{$bound})
829 1 8 if ($self->{'-not_in'})
833 1 1 if ($date =~ /$dynamic_date/) { }
837 0 1 unless my(@parsed_date) = &$date_parser($date)
843 0 1 unless &try(sub { foreach my $date (@{$$self{"-not_in"};}) { if ($date =~ /$dynamic_date/) { push @excl_dates, $date; } else { die "wrong date" unless my(@parsed_date) = &$date_parser($date); push @excl_dates, \@parsed_date; } ; } ; @excl_dates > 0; } )
855 4 14 unless @date and check_date(@date)
858 6 8 if (defined $self->{'-min'})
861 2 4 if not check_date(@$min) or _date_cmp(\@date, $min) < 0
864 3 9 if (defined $self->{'-max'})
867 1 2 if not check_date(@$max) or _date_cmp(\@date, $max) > 0
870 2 9 if ($self->{'-not_in'})
871 1 1 if grep {_date_cmp(\@date, $_) == 0;} @{$$self{"-not_in"};}
899 0 16 unless (ref $time)
900 0 0 unless $time eq "now"
917 2 4 unless $_
931 4 2 if ($self->{$bound} and $self->{$bound} ne "now")
933 0 4 unless @time and _valid_time(@time)
950 2 4 unless @t and _valid_time(@t)
953 3 1 if (defined $self->{'-min'})
955 1 2 if _time_cmp(\@t, $self->{'-min'}) < 0
958 2 1 if (defined $self->{'-max'})
960 1 1 if _time_cmp(\@t, $self->{'-max'}) > 0
985 1 2 unless &Scalar::Util::openhandle($data)
1009 0 5 unless &try(sub { @{$self->{'-values'};}; } )
1011 1 4 if grep {not defined $_;} @{$$self{"-values"};}
1022 2 4 unless grep {$_ eq $data;} @{$$self{"-values"};}
1047 5 7 if ($self->{'-items'})
1048 0 5 unless &does($self->{'-items'}, "ARRAY")
1054 0 10 if $self->{$bound} and $self->{$bound} < @{$self->{'-items'};}
1060 8 16 if (my $dom = $self->{$arg})
1061 7 1 unless &does($dom, "ARRAY")
1062 1 8 unless &does($_, "Data::Domain")
0 8 unless &all(sub { &does($_, "CODE") unless &does($_, "Data::Domain"); } , @$dom)
1075 1 37 unless &does($data, "ARRAY")
1078 1 36 if (defined $self->{'-min_size'} and @$data < $self->{'-min_size'})
1082 1 35 if (defined $self->{'-max_size'} and @$data > $self->{'-max_size'})
1086 2 6 unless $self->{'-items'} or $self->{'-all'} or $self->{'-any'}
1104 0 50 unless my $subdomain = $self->_build_subdomain($items->[$i], $context)
1111 8 25 if (my $all = $self->{'-all'})
1112 8 0 unless &does($all, "ARRAY")
1125 9 24 if $has_invalid
1128 13 11 if (my $any = $self->{'-any'})
1129 9 4 unless &does($any, "ARRAY")
1133 1 12 unless $n_data > $n_items
1143 11 20 unless $error
1169 13 1 if (&does($fields, 'ARRAY')) { }
1 0 elsif (&does($fields, 'HASH')) { }
1188 3 11 if (my $exclude = $self->{'-exclude'})
1189 0 2 unless &does($exclude, "ARRAY") or &does($exclude, "Regexp") or not ref $exclude
1196 2 26 if (my $dom = $self->{$arg})
1197 0 2 unless &does($dom, "Data::Domain::List") or &does($dom, "CODE")
1211 2 136 unless &does($data, "HASH")
1217 10 126 if (my $exclude = $self->{'-exclude'})
1221 5 5 match::simple::match($exclude, ['*', 'all']) ? :
1222 7 3 if @wrong_fields
1239 14 247 if $msg
1243 3 33 if (my $keys_dom = $self->{'-keys'})
1247 1 2 if $msg
1251 3 33 if (my $values_dom = $self->{'-values'})
1255 1 2 if $msg
1258 17 19 keys %msgs ? :
1275 0 2 unless &Scalar::Does::does($self->{'-options'}, "ARRAY")
1288 109 112 unless my $msg = $subdomain->inspect($data, $context)
1310 0 1 unless &Scalar::Does::does($self->{'-options'}, "ARRAY")
1324 2 4 if $msg
1326 2 1 @msgs ? :