line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HashData::Test::Spec::Basic; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2021-05-21'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'HashData'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
74944
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
29
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
504
|
use Role::Tiny::With; |
|
1
|
|
|
|
|
5128
|
|
|
1
|
|
|
|
|
321
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'HashDataRole::Spec::Basic'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $hash = { |
16
|
|
|
|
|
|
|
five => "lima", |
17
|
|
|
|
|
|
|
four => "empat", |
18
|
|
|
|
|
|
|
one => "satu", |
19
|
|
|
|
|
|
|
three => "tiga", |
20
|
|
|
|
|
|
|
two => "dua", |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
my $keys = [sort keys %$hash]; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
1
|
|
|
1
|
0
|
110
|
my $class = shift; |
26
|
1
|
|
|
|
|
5
|
bless {pos=>0}, $class; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _hash { |
30
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
31
|
0
|
|
|
|
|
0
|
$hash; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get_next_item { |
35
|
23
|
|
|
23
|
0
|
113
|
my $self = shift; |
36
|
23
|
100
|
|
|
|
62
|
die "StopIteration" unless $self->{pos} < @$keys; |
37
|
22
|
|
|
|
|
43
|
my $key = $keys->[ $self->{pos}++ ]; |
38
|
22
|
|
|
|
|
73
|
[$key, $hash->{$key}]; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub has_next_item { |
42
|
20
|
|
|
20
|
0
|
1125
|
my $self = shift; |
43
|
20
|
|
|
|
|
50
|
$self->{pos} < @$keys; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub get_iterator_pos { |
47
|
1
|
|
|
1
|
0
|
8
|
my $self = shift; |
48
|
1
|
|
|
|
|
4
|
$self->{pos}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub reset_iterator { |
52
|
5
|
|
|
5
|
0
|
8191
|
my $self = shift; |
53
|
5
|
|
|
|
|
13
|
$self->{pos} = 0; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub get_item_at_key { |
57
|
2
|
|
|
2
|
0
|
2467
|
my ($self, $key) = @_; |
58
|
2
|
100
|
|
|
|
17
|
die "No such key '$key'" unless exists $hash->{$key}; |
59
|
1
|
|
|
|
|
5
|
$hash->{$key}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub has_item_at_key { |
63
|
2
|
|
|
2
|
0
|
5
|
my ($self, $key) = @_; |
64
|
2
|
|
|
|
|
11
|
exists $hash->{$key}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub get_all_keys { |
68
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
69
|
1
|
|
|
|
|
7
|
[@$keys]; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# ABSTRACT: A test hash data |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |