line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
26
|
|
|
26
|
|
128
|
use strict; |
|
26
|
|
|
|
|
54
|
|
|
26
|
|
|
|
|
793
|
|
2
|
26
|
|
|
26
|
|
117
|
use warnings; |
|
26
|
|
|
|
|
42
|
|
|
26
|
|
|
|
|
784
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: a tolerance "m +/- n" |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package |
6
|
|
|
|
|
|
|
Number::Tolerant::Type::plus_or_minus; |
7
|
26
|
|
|
26
|
|
120
|
use parent qw(Number::Tolerant::Type); |
|
26
|
|
|
|
|
43
|
|
|
26
|
|
|
|
|
164
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
1
|
7
|
sub construct { shift; |
10
|
|
|
|
|
|
|
{ |
11
|
5
|
|
|
|
|
26
|
value => $_[0], |
12
|
|
|
|
|
|
|
variance => $_[1], |
13
|
|
|
|
|
|
|
min => $_[0] - $_[1], |
14
|
|
|
|
|
|
|
max => $_[0] + $_[1] |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub parse { |
19
|
15
|
|
|
15
|
1
|
33
|
my ($self, $string, $factory) = @_; |
20
|
|
|
|
|
|
|
|
21
|
15
|
|
|
|
|
59
|
my $number = $self->number_re; |
22
|
|
|
|
|
|
|
|
23
|
15
|
100
|
|
|
|
314
|
return $factory->new("$1", 'plus_or_minus', "$2") |
24
|
|
|
|
|
|
|
if $string =~ m!\A($number)\s*\+/-\s*($number)\z!; |
25
|
13
|
|
|
|
|
43
|
return; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
4
|
1
|
2229
|
sub stringify { "$_[0]->{value} +/- $_[0]->{variance}" } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub valid_args { |
31
|
85
|
|
|
85
|
1
|
113
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
85
|
100
|
|
|
|
123
|
return unless 3 == grep { defined } @_; |
|
197
|
|
|
|
|
364
|
|
34
|
24
|
100
|
|
|
|
72
|
return unless $_[1] eq 'plus_or_minus'; |
35
|
|
|
|
|
|
|
|
36
|
6
|
50
|
|
|
|
44
|
return unless defined (my $base = $self->normalize_number($_[0])); |
37
|
6
|
100
|
|
|
|
15
|
return unless defined (my $var = $self->normalize_number($_[2])); |
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
18
|
return ($base, $var); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |