line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Deep::Between; |
2
|
6
|
|
|
6
|
|
419911
|
use 5.008_001; |
|
6
|
|
|
|
|
24
|
|
|
6
|
|
|
|
|
221
|
|
3
|
6
|
|
|
6
|
|
31
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
177
|
|
4
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
1687
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
5572
|
use Test::Deep::Cmp; |
|
6
|
|
|
|
|
10333
|
|
|
6
|
|
|
|
|
28
|
|
9
|
6
|
|
|
6
|
|
5525
|
use Exporter::Lite; |
|
6
|
|
|
|
|
4905
|
|
|
6
|
|
|
|
|
93
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT = qw(between between_str); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub between { |
14
|
6
|
|
|
6
|
1
|
9050
|
my ($from, $to) = @_; |
15
|
6
|
|
|
|
|
89
|
__PACKAGE__->new($from, $to); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub between_str { |
19
|
1
|
|
|
1
|
1
|
109
|
my ($from, $to) = @_; |
20
|
1
|
|
|
|
|
18
|
__PACKAGE__->new($from, $to, 1); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub init { |
24
|
7
|
|
|
7
|
0
|
68
|
my $self = shift; |
25
|
7
|
|
|
|
|
18
|
my ($from, $to, $is_str) = @_; |
26
|
|
|
|
|
|
|
|
27
|
7
|
|
|
|
|
395
|
$self->{from} = $from; |
28
|
7
|
|
|
|
|
21
|
$self->{to} = $to; |
29
|
7
|
|
|
|
|
16
|
$self->{is_str} = $is_str; |
30
|
|
|
|
|
|
|
|
31
|
7
|
|
|
|
|
32
|
$self->_is_invalid_range(); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _is_invalid_range { |
35
|
7
|
|
|
7
|
|
16
|
my $self = shift; |
36
|
7
|
100
|
|
|
|
47
|
if ($self->{is_str}) { |
37
|
1
|
50
|
|
|
|
6
|
if ($self->{from} gt $self->{to}) { |
38
|
0
|
|
|
|
|
0
|
$self->{error_mean} = 'from_value is larger than to_value.'; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
else { |
42
|
6
|
100
|
|
|
|
130
|
if ($self->{from} > $self->{to}) { |
43
|
1
|
|
|
|
|
5
|
$self->{error_mean} = 'from_value is larger than to_value.'; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _is_in_range { |
49
|
6
|
|
|
6
|
|
15
|
my $self = shift; |
50
|
6
|
|
|
|
|
11
|
my $got = shift; |
51
|
6
|
100
|
|
|
|
32
|
if ($self->{is_str}) { |
52
|
1
|
|
33
|
|
|
16
|
return $self->{from} le $got && $got le $self->{to}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
5
|
|
66
|
|
|
157
|
return $self->{from} <= $got && $got <= $self->{to}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub descend { |
60
|
7
|
|
|
7
|
0
|
84728
|
my ($self, $got) = @_; |
61
|
|
|
|
|
|
|
|
62
|
7
|
100
|
|
|
|
49
|
if (exists $self->{error_mean}) { |
63
|
1
|
|
|
|
|
4
|
return 0; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
6
|
|
|
|
|
17
|
$self->{error_mean} = '%s is not in %s to %s.'; |
67
|
6
|
|
|
|
|
26
|
return $self->_is_in_range($got); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub diagnostics { |
71
|
3
|
|
|
3
|
0
|
1059
|
my ($self, $got) = @_; |
72
|
3
|
|
|
|
|
26
|
return sprintf $self->{error_mean}, $got, $self->{from}, $self->{to}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
__END__ |