line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Ranger; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
34124
|
use 5.010000; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
153
|
|
4
|
4
|
|
|
4
|
|
19
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
110
|
|
5
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
88
|
|
6
|
4
|
|
|
4
|
|
21
|
use Carp; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
401
|
|
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
3870
|
use version 0.77; our $VERSION = qv('0.0.4'); |
|
4
|
|
|
|
|
16145
|
|
|
4
|
|
|
|
|
30
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
4608
|
use Test::More; # Standard framework for writing test scripts |
|
4
|
|
|
|
|
66911
|
|
|
4
|
|
|
|
|
44
|
|
11
|
4
|
|
|
4
|
|
5529
|
use Data::Lock qw( dlock ); # Declare locked scalars, arrays, and hashes |
|
4
|
|
|
|
|
32313
|
|
|
4
|
|
|
|
|
298
|
|
12
|
4
|
|
|
4
|
|
40
|
use Scalar::Util; # General-utility scalar subroutines |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
339
|
|
13
|
4
|
|
|
4
|
|
4140
|
use Scalar::Util::Reftype; # Alternate reftype() interface |
|
4
|
|
|
|
|
27541
|
|
|
4
|
|
|
|
|
289
|
|
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
3033
|
use Test::Ranger::List; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
2014
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
## use |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Alternate uses |
20
|
|
|
|
|
|
|
#~ use Devel::Comments; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#============================================================================# |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Pseudo-globals |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#~ # Literal hash keys |
27
|
|
|
|
|
|
|
#~ dlock( my $coderef = '-coderef'); # cref to code under test |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#----------------------------------------------------------------------------# |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#=========# CLASS METHOD |
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
# my $obj = $class->new($self); |
34
|
|
|
|
|
|
|
# my $obj = $class->new(); |
35
|
|
|
|
|
|
|
# my $obj = $class->new({ -a => 'x' }); |
36
|
|
|
|
|
|
|
# my $obj = $class->new([ 1, 2, 3, 4 ]); |
37
|
|
|
|
|
|
|
# |
38
|
|
|
|
|
|
|
# Purpose : Object constructor |
39
|
|
|
|
|
|
|
# Parms : $class : Any subclass of this class |
40
|
|
|
|
|
|
|
# : $self : Hashref or arrayref |
41
|
|
|
|
|
|
|
# Returns : $self |
42
|
|
|
|
|
|
|
# Invokes : init(), Test::Ranger::List::new() |
43
|
|
|
|
|
|
|
# |
44
|
|
|
|
|
|
|
# If invoked with $class only, blesses and returns an empty hashref. |
45
|
|
|
|
|
|
|
# If invoked with $class and a hashref, blesses and returns it. |
46
|
|
|
|
|
|
|
# If invoked with $class and an arrayref, invokes ::List::new(). |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
sub new { |
49
|
8
|
|
|
8
|
1
|
3035
|
my $class = shift; |
50
|
8
|
|
100
|
|
|
33
|
my $self = shift || {}; # default: hashref |
51
|
|
|
|
|
|
|
|
52
|
8
|
100
|
|
|
|
43
|
if ( (reftype $self)->array ) { |
53
|
1
|
|
|
|
|
76
|
$self = Test::Ranger::List->new($self); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
7
|
|
|
|
|
1138
|
bless ($self => $class); |
57
|
7
|
|
|
|
|
24
|
$self->init(); |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
8
|
|
|
|
|
129
|
return $self; |
61
|
|
|
|
|
|
|
}; ## new |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#=========# OBJECT METHOD |
64
|
|
|
|
|
|
|
# |
65
|
|
|
|
|
|
|
# $obj->init(); |
66
|
|
|
|
|
|
|
# |
67
|
|
|
|
|
|
|
# Purpose : Initialize housekeeping info. |
68
|
|
|
|
|
|
|
# Parms : $class : Any subclass of this class |
69
|
|
|
|
|
|
|
# : $self : Hashref |
70
|
|
|
|
|
|
|
# Returns : $self |
71
|
|
|
|
|
|
|
# |
72
|
|
|
|
|
|
|
sub init { |
73
|
9
|
|
|
9
|
0
|
14
|
my $self = shift; |
74
|
|
|
|
|
|
|
|
75
|
9
|
|
|
|
|
44
|
$self->{-plan_counter} = 0; |
76
|
9
|
|
|
|
|
22
|
$self->{-expanded} = 0; |
77
|
|
|
|
|
|
|
|
78
|
9
|
|
|
|
|
15
|
return $self; |
79
|
|
|
|
|
|
|
}; ## init |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#=========# OBJECT METHOD |
82
|
|
|
|
|
|
|
# |
83
|
|
|
|
|
|
|
# $single->expand(); |
84
|
|
|
|
|
|
|
# |
85
|
|
|
|
|
|
|
# Purpose : Expand/parse declaration into canonical form. |
86
|
|
|
|
|
|
|
# Parms : $class |
87
|
|
|
|
|
|
|
# : $self |
88
|
|
|
|
|
|
|
# Returns : $self |
89
|
|
|
|
|
|
|
# |
90
|
|
|
|
|
|
|
sub expand { |
91
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Default givens |
94
|
1
|
50
|
|
|
|
6
|
if ( !$self->{-given}{-args} ) { |
95
|
1
|
|
|
|
|
4
|
$self->{-given}{-args} = []; |
96
|
|
|
|
|
|
|
}; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Default expectations |
99
|
1
|
50
|
|
|
|
5
|
if ( !$self->{-return}{-want} ) { |
100
|
1
|
|
|
|
|
4
|
$self->{-return}{-want} = 1; |
101
|
|
|
|
|
|
|
}; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
2
|
$self->{-expanded} = 1; |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
2
|
return $self; |
108
|
|
|
|
|
|
|
}; ## expand |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#=========# OBJECT METHOD |
111
|
|
|
|
|
|
|
# |
112
|
|
|
|
|
|
|
# $single->execute(); |
113
|
|
|
|
|
|
|
# |
114
|
|
|
|
|
|
|
# Execute a $single object. |
115
|
|
|
|
|
|
|
# |
116
|
|
|
|
|
|
|
sub execute { |
117
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
118
|
|
|
|
|
|
|
|
119
|
1
|
50
|
|
|
|
6
|
$self->expand() if !$self->{-expanded}; |
120
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
2
|
my $coderef = $self->{-coderef}; |
122
|
1
|
|
|
|
|
1
|
my @args = @{ $self->{-given}{-args} }; |
|
1
|
|
|
|
|
4
|
|
123
|
|
|
|
|
|
|
### $coderef |
124
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
4
|
$self->{-return}{-got} = &$coderef( @args ); |
126
|
|
|
|
|
|
|
|
127
|
1
|
|
|
|
|
5
|
return $self; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
}; ## execute |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
#=========# OBJECT METHOD |
132
|
|
|
|
|
|
|
# |
133
|
|
|
|
|
|
|
# $single->check(); |
134
|
|
|
|
|
|
|
# |
135
|
|
|
|
|
|
|
# Check results in a $single object. |
136
|
|
|
|
|
|
|
# |
137
|
|
|
|
|
|
|
sub check { |
138
|
1
|
|
|
1
|
1
|
1
|
my $self = shift; |
139
|
|
|
|
|
|
|
|
140
|
1
|
|
|
|
|
11
|
is( $self->{-return}{-got}, $self->{-return}{-want}, $self->{-fullname} ); |
141
|
1
|
|
|
|
|
762
|
$self->{-plan_counter}++; |
142
|
|
|
|
|
|
|
|
143
|
1
|
|
|
|
|
3
|
return $self; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
}; ## check |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
#=========# OBJECT METHOD |
148
|
|
|
|
|
|
|
# |
149
|
|
|
|
|
|
|
# $single->test(); |
150
|
|
|
|
|
|
|
# |
151
|
|
|
|
|
|
|
# Execute and check a $single object. |
152
|
|
|
|
|
|
|
# |
153
|
|
|
|
|
|
|
sub test { |
154
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
155
|
|
|
|
|
|
|
|
156
|
1
|
|
|
|
|
4
|
$self->execute(); |
157
|
1
|
|
|
|
|
4
|
$self->check(); |
158
|
|
|
|
|
|
|
|
159
|
1
|
|
|
|
|
1
|
return $self; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
}; ## test |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
#=========# OBJECT METHOD |
164
|
|
|
|
|
|
|
# |
165
|
|
|
|
|
|
|
# $single->done(); |
166
|
|
|
|
|
|
|
# |
167
|
|
|
|
|
|
|
# Conclude testing. |
168
|
|
|
|
|
|
|
# |
169
|
|
|
|
|
|
|
sub done { |
170
|
1
|
|
|
1
|
0
|
4
|
my $self = shift; |
171
|
|
|
|
|
|
|
|
172
|
1
|
|
|
|
|
7
|
done_testing( $self->{-done_counter} ); |
173
|
|
|
|
|
|
|
|
174
|
1
|
|
|
|
|
339
|
return $self; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
}; ## done |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
## END MODULE |
180
|
|
|
|
|
|
|
1; |
181
|
|
|
|
|
|
|
#============================================================================# |
182
|
|
|
|
|
|
|
__END__ |