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-06-01'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'HashData'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.1.1'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
80433
|
use strict; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
34
|
|
9
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
519
|
use Role::Tiny::With; |
|
1
|
|
|
|
|
5540
|
|
|
1
|
|
|
|
|
371
|
|
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
|
113
|
my $class = shift; |
26
|
1
|
|
|
|
|
7
|
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
|
136
|
my $self = shift; |
36
|
23
|
100
|
|
|
|
69
|
die "StopIteration" unless $self->{pos} < @$keys; |
37
|
22
|
|
|
|
|
48
|
my $key = $keys->[ $self->{pos}++ ]; |
38
|
22
|
|
|
|
|
81
|
[$key, $hash->{$key}]; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub has_next_item { |
42
|
20
|
|
|
20
|
0
|
1607
|
my $self = shift; |
43
|
20
|
|
|
|
|
56
|
$self->{pos} < @$keys; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub get_iterator_pos { |
47
|
1
|
|
|
1
|
0
|
5
|
my $self = shift; |
48
|
1
|
|
|
|
|
6
|
$self->{pos}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub reset_iterator { |
52
|
5
|
|
|
5
|
0
|
8993
|
my $self = shift; |
53
|
5
|
|
|
|
|
16
|
$self->{pos} = 0; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub get_item_at_key { |
57
|
2
|
|
|
2
|
0
|
2876
|
my ($self, $key) = @_; |
58
|
2
|
100
|
|
|
|
20
|
die "No such key '$key'" unless exists $hash->{$key}; |
59
|
1
|
|
|
|
|
7
|
$hash->{$key}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub has_item_at_key { |
63
|
2
|
|
|
2
|
0
|
5
|
my ($self, $key) = @_; |
64
|
2
|
|
|
|
|
13
|
exists $hash->{$key}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub get_all_keys { |
68
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
69
|
1
|
|
|
|
|
9
|
[@$keys]; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# ABSTRACT: A test hash data |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |