File Coverage

blib/lib/Number/Tolerant/Type/or_more.pm
Criterion Covered Total %
statement 23 23 100.0
branch 10 10 100.0
condition n/a
subroutine 6 6 100.0
pod 3 3 100.0
total 42 42 100.0


line stmt bran cond sub pod time code
1 26     26   134 use strict;
  26         44  
  26         704  
2 26     26   105 use warnings;
  26         52  
  26         719  
3             # ABSTRACT: a tolerance "m >= n"
4              
5             package
6             Number::Tolerant::Type::or_more;
7 26     26   184 use parent qw(Number::Tolerant::Type);
  26         41  
  26         94  
8              
9 15     15 1 19 sub construct { shift; { value => $_[0], min => $_[0] } }
  15         40  
10              
11             sub parse {
12 19     19 1 42 my ($self, $string, $factory) = @_;
13 19         67 my $number = $self->number_re;
14 19         56 my $X = $self->variable_re;
15              
16 19 100       433 return $factory->new("$1", 'or_more') if $string =~ m!\A($number)\s*<=$X\z!;
17 18 100       271 return $factory->new("$1", 'or_more') if $string =~ m!\A$X?>=\s*($number)\z!;
18 17 100       289 return $factory->new("$1", 'or_more')
19             if $string =~ m!\A($number)\s+or\s+more\z!;
20              
21 16         57 return;
22             }
23              
24             sub valid_args {
25 102     102 1 134 my $self = shift;
26              
27 102 100       143 return unless 2 == grep { defined } @_;
  245         483  
28 41 100       99 return unless $_[1] eq 'or_more';
29              
30 15         42 return $self->normalize_number($_[0]);
31             }
32              
33             1;
34              
35             __END__