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   151 use strict;
  26         54  
  26         802  
2 26     26   116 use warnings;
  26         55  
  26         763  
3             # ABSTRACT: a tolerance "m >= n"
4              
5             package
6             Number::Tolerant::Type::or_more;
7 26     26   109 use parent qw(Number::Tolerant::Type);
  26         47  
  26         107  
8              
9 15     15 1 17 sub construct { shift; { value => $_[0], min => $_[0] } }
  15         42  
10              
11             sub parse {
12 27     27 1 63 my ($self, $string, $factory) = @_;
13 27         112 my $number = $self->number_re;
14 27         84 my $X = $self->variable_re;
15              
16 27 100       473 return $factory->new("$1", 'or_more') if $string =~ m!\A($number)\s*<=$X\z!;
17 26 100       414 return $factory->new("$1", 'or_more') if $string =~ m!\A$X?>=\s*($number)\z!;
18 25 100       412 return $factory->new("$1", 'or_more')
19             if $string =~ m!\A($number)\s+or\s+more\z!;
20              
21 24         99 return;
22             }
23              
24             sub valid_args {
25 97     97 1 140 my $self = shift;
26              
27 97 100       152 return unless 2 == grep { defined } @_;
  214         510  
28 42 100       125 return unless $_[1] eq 'or_more';
29              
30 15         42 return $self->normalize_number($_[0]);
31             }
32              
33             1;
34              
35             __END__