line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TAPx::Parser::Result; |
2
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
20821
|
use strict; |
|
13
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
519
|
|
4
|
13
|
|
|
13
|
|
70
|
use vars qw($VERSION); |
|
13
|
|
|
|
|
94
|
|
|
13
|
|
|
|
|
450
|
|
5
|
|
|
|
|
|
|
|
6
|
13
|
|
|
13
|
|
6516
|
use TAPx::Parser::Result::Plan; |
|
13
|
|
|
|
|
34
|
|
|
13
|
|
|
|
|
1755
|
|
7
|
13
|
|
|
13
|
|
6770
|
use TAPx::Parser::Result::Test; |
|
13
|
|
|
|
|
31
|
|
|
13
|
|
|
|
|
366
|
|
8
|
13
|
|
|
13
|
|
12196
|
use TAPx::Parser::Result::Comment; |
|
13
|
|
|
|
|
30
|
|
|
13
|
|
|
|
|
434
|
|
9
|
13
|
|
|
13
|
|
6129
|
use TAPx::Parser::Result::Bailout; |
|
13
|
|
|
|
|
33
|
|
|
13
|
|
|
|
|
378
|
|
10
|
13
|
|
|
13
|
|
5952
|
use TAPx::Parser::Result::Unknown; |
|
13
|
|
|
|
|
27
|
|
|
13
|
|
|
|
|
476
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
BEGIN { |
13
|
13
|
|
|
13
|
|
65
|
no strict 'refs'; |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
1108
|
|
14
|
13
|
|
|
13
|
|
43
|
foreach my $token (qw) { |
15
|
65
|
|
|
|
|
131
|
my $method = "is_$token"; |
16
|
65
|
|
|
1553
|
|
6655
|
*$method = sub { return $token eq shift->type }; |
|
1553
|
|
|
|
|
139681
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
############################################################################## |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 NAME |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
TAPx::Parser::Result - TAPx::Parser output |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 VERSION |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Version 0.50_07 |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$VERSION = '0.50_07'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 DESCRIPTION |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
This is merely a factory class which returns an object representing the |
37
|
|
|
|
|
|
|
current bit of test data from TAP (usually a line). It's for internal use |
38
|
|
|
|
|
|
|
only and should not be relied upon. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# note that this is bad. Makes it very difficult to subclass, but then, it |
43
|
|
|
|
|
|
|
# would be a lot of work to subclass this system. |
44
|
|
|
|
|
|
|
my %class_for = ( |
45
|
|
|
|
|
|
|
plan => 'TAPx::Parser::Result::Plan', |
46
|
|
|
|
|
|
|
test => 'TAPx::Parser::Result::Test', |
47
|
|
|
|
|
|
|
comment => 'TAPx::Parser::Result::Comment', |
48
|
|
|
|
|
|
|
bailout => 'TAPx::Parser::Result::Bailout', |
49
|
|
|
|
|
|
|
unknown => 'TAPx::Parser::Result::Unknown', |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
############################################################################## |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 METHODS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head3 C |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $result = TAPx::Parser::Result->new($token); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Returns an instance the appropriate class for the test token passed in. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub new { |
65
|
369
|
|
|
369
|
1
|
1554
|
my ( $class, $token ) = @_; |
66
|
369
|
|
|
|
|
856
|
my $type = $token->{type}; |
67
|
369
|
100
|
|
|
|
3720
|
return bless $token => $class_for{$type} |
68
|
|
|
|
|
|
|
if exists $class_for{$type}; |
69
|
1
|
|
|
|
|
12
|
require Carp; |
70
|
1
|
|
|
|
|
1266
|
require Data::Dumper; |
71
|
1
|
|
|
|
|
9084
|
$Data::Dumper::Indent = 1; |
72
|
1
|
|
|
|
|
2
|
$Data::Dumper::Terse = 1; |
73
|
1
|
|
|
|
|
4
|
$token = Data::Dumper::Dumper($token); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# this should never happen! |
76
|
1
|
|
|
|
|
286
|
Carp::croak("Could not determine class for\n$token"); |
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 test line. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
is $foo, $bar, $description; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item * C |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Indicates whether or not this is a comment. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# this is a comment |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * C |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Indicates whether or not this is bailout line. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Bail out! We're out of dilithium crystals. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * C |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Indicates whether or not the current line could be parsed. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
... this line is junk ... |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=back |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
############################################################################## |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head3 C |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
print $result->raw; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Returns the original line of text which was parsed. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
96
|
|
|
96
|
1
|
26602
|
sub raw { shift->{raw} } |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
############################################################################## |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head3 C |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
my $type = $result->type; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Returns the "type" of a token, such as C or C. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
2278
|
|
|
2278
|
1
|
23521
|
sub type { shift->{type} } |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
############################################################################## |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head3 C |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
print $result->as_string; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Prints a string representation of the token. This might not be the exact |
151
|
|
|
|
|
|
|
output, however. Tests will have test numbers added if not present, TODO and |
152
|
|
|
|
|
|
|
SKIP directives will be capitalized and, in general, things will be cleaned |
153
|
|
|
|
|
|
|
up. If you need the original text for the token, see the C method. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|
157
|
39
|
|
|
39
|
1
|
917
|
sub as_string { shift->{raw} } |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
############################################################################## |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head3 C |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
if ( $result->is_ok ) { ... } |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Reports whether or not a given result has passed. Anything which is B a |
166
|
|
|
|
|
|
|
test result returns true. This is merely provided as a convenient shortcut. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
87
|
|
|
87
|
1
|
31271
|
sub is_ok {1} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
############################################################################## |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head3 C |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Deprecated. Please use C instead. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub passed { |
181
|
170
|
|
|
170
|
1
|
88248
|
warn 'passed() is deprecated. Please use "is_ok()"'; |
182
|
170
|
|
|
|
|
83335
|
shift->is_ok; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
############################################################################## |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head3 C |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
if ( $result->has_directive ) { |
190
|
|
|
|
|
|
|
... |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Indicates whether or not the given result has a TODO or SKIP directive. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub has_directive { |
198
|
11
|
|
|
11
|
1
|
5780
|
my $self = shift; |
199
|
11
|
|
100
|
|
|
64
|
return ($self->has_todo || $self->has_skip) || ''; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
############################################################################## |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head3 C |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
if ( $result->has_todo ) { |
207
|
|
|
|
|
|
|
... |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Indicates whether or not the given result has a TODO directive. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=cut |
213
|
|
|
|
|
|
|
|
214
|
1569
|
|
100
|
1569
|
1
|
63473
|
sub has_todo { 'TODO' eq (shift->{directive} || '') } |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
############################################################################## |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head3 C |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
if ( $result->has_skip ) { |
221
|
|
|
|
|
|
|
... |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
Indicates whether or not the given result has a SKIP directive. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=cut |
227
|
|
|
|
|
|
|
|
228
|
399
|
|
100
|
399
|
1
|
88673
|
sub has_skip { 'SKIP' eq (shift->{directive} || '') } |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
1; |