Number/Tolerant/Type/or_less.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/plus_or_minus_pct.pm ↑ Summary Number/Tolerant/Type/or_more.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_less;
7 25 ▶use parent qw(Number::Tolerant::Type);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 14 ▶sub construct { shift; { value => $_[0], max => $_[0] } }
Subroutine construct: called CC=1 SCAR=0.0
Pod documented
10  
11 24 ▶sub parse {
Subroutine parse: called CC=4 SCAR=13.9
Pod documented
12 24 my ($self, $string, $factory) = @_;
13  
14 24 my $number = $self->number_re;
15 24 my $X = $self->variable_re;
16  
17 24 ▶ return $factory->new("$1", 'or_less') if $string =~ m!\A$X?<=\s*($number)\z!;
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /\A$X?<=\s*($number)\z/ 1 23 24
18 23 ▶ return $factory->new("$1", 'or_less') if $string =~ m!\A($number)\s*>=$X\z!;
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /\A($number)\s*>=$X\z/ 1 22 23
19 22 ▶ return $factory->new("$1", 'or_less')
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /\A($number)\s+or\s+less\z/ 1 21 22
20 if $string =~ m!\A($number)\s+or\s+less\z!;
21  
22 21 return;
23 }
24  
25 98 ▶sub valid_args {
Subroutine valid_args: called CC=3 SCAR=11.0
Pod documented
26 98 my $self = shift;
27  
28 98 ▶ return unless 2 == grep { defined } @_;
Branch: 1 branch
BranchTrueFalseTotal
unless 2 == grep({defined $_;} @_) 63 35 98
29 35 ▶ return unless $_[1] eq 'or_less';
Branch: 1 branch
BranchTrueFalseTotal
unless $_[1] eq "or_less" 21 14 35
30  
31 14 return $self->normalize_number($_[0]);
32 }
33  
34 25 1;
35  
36 __END__
« Number/Tolerant/Type/plus_or_minus_pct.pm ↑ Summary Number/Tolerant/Type/or_more.pm »