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