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   127 use strict;
  26         49  
  26         952  
2 26     26   131 use warnings;
  26         51  
  26         942  
3             # ABSTRACT: a tolerance "m >= n"
4              
5             package
6             Number::Tolerant::Type::or_more;
7 26     26   131 use parent qw(Number::Tolerant::Type);
  26         44  
  26         127  
8              
9 15     15 1 21 sub construct { shift; { value => $_[0], min => $_[0] } }
  15         59  
10              
11             sub parse {
12 21     21 1 45 my ($self, $string, $factory) = @_;
13 21         96 my $number = $self->number_re;
14 21         92 my $X = $self->variable_re;
15              
16 21 100       578 return $factory->new("$1", 'or_more') if $string =~ m!\A($number)\s*<=$X\z!;
17 20 100       452 return $factory->new("$1", 'or_more') if $string =~ m!\A$X?>=\s*($number)\z!;
18 19 100       434 return $factory->new("$1", 'or_more')
19             if $string =~ m!\A($number)\s+or\s+more\z!;
20              
21 18         112 return;
22             }
23              
24             sub valid_args {
25 104     104 1 163 my $self = shift;
26              
27 104 100       214 return unless 2 == grep { defined } @_;
  234         761  
28 45 100       210 return unless $_[1] eq 'or_more';
29              
30 15         60 return $self->normalize_number($_[0]);
31             }
32              
33             1;
34              
35             __END__