| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
25
|
|
|
25
|
|
160
|
use strict; |
|
|
25
|
|
|
|
|
106
|
|
|
|
25
|
|
|
|
|
1409
|
|
|
2
|
25
|
|
|
25
|
|
151
|
use warnings; |
|
|
25
|
|
|
|
|
73
|
|
|
|
25
|
|
|
|
|
1666
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: a tolerance "m to n" |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package |
|
6
|
|
|
|
|
|
|
Number::Tolerant::Type::to; |
|
7
|
25
|
|
|
25
|
|
152
|
use parent qw(Number::Tolerant::Type); |
|
|
25
|
|
|
|
|
40
|
|
|
|
25
|
|
|
|
|
403
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
32
|
|
|
32
|
1
|
47
|
sub construct { shift; |
|
10
|
32
|
|
|
|
|
114
|
($_[0],$_[1]) = sort { $a <=> $b } ($_[0],$_[1]); |
|
|
32
|
|
|
|
|
104
|
|
|
11
|
|
|
|
|
|
|
{ |
|
12
|
32
|
|
|
|
|
210
|
value => ($_[0]+$_[1])/2, |
|
13
|
|
|
|
|
|
|
variance => $_[1] - ($_[0]+$_[1])/2, |
|
14
|
|
|
|
|
|
|
min => $_[0], |
|
15
|
|
|
|
|
|
|
max => $_[1] |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub parse { |
|
20
|
24
|
|
|
24
|
1
|
83
|
my ($self, $string, $factory) = @_; |
|
21
|
24
|
|
|
|
|
161
|
my $number = $self->number_re; |
|
22
|
24
|
|
|
|
|
100
|
my $X = $self->variable_re; |
|
23
|
|
|
|
|
|
|
|
|
24
|
24
|
100
|
|
|
|
2249
|
return $factory->new("$1", 'to', "$2") |
|
25
|
|
|
|
|
|
|
if ($string =~ m!\A($number)\s*<=$X<=\s*($number)\z!); |
|
26
|
23
|
100
|
|
|
|
2052
|
return $factory->new("$2", 'to', "$1") |
|
27
|
|
|
|
|
|
|
if ($string =~ m!\A($number)\s*>=$X>=\s*($number)\z!); |
|
28
|
22
|
100
|
|
|
|
1982
|
return $factory->new("$1", 'to', "$2") |
|
29
|
|
|
|
|
|
|
if ($string =~ m!\A($number)\s+to\s+($number)\z!); |
|
30
|
21
|
|
|
|
|
146
|
return; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub valid_args { |
|
34
|
87
|
|
|
87
|
1
|
171
|
my $self = shift; |
|
35
|
|
|
|
|
|
|
|
|
36
|
87
|
100
|
|
|
|
200
|
return unless 3 == grep { defined } @_; |
|
|
227
|
|
|
|
|
591
|
|
|
37
|
49
|
100
|
|
|
|
175
|
return unless $_[1] eq 'to'; |
|
38
|
|
|
|
|
|
|
|
|
39
|
33
|
50
|
|
|
|
148
|
return unless defined (my $from = $self->normalize_number($_[0])); |
|
40
|
33
|
100
|
|
|
|
98
|
return unless defined (my $to = $self->normalize_number($_[2])); |
|
41
|
|
|
|
|
|
|
|
|
42
|
32
|
|
|
|
|
114
|
return ($from, $to); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |