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