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 SCAR 17.9
CC
6
Cov
100%
parse
4.0
valid_args
3.0
BEGIN
1.0
CRAP 6.0
« Number/Tolerant/Type/plus_or_minus_pct.pm ↑ Summary Number/Tolerant/Type/or_more.pm »
1 26 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 26 ▶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 26 ▶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 sub parse {
12 28 ▶ my ($self, $string, $factory) = @_;
Subroutine parse: called CC=4 SCAR=13.9
Pod documented
13  
14 28 my $number = $self->number_re;
15 28 my $X = $self->variable_re;
16  
17 28 ▶ 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 27 28
18 27 ▶ 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 26 27
19 26 ▶ return $factory->new("$1", 'or_less')
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /\A($number)\s+or\s+less\z/ 1 25 26
20 if $string =~ m!\A($number)\s+or\s+less\z!;
21  
22 25 return;
23 }
24  
25 sub valid_args {
26 69 ▶ my $self = shift;
Subroutine valid_args: called CC=3 SCAR=11.0
Pod documented
27  
28 69 ▶ return unless 2 == grep { defined } @_;
Branch: 1 branch
BranchTrueFalseTotal
unless 2 == grep({defined $_;} @_) 34 35 69
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 26 1;
35  
36 __END__
« Number/Tolerant/Type/plus_or_minus_pct.pm ↑ Summary Number/Tolerant/Type/or_more.pm »