| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package TAP::Parser::Result; |
|
2
|
|
|
|
|
|
|
|
|
3
|
32
|
|
|
32
|
|
152
|
use strict; |
|
|
32
|
|
|
|
|
36
|
|
|
|
32
|
|
|
|
|
763
|
|
|
4
|
32
|
|
|
32
|
|
116
|
use warnings; |
|
|
32
|
|
|
|
|
40
|
|
|
|
32
|
|
|
|
|
711
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
32
|
|
|
32
|
|
105
|
use base 'TAP::Object'; |
|
|
32
|
|
|
|
|
37
|
|
|
|
32
|
|
|
|
|
7652
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# make is_* methods |
|
11
|
32
|
|
|
32
|
|
133
|
my @attrs = qw( plan pragma test comment bailout version unknown yaml ); |
|
12
|
32
|
|
|
32
|
|
137
|
no strict 'refs'; |
|
|
32
|
|
|
|
|
42
|
|
|
|
32
|
|
|
|
|
2135
|
|
|
13
|
32
|
|
|
|
|
61
|
for my $token (@attrs) { |
|
14
|
256
|
|
|
|
|
274
|
my $method = "is_$token"; |
|
15
|
256
|
|
|
2788
|
|
9097
|
*$method = sub { return $token eq shift->type }; |
|
|
2788
|
|
|
|
|
164037
|
|
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
############################################################################## |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NAME |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
TAP::Parser::Result - Base class for TAP::Parser output objects |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 VERSION |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Version 3.39 |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our $VERSION = '3.39'; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# abstract class - not meant to be used directly |
|
36
|
|
|
|
|
|
|
# see TAP::Parser::ResultFactory for preferred usage |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# directly: |
|
39
|
|
|
|
|
|
|
use TAP::Parser::Result; |
|
40
|
|
|
|
|
|
|
my $token = {...}; |
|
41
|
|
|
|
|
|
|
my $result = TAP::Parser::Result->new( $token ); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 DESCRIPTION |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This is a simple base class used by L to store objects that |
|
46
|
|
|
|
|
|
|
represent the current bit of test output data from TAP (usually a single |
|
47
|
|
|
|
|
|
|
line). Unless you're subclassing, you probably won't need to use this module |
|
48
|
|
|
|
|
|
|
directly. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 METHODS |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head3 C |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# see TAP::Parser::ResultFactory for preferred usage |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# to use directly: |
|
57
|
|
|
|
|
|
|
my $result = TAP::Parser::Result->new($token); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Returns an instance the appropriate class for the test token passed in. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# new() implementation provided by TAP::Object |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _initialize { |
|
66
|
1333
|
|
|
1333
|
|
1795
|
my ( $self, $token ) = @_; |
|
67
|
1333
|
100
|
|
|
|
2740
|
if ($token) { |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# assign to a hash slice to make a shallow copy of the token. |
|
70
|
|
|
|
|
|
|
# I guess we could assign to the hash as (by default) there are not |
|
71
|
|
|
|
|
|
|
# contents, but that seems less helpful if someone wants to subclass us |
|
72
|
1332
|
|
|
|
|
4225
|
@{$self}{ keys %$token } = values %$token; |
|
|
1332
|
|
|
|
|
5627
|
|
|
73
|
|
|
|
|
|
|
} |
|
74
|
1333
|
|
|
|
|
6217
|
return $self; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
############################################################################## |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 Boolean methods |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The following methods all return a boolean value and are to be overridden in |
|
82
|
|
|
|
|
|
|
the appropriate subclass. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over 4 |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * C |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Indicates whether or not this is the test plan line. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1..3 |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * C |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Indicates whether or not this is a pragma line. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
pragma +strict |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item * C |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Indicates whether or not this is a test line. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
ok 1 Is OK! |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * C |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Indicates whether or not this is a comment. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# this is a comment |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * C |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Indicates whether or not this is bailout line. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Bail out! We're out of dilithium crystals. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * C |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Indicates whether or not this is a TAP version line. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
TAP version 4 |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * C |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Indicates whether or not the current line could be parsed. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
... this line is junk ... |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * C |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Indicates whether or not this is a YAML chunk. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=back |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
############################################################################## |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head3 C |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
print $result->raw; |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Returns the original line of text which was parsed. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
|
145
|
|
|
|
|
|
|
|
|
146
|
464
|
|
|
464
|
1
|
44822
|
sub raw { shift->{raw} } |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
############################################################################## |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head3 C |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my $type = $result->type; |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Returns the "type" of a token, such as C or C. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
|
157
|
|
|
|
|
|
|
|
|
158
|
4398
|
|
|
4398
|
1
|
17978
|
sub type { shift->{type} } |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
############################################################################## |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head3 C |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
print $result->as_string; |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Prints a string representation of the token. This might not be the exact |
|
167
|
|
|
|
|
|
|
output, however. Tests will have test numbers added if not present, TODO and |
|
168
|
|
|
|
|
|
|
SKIP directives will be capitalized and, in general, things will be cleaned |
|
169
|
|
|
|
|
|
|
up. If you need the original text for the token, see the C method. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
|
172
|
|
|
|
|
|
|
|
|
173
|
16
|
|
|
16
|
1
|
772
|
sub as_string { shift->{raw} } |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
############################################################################## |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head3 C |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
if ( $result->is_ok ) { ... } |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Reports whether or not a given result has passed. Anything which is B a |
|
182
|
|
|
|
|
|
|
test result returns true. This is merely provided as a convenient shortcut. |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |
|
185
|
|
|
|
|
|
|
|
|
186
|
197
|
|
|
197
|
1
|
34105
|
sub is_ok {1} |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
############################################################################## |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head3 C |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Deprecated. Please use C instead. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub passed { |
|
197
|
436
|
|
|
436
|
1
|
145156
|
warn 'passed() is deprecated. Please use "is_ok()"'; |
|
198
|
436
|
|
|
|
|
124501
|
shift->is_ok; |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
############################################################################## |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head3 C |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
if ( $result->has_directive ) { |
|
206
|
|
|
|
|
|
|
... |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Indicates whether or not the given result has a TODO or SKIP directive. |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=cut |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub has_directive { |
|
214
|
284
|
|
|
284
|
1
|
5478
|
my $self = shift; |
|
215
|
284
|
|
100
|
|
|
424
|
return ( $self->has_todo || $self->has_skip ); |
|
216
|
|
|
|
|
|
|
} |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
############################################################################## |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head3 C |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
if ( $result->has_todo ) { |
|
223
|
|
|
|
|
|
|
... |
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Indicates whether or not the given result has a TODO directive. |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=cut |
|
229
|
|
|
|
|
|
|
|
|
230
|
3832
|
|
100
|
3832
|
1
|
118788
|
sub has_todo { 'TODO' eq ( shift->{directive} || '' ) } |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
############################################################################## |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head3 C |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
if ( $result->has_skip ) { |
|
237
|
|
|
|
|
|
|
... |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Indicates whether or not the given result has a SKIP directive. |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=cut |
|
243
|
|
|
|
|
|
|
|
|
244
|
1757
|
|
100
|
1757
|
1
|
121955
|
sub has_skip { 'SKIP' eq ( shift->{directive} || '' ) } |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head3 C |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Set the directive associated with this token. Used internally to fake |
|
249
|
|
|
|
|
|
|
TODO tests. |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=cut |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
sub set_directive { |
|
254
|
4
|
|
|
4
|
1
|
11
|
my ( $self, $dir ) = @_; |
|
255
|
4
|
|
|
|
|
15
|
$self->{directive} = $dir; |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
1; |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head1 SUBCLASSING |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
Please see L for a subclassing overview. |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
Remember: if you want your subclass to be automatically used by the parser, |
|
265
|
|
|
|
|
|
|
you'll have to register it with L. |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
If you're creating a completely new result I, you'll probably need to |
|
268
|
|
|
|
|
|
|
subclass L too, or else it'll never get used. |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=head2 Example |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
package MyResult; |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
use strict; |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
use base 'TAP::Parser::Result'; |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
# register with the factory: |
|
279
|
|
|
|
|
|
|
TAP::Parser::ResultFactory->register_type( 'my_type' => __PACKAGE__ ); |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
sub as_string { 'My results all look the same' } |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
L, |
|
286
|
|
|
|
|
|
|
L, |
|
287
|
|
|
|
|
|
|
L, |
|
288
|
|
|
|
|
|
|
L, |
|
289
|
|
|
|
|
|
|
L, |
|
290
|
|
|
|
|
|
|
L, |
|
291
|
|
|
|
|
|
|
L, |
|
292
|
|
|
|
|
|
|
L, |
|
293
|
|
|
|
|
|
|
L, |
|
294
|
|
|
|
|
|
|
L, |
|
295
|
|
|
|
|
|
|
L, |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=cut |