Number/Tolerant/Type/less_than.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 10 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 96.0% 48 / 50 CC 8 SCAR 12.4
CC
8
Cov
97%
valid_args
5.0
parse
4.0
BEGIN
1.0
CRAP 3.5
« Number/Tolerant/Union.pm ↑ Summary Number/Tolerant/Type/more_than.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::less_than;
7 25 ▶use parent qw(Number::Tolerant::Type);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 9 ▶sub construct { shift; { value => $_[0], max => $_[0], exclude_max => 1 } }
Subroutine construct: called CC=1 SCAR=0.0
Pod documented
10  
11 32 ▶sub parse {
Subroutine parse: called CC=4 SCAR=13.9
Pod documented
12 32 my ($self, $string, $factory) = @_;
13  
14 32 my $number = $self->number_re;
15 32 my $X = $self->variable_re;
16 32 ▶ return $factory->new(less_than => "$1") if $string =~ m!\A$X?<\s*($number)\z!;
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /\A$X?<\s*($number)\z/ 1 31 32
17 31 ▶ return $factory->new(less_than => "$1") if $string =~ m!\A($number)\s*>$X\z!;
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /\A($number)\s*>$X\z/ 1 30 31
18  
19 30 ▶ return $factory->new(less_than => "$1")
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ /\Aless\s+than\s+($number)\z/ 1 29 30
20 if $string =~ m!\Aless\s+than\s+($number)\z!;
21  
22 29 return;
23 }
24  
25 99 ▶sub valid_args {
Subroutine valid_args: called CC=5 SCAR=16.1
Pod documented
26 99 my $self = shift;
27  
28 99 ▶ return unless 2 == grep { defined } @_;
Branch: 1 branch
BranchTrueFalseTotal
unless 2 == grep({defined $_;} @_) 61 38 99
29  
30 38 for my $i ( [0,1], [1,0] ) {
31 72 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($_[$i->[0]] eq "less_than" and defined(my $num = $self->normalize_number($_[$i->[1]]))) 9 63 72
Condition66%2/3
$_[$i->[0]] eq "less_than" and defined(my $num = $self->normalize_number($_[$i->[1]]))
!ll&&!rl&&r
6309
MC/DC50%1/2
$_[$i->[0]] eq "less_than" and defined(my $num = $self->normalize_number($_[$i->[1]]))
$_[$i->[0]] eq "less_than" defined(my $num = $self->normalize_number($_[$i->[1]]))
Truth table66%2/3
A and B
A= $_[$i->[0]] eq "less_than"B= defined(my $num = $self->normalize_number($_[$i->[1]]))
ABresult
0X0
100
111
32 $_[ $i->[0] ] eq 'less_than'
33 and defined (my $num = $self->normalize_number($_[ $i->[1] ]))
34 ) {
35 9 return $num;
36 }
37 }
38  
39 29 return;
40 }
41  
42 25 1;
43  
44 __END__
« Number/Tolerant/Union.pm ↑ Summary Number/Tolerant/Type/more_than.pm »