line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Mimic::Library::MonitorTiedHash; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
87
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use constant { |
9
|
|
|
|
|
|
|
# Instance variables |
10
|
1
|
|
|
|
|
1341
|
BACKING_VAR => 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
|
|
5
|
}; |
|
1
|
|
|
|
|
2
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub TIEHASH { |
21
|
0
|
|
|
0
|
|
|
my ( $class, $history, $backing_var ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Initialize instance variables. |
24
|
0
|
|
|
|
|
|
my $self = []; |
25
|
0
|
|
|
|
|
|
$self->[BACKING_VAR] = $backing_var; |
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->[BACKING_VAR]->STORE( $key, $value ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub FETCH { |
44
|
0
|
|
|
0
|
|
|
my ( $self, $key ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $value = $self->[BACKING_VAR]->FETCH($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
|
|
|
|
|
|
my $key = $self->[BACKING_VAR]->FIRSTKEY(); |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if ( ! $Test::Mimic::Recorder::SuspendRecording ) { |
61
|
0
|
|
|
|
|
|
push( @{ $self->[HISTORY]->[KEYS_F] }, $key ); |
|
0
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return $key; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub NEXTKEY { |
68
|
0
|
|
|
0
|
|
|
my ( $self, $last_key ) = @_; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $key = $self->[BACKING_VAR]->NEXTKEY($last_key); |
71
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
if ( ! $Test::Mimic::Recorder::SuspendRecording ) { |
73
|
0
|
|
|
|
|
|
push( @{ $self->[HISTORY]->[KEYS_F] }, $key ); |
|
0
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return $key; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub EXISTS { |
80
|
0
|
|
|
0
|
|
|
my ( $self, $key ) = @_; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
my $result = $self->[BACKING_VAR]->EXISTS($key); |
83
|
0
|
0
|
|
|
|
|
if ( ! $Test::Mimic::Recorder::SuspendRecording ) { |
84
|
0
|
|
0
|
|
|
|
my $exists_history = ( $self->[HISTORY]->[EXISTS_F]->{$key} ||= [] ); |
85
|
0
|
|
|
|
|
|
push( @{$exists_history}, $result ); |
|
0
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return $result; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub DELETE { |
92
|
0
|
|
|
0
|
|
|
my ( $self, $key ) = @_; |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
$self->[BACKING_VAR]->DELETE($key); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Any non-read inherited operation should not alter the history. |
98
|
|
|
|
|
|
|
sub CLEAR { |
99
|
0
|
|
|
0
|
|
|
my $self = shift(@_); |
100
|
0
|
|
|
|
|
|
local $Test::Mimic::Recorder::SuspendRecording = 1; |
101
|
0
|
|
|
|
|
|
$self->SUPER::CLEAR(@_); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub SCALAR { |
105
|
0
|
|
|
0
|
|
|
my ( $self ) = @_; |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
my $result = $self->[BACKING_VAR]->SCALAR(); |
108
|
0
|
0
|
|
|
|
|
if ( ! $Test::Mimic::Recorder::SuspendRecording ) { |
109
|
0
|
|
|
|
|
|
push( @{ $self->[HISTORY]->[SCALAR_F] }, $result ); |
|
0
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
return $result; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |