line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
26
|
|
|
26
|
|
127
|
use strict; |
|
26
|
|
|
|
|
49
|
|
|
26
|
|
|
|
|
986
|
|
2
|
26
|
|
|
26
|
|
189
|
use warnings; |
|
26
|
|
|
|
|
52
|
|
|
26
|
|
|
|
|
939
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: a tolerance "m +/- n%" |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package |
6
|
|
|
|
|
|
|
Number::Tolerant::Type::plus_or_minus_pct; |
7
|
26
|
|
|
26
|
|
128
|
use parent qw(Number::Tolerant::Type); |
|
26
|
|
|
|
|
66
|
|
|
26
|
|
|
|
|
171
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
1
|
8
|
sub construct { shift; |
10
|
|
|
|
|
|
|
{ |
11
|
5
|
|
|
|
|
41
|
value => $_[0], |
12
|
|
|
|
|
|
|
variance => $_[1], |
13
|
|
|
|
|
|
|
min => $_[0] - $_[0]*($_[1]/100), |
14
|
|
|
|
|
|
|
max => $_[0] + $_[0]*($_[1]/100) |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub parse { |
19
|
20
|
|
|
20
|
1
|
54
|
my ($self, $string, $factory) = @_; |
20
|
20
|
|
|
|
|
123
|
my $number = $self->number_re; |
21
|
|
|
|
|
|
|
|
22
|
20
|
100
|
|
|
|
757
|
return $factory->new("$1", 'plus_or_minus_pct', "$2") |
23
|
|
|
|
|
|
|
if $string =~ m!\A($number)\s*\+/-\s*($number)%\z!; |
24
|
19
|
|
|
|
|
119
|
return; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
9
|
|
|
9
|
1
|
2332
|
sub stringify { "$_[0]->{value} +/- $_[0]->{variance}%" } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub valid_args { |
30
|
101
|
|
|
101
|
1
|
156
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
101
|
100
|
|
|
|
165
|
return unless 3 == grep { defined } @_; |
|
239
|
|
|
|
|
749
|
|
33
|
44
|
100
|
|
|
|
269
|
return unless $_[1] eq 'plus_or_minus_pct'; |
34
|
|
|
|
|
|
|
|
35
|
6
|
50
|
|
|
|
37
|
return unless defined (my $base = $self->normalize_number($_[0])); |
36
|
6
|
100
|
|
|
|
36
|
return unless defined (my $var = $self->normalize_number($_[2])); |
37
|
|
|
|
|
|
|
|
38
|
5
|
|
|
|
|
172
|
return ($base, $var); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |