line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Mimic::Library::MonitorHash; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
16
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2078
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use constant { |
9
|
|
|
|
|
|
|
# Instance variables |
10
|
1
|
|
|
|
|
1552
|
VALUE => 0, |
11
|
|
|
|
|
|
|
HISTORY => 1, |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# History fields |
14
|
|
|
|
|
|
|
FETCH_F => 0, |
15
|
|
|
|
|
|
|
KEYS_F => 1, |
16
|
|
|
|
|
|
|
EXISTS_F => 2, |
17
|
|
|
|
|
|
|
SCALAR_F => 3, |
18
|
1
|
|
|
1
|
|
2476
|
}; |
|
1
|
|
|
|
|
2
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub TIEHASH { |
21
|
0
|
|
|
0
|
|
|
my ( $class, $history, $val ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Initialize instance variables. |
24
|
0
|
|
|
|
|
|
my $self = []; |
25
|
0
|
|
|
|
|
|
%{ $self->[VALUE] = {} } = %{$val}; # Copy the hash |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
for my $field ( FETCH_F, EXISTS_F ) { |
27
|
0
|
|
|
|
|
|
$history->[$field] = {}; |
28
|
|
|
|
|
|
|
} |
29
|
0
|
|
|
|
|
|
for my $field ( KEYS_F, SCALAR_F ) { |
30
|
0
|
|
|
|
|
|
$history->[$field] = []; |
31
|
|
|
|
|
|
|
} |
32
|
0
|
|
|
|
|
|
$self->[HISTORY] = $history; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
bless( $self, $class ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub STORE { |
38
|
0
|
|
|
0
|
|
|
my ( $self, $key, $value ) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
$self->[VALUE]->{$key} = $value; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub FETCH { |
44
|
0
|
|
|
0
|
|
|
my ( $self, $key ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $value = $self->[VALUE]->{$key}; |
47
|
0
|
0
|
|
|
|
|
if ( ! $Test::Mimic::Recorder::SuspendRecording ) { |
48
|
0
|
|
0
|
|
|
|
my $key_history = ( $self->[HISTORY]->[FETCH_F]->{$key} ||= [] ); |
49
|
0
|
|
|
|
|
|
push( @{$key_history}, Test::Mimic::Library::monitor( $value ) ); |
|
0
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $value; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub FIRSTKEY { |
56
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
keys %{ $self->[VALUE] }; # Reset hash iterator. |
|
0
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
return $self->NEXTKEY($self); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub NEXTKEY { |
63
|
0
|
|
|
0
|
|
|
my ( $self, $last_key ) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $key = each %{ $self->[VALUE] }; |
|
0
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if ( ! $Test::Mimic::Recorder::SuspendRecording ) { |
68
|
0
|
|
|
|
|
|
push( @{ $self->[HISTORY]->[KEYS_F] }, $key ); |
|
0
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return $key; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub EXISTS { |
75
|
0
|
|
|
0
|
|
|
my ( $self, $key ) = @_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $result = exists $self->[VALUE]->{$key}; |
78
|
0
|
0
|
|
|
|
|
if ( ! $Test::Mimic::Recorder::SuspendRecording ) { |
79
|
0
|
|
0
|
|
|
|
my $exists_history = ( $self->[HISTORY]->[EXISTS_F]->{$key} ||= [] ); |
80
|
0
|
|
|
|
|
|
push( @{$exists_history}, $result ); |
|
0
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
return $result; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub DELETE { |
87
|
0
|
|
|
0
|
|
|
my ( $self, $key ) = @_; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
delete $self->[VALUE]->{$key}; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# Any non-read inherited operation should not alter the history. |
93
|
|
|
|
|
|
|
sub CLEAR { |
94
|
0
|
|
|
0
|
|
|
my $self = shift(@_); |
95
|
0
|
|
|
|
|
|
local $Test::Mimic::Recorder::SuspendRecording = 1; |
96
|
0
|
|
|
|
|
|
$self->SUPER::CLEAR(@_); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub SCALAR { |
100
|
0
|
|
|
0
|
|
|
my ( $self ) = @_; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
my $result = scalar %{ $self->[VALUE] }; |
|
0
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
|
if ( ! $Test::Mimic::Recorder::SuspendRecording ) { |
104
|
0
|
|
|
|
|
|
push( @{ $self->[HISTORY]->[SCALAR_F] }, $result ); |
|
0
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
return $result; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |