line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Mimic::Library::MonitorArray; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
91
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1133
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use constant { |
9
|
|
|
|
|
|
|
# Instance variables |
10
|
1
|
|
|
|
|
1766
|
VALUE => 0, |
11
|
|
|
|
|
|
|
HISTORY => 1, |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# History fields |
14
|
|
|
|
|
|
|
FETCH_F => 0, |
15
|
|
|
|
|
|
|
FETCHSIZE_F => 1, |
16
|
|
|
|
|
|
|
EXISTS_F => 2, |
17
|
1
|
|
|
1
|
|
2481
|
}; |
|
1
|
|
|
|
|
2
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# basic methods |
20
|
|
|
|
|
|
|
sub TIEARRAY { |
21
|
0
|
|
|
0
|
|
|
my ( $class, $history, $val ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Initialize instance variables. |
24
|
0
|
|
|
|
|
|
my $self = []; |
25
|
0
|
|
|
|
|
|
@{ $self->[VALUE] = [] } = @{$val}; # Copy the array |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
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->[VALUE]->[$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->[VALUE]->[$index] = $value; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub FETCHSIZE { |
53
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $size = scalar( @{ $self->[VALUE] } ); |
|
0
|
|
|
|
|
|
|
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->[VALUE] } = $size - 1; #Set the index of the last element. |
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# other methods |
70
|
|
|
|
|
|
|
sub DELETE { |
71
|
0
|
|
|
0
|
|
|
my ( $self, $index ) = @_; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
delete $self->[VALUE]->[$index]; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub EXISTS { |
77
|
0
|
|
|
0
|
|
|
my ( $self, $index ) = @_; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $result = exists $self->[VALUE]->[$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
|
0
|
|
|
0
|
|
|
sub UNTIE { |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
0
|
|
|
sub DESTROY { |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |