Number/Tolerant/Type/or_more.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 100% 43 / 43 CC 6 SCAR 9.7
CC
6
Cov
100%
parse
4.0
valid_args
3.0
BEGIN
1.0
CRAP 2.6
« Number/Tolerant/Type/or_less.pm ↑ Summary Number/Tolerant/Type/infinite.pm »
1 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 25 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 # ABSTRACT: a tolerance "m >= n"
4  
5 package
6 Number::Tolerant::Type::or_more;
7 25 ▶use parent qw(Number::Tolerant::Type);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 15 ▶sub construct { shift; { value => $_[0], min => $_[0] } }
Subroutine construct: called CC=1 SCAR=0.0
Pod documented
10  
11 22 ▶sub parse {
Subroutine parse: called CC=4 SCAR=13.9
Pod documented
12 22 my ($self, $string, $factory) = @_;
13 22 my $number = $self->number_re;
14 22 my $X = $self->variable_re;
15  
16 22 ▶ return $factory->new("$1", 'or_more') if $string =~ m!\A($number)\s*<=$X\z!;
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /\A($number)\s*<=$X\z/ 1 21 22
17 21 ▶ return $factory->new("$1", 'or_more') if $string =~ m!\A$X?>=\s*($number)\z!;
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /\A$X?>=\s*($number)\z/ 1 20 21
18 20 ▶ return $factory->new("$1", 'or_more')
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /\A($number)\s+or\s+more\z/ 1 19 20
19 if $string =~ m!\A($number)\s+or\s+more\z!;
20  
21 19 return;
22 }
23  
24 115 ▶sub valid_args {
Subroutine valid_args: called CC=3 SCAR=11.0
Pod documented
25 115 my $self = shift;
26  
27 115 ▶ return unless 2 == grep { defined } @_;
Branch: 1 branch
BranchTrueFalseTotal
unless 2 == grep({defined $_;} @_) 67 48 115
28 48 ▶ return unless $_[1] eq 'or_more';
Branch: 1 branch
BranchTrueFalseTotal
unless $_[1] eq "or_more" 33 15 48
29  
30 15 return $self->normalize_number($_[0]);
31 }
32  
33 25 1;
34  
35 __END__
« Number/Tolerant/Type/or_less.pm ↑ Summary Number/Tolerant/Type/infinite.pm »