line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
26
|
|
|
26
|
|
163
|
use strict; |
|
26
|
|
|
|
|
41
|
|
|
26
|
|
|
|
|
692
|
|
2
|
26
|
|
|
26
|
|
106
|
use warnings; |
|
26
|
|
|
|
|
42
|
|
|
26
|
|
|
|
|
743
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: a tolerance "m (-l or +n)" |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package |
6
|
|
|
|
|
|
|
Number::Tolerant::Type::offset; |
7
|
26
|
|
|
26
|
|
113
|
use parent qw(Number::Tolerant::Type); |
|
26
|
|
|
|
|
39
|
|
|
26
|
|
|
|
|
98
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
1
|
4
|
sub construct { shift; |
10
|
|
|
|
|
|
|
{ |
11
|
3
|
|
|
|
|
24
|
value => $_[0], |
12
|
|
|
|
|
|
|
min => $_[0] + $_[1], |
13
|
|
|
|
|
|
|
max => $_[0] + $_[2] |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub parse { |
18
|
16
|
|
|
16
|
1
|
34
|
my ($self, $string, $factory) = @_; |
19
|
|
|
|
|
|
|
|
20
|
16
|
|
|
|
|
76
|
my $number = $self->number_re; |
21
|
16
|
100
|
|
|
|
511
|
return $factory->new("$1", 'offset', "$2", "$3") |
22
|
|
|
|
|
|
|
if $string =~ m!\A($number)\s+\(?\s*($number)\s+($number)\s*\)?\s*\z!; |
23
|
|
|
|
|
|
|
|
24
|
15
|
|
|
|
|
61
|
return; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub stringify { |
28
|
7
|
|
|
7
|
1
|
2313
|
my ($self) = @_; |
29
|
|
|
|
|
|
|
return sprintf "%s (-%s +%s)", |
30
|
|
|
|
|
|
|
$_[0]->{value}, |
31
|
|
|
|
|
|
|
($_[0]->{value} - $_[0]->{min}), |
32
|
7
|
|
|
|
|
70
|
($_[0]->{max} - $_[0]->{value}); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub valid_args { |
36
|
94
|
|
|
94
|
1
|
132
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
94
|
50
|
|
|
|
172
|
return if @_ > 4; |
39
|
|
|
|
|
|
|
|
40
|
94
|
100
|
|
|
|
251
|
return unless defined(my $lhs_number = $self->normalize_number($_[0])); |
41
|
72
|
100
|
|
|
|
178
|
return unless defined(my $minus_number = $self->normalize_number($_[2])); |
42
|
26
|
100
|
|
|
|
71
|
return unless defined(my $plus_number = $self->normalize_number($_[3])); |
43
|
|
|
|
|
|
|
|
44
|
3
|
50
|
|
|
|
9
|
return unless $_[1] eq 'offset'; |
45
|
3
|
50
|
|
|
|
11
|
return unless $minus_number <= 0; |
46
|
3
|
50
|
|
|
|
8
|
return unless $plus_number >= 0; |
47
|
|
|
|
|
|
|
|
48
|
3
|
|
|
|
|
18
|
return ($lhs_number, $minus_number, $plus_number) |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |