line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Mimic::Library::MonitorTiedArray; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base qw; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
103
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use constant { |
9
|
|
|
|
|
|
|
# Instance variables |
10
|
1
|
|
|
|
|
1049
|
BACKING_VAR => 0, |
11
|
|
|
|
|
|
|
HISTORY => 1, |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# History fields |
14
|
|
|
|
|
|
|
FETCH_F => 0, |
15
|
|
|
|
|
|
|
FETCHSIZE_F => 1, |
16
|
|
|
|
|
|
|
EXISTS_F => 2, |
17
|
1
|
|
|
1
|
|
5
|
}; |
|
1
|
|
|
|
|
1
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# basic methods |
20
|
|
|
|
|
|
|
sub TIEARRAY { |
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, FETCHSIZE_F, EXISTS_F ) { |
27
|
0
|
|
|
|
|
|
$history->[$field] = []; |
28
|
|
|
|
|
|
|
} |
29
|
0
|
|
|
|
|
|
$self->[HISTORY] = $history; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
bless( $self, $class ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub FETCH { |
35
|
0
|
|
|
0
|
|
|
my ( $self, $index ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $value = $self->[BACKING_VAR]->FETCH($index); |
38
|
0
|
0
|
|
|
|
|
if ( ! $Test::Mimic::Recorder::SuspendRecording ) { |
39
|
0
|
|
0
|
|
|
|
my $index_history = ( $self->[HISTORY]->[FETCH_F]->[$index] ||= [] ); |
40
|
0
|
|
|
|
|
|
push( @{$index_history}, Test::Mimic::Library::monitor( $value ) ); |
|
0
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return $value; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub STORE { |
47
|
0
|
|
|
0
|
|
|
my ( $self, $index, $value ) = @_; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
$self->[BACKING_VAR]->STORE( $index, $value ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub FETCHSIZE { |
53
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $size = $self->[BACKING_VAR]->FETCHSIZE(); |
56
|
0
|
0
|
|
|
|
|
if ( ! $Test::Mimic::Recorder::SuspendRecording ) { |
57
|
0
|
|
|
|
|
|
push( @{ $self->[HISTORY]->[FETCHSIZE_F] }, $size ); |
|
0
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return $size; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub STORESIZE { |
64
|
0
|
|
|
0
|
|
|
my ( $self, $size ) = @_; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$self->[BACKING_VAR]->STORESIZE($size); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# other methods |
70
|
|
|
|
|
|
|
sub DELETE { |
71
|
0
|
|
|
0
|
|
|
my ( $self, $index ) = @_; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
$self->[BACKING_VAR]->DELETE($index); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub EXISTS { |
77
|
0
|
|
|
0
|
|
|
my ( $self, $index ) = @_; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $result = $self->[BACKING_VAR]->EXISTS($index); |
80
|
0
|
0
|
|
|
|
|
if ( ! $Test::Mimic::Recorder::SuspendRecording ) { |
81
|
0
|
|
0
|
|
|
|
my $exists_history = ( $self->[HISTORY]->[EXISTS_F]->[$index] ||= [] ); |
82
|
0
|
|
|
|
|
|
push( @{$exists_history}, $result ); |
|
0
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
return $result; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# We need to turn off recording for any non-read inherited operations. |
89
|
|
|
|
|
|
|
sub PUSH { |
90
|
0
|
|
|
0
|
|
|
my $self = shift(@_); |
91
|
0
|
|
|
|
|
|
local $Test::Mimic::Recorder::SuspendRecording = 1; |
92
|
0
|
|
|
|
|
|
$self->SUPER::PUSH(@_); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub UNSHIFT { |
96
|
0
|
|
|
0
|
|
|
my $self = shift(@_); |
97
|
0
|
|
|
|
|
|
local $Test::Mimic::Recorder::SuspendRecording = 1; |
98
|
0
|
|
|
|
|
|
$self->SUPER::UNSHIFT(@_); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# Not truly needed for CLEAR, but if the implementation of Tie::Hash changes this will save us. |
102
|
|
|
|
|
|
|
sub CLEAR { |
103
|
0
|
|
|
0
|
|
|
my $self = shift(@_); |
104
|
0
|
|
|
|
|
|
local $Test::Mimic::Recorder::SuspendRecording = 1; |
105
|
0
|
|
|
|
|
|
$self->SUPER::CLEAR(); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
#POP, SHIFT, and SPLICE will be inherited from Tie::Array |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# optional methods |
111
|
|
|
|
|
|
|
sub UNTIE { |
112
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
113
|
0
|
|
|
|
|
|
$self->[BACKING_VAR]->UNTIE(); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub DESTROY { |
117
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
118
|
0
|
|
|
|
|
|
$self->[BACKING_VAR]->DESTROY(); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |