DOM.pm

filter: Statementstmt 99.3% 300 / 302 Branchbran 86.4% 159 / 184 Conditioncond 84.7% 89 / 105 MC/DCmcdc 69.4% 41 / 59 Subroutinesub 100% 26 / 26 Podpod 100% 7 / 7 totaltotal 91.0% 622 / 683 CC 141 SCAR 43.0
CC
141
Cov
93%
new
111.3
_entry_to_tapline
18.5
preprocess_ignorelines
5.1
CRAP 73.7
↑ Summary DOM/Archive.pm »
1 package TAP::DOM;
2 # git description: v1.001-4-g8f1a848
3  
4 25 our $AUTHORITY = 'cpan:SCHWIGON';
5 # ABSTRACT: TAP as Document Object Model.
6 25 $TAP::DOM::VERSION = '1.002';
7 25 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 25 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 25 ▶use TAP::DOM::Entry;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 25 ▶use TAP::DOM::Summary;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 25 ▶use TAP::DOM::DocumentData;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 25 ▶use TAP::DOM::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 25 ▶use TAP::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 25 ▶use TAP::Parser::Aggregator;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 25 ▶use YAML::Syck;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 25 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 25 our $IS_PLAN = 1;
21 25 our $IS_OK = 2;
22 25 our $IS_TEST = 4;
23 25 our $IS_COMMENT = 8;
24 25 our $IS_UNKNOWN = 16;
25 25 our $IS_ACTUAL_OK = 32;
26 25 our $IS_VERSION = 64;
27 25 our $IS_PRAGMA = 128;
28 25 our $IS_UNPLANNED = 256;
29 25 our $IS_BAILOUT = 512;
30 25 our $IS_YAML = 1024;
31 25 our $HAS_SKIP = 2048;
32 25 our $HAS_TODO = 4096;
33  
34 25 our @tap_dom_args = (qw(ignore
35 ignorelines
36 dontignorelines
37 ignoreunknown
38 usebitsets
39 sparse
40 disable_global_kv_data
41 put_dangling_kv_data_under_lazy_plan
42 document_data_prefix
43 document_data_ignore
44 preprocess_ignorelines
45 preprocess_tap
46 noempty_tap
47 utf8
48 lowercase_fieldnames
49 lowercase_fieldvalues
50 trim_fieldvalues
51 normalize
52 ));
53  
54 25 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
55 25 our @EXPORT_OK = qw( $IS_PLAN
56 $IS_OK
57 $IS_TEST
58 $IS_COMMENT
59 $IS_UNKNOWN
60 $IS_ACTUAL_OK
61 $IS_VERSION
62 $IS_PRAGMA
63 $IS_UNPLANNED
64 $IS_BAILOUT
65 $IS_YAML
66 $HAS_SKIP
67 $HAS_TODO
68 );
69 25 our %EXPORT_TAGS = (constants => [ qw( $IS_PLAN
70 $IS_OK
71 $IS_TEST
72 $IS_COMMENT
73 $IS_UNKNOWN
74 $IS_ACTUAL_OK
75 $IS_VERSION
76 $IS_PRAGMA
77 $IS_UNPLANNED
78 $IS_BAILOUT
79 $IS_YAML
80 $HAS_SKIP
81 $HAS_TODO
82 ) ] );
83  
84 25 our %mnemonic = (
85 severity => {
86 1 => 'ok',
87 2 => 'ok_todo',
88 3 => 'ok_skip',
89 4 => 'notok_todo',
90 5 => 'notok',
91 6 => 'notok_skip', # forbidden TAP semantic, should never happen
92 },
93 );
94  
95 # TAP severity level definition:
96 #
97 # |--------+---------------+----------+--------------+----------+------------+----------|
98 # | *type* | is_ok | has_todo | is_actual_ok | has_skip | *mnemonic* | *tapcon* |
99 # |--------+---------------+----------+--------------+----------+------------+----------|
100 # | plan | undef | undef | undef | 1 | ok_skip | 3 |
101 # |--------+---------------+----------+--------------+----------+------------+----------|
102 # | test | 1 | 0 | 0 | 0 | ok | 1 |
103 # | test | 1 | 1 | 1 | 0 | ok_todo | 2 |
104 # | test | 1 | 0 | 0 | 1 | ok_skip | 3 |
105 # | test | 1 | 1 | 0 | 0 | notok_todo | 4 |
106 # | test | 0 | 0 | 0 | 0 | notok | 5 |
107 # | test | 0 | 0 | 0 | 1 | notok_skip | 6 |
108 # |--------+---------------+----------+--------------+----------+------------+----------|
109 # | | | | | | missing | 0 |
110 # |--------+---------------+----------+--------------+----------+------------+----------|
111 # | *type* | *value* | | | | | |
112 # |--------+---------------+----------+--------------+----------+------------+----------|
113 # | pragma | +tapdom_error | | | | notok | 5 |
114 # |--------+---------------+----------+--------------+----------+------------+----------|
115  
116 25 our $severity = {};
117 #
118 # {type} {is_ok} {has_todo} {is_actual_ok} {has_skip} = $severity;
119 #
120 25 $severity->{plan} {0} {0} {0} {1} = 3; # ok_skip
121 25 $severity->{test} {1} {0} {0} {0} = 1; # ok
122 25 $severity->{test} {1} {1} {1} {0} = 2; # ok_todo
123 25 $severity->{test} {1} {0} {0} {1} = 3; # ok_skip
124 25 $severity->{test} {1} {1} {0} {0} = 4; # notok_todo
125 25 $severity->{test} {0} {0} {0} {0} = 5; # notok
126 25 $severity->{test} {0} {0} {0} {1} = 6; # notok_skip
127  
128 25 our $obvious_tap_line = qr/(1\.\.|ok\s|not\s+ok\s|#|\s|tap\s+version|pragma|Bail out!)/i;
129  
130 25 our $noempty_tap = "pragma +tapdom_error\n# document was empty";
131  
132 use Class::XSAccessor
133 25 ▶ chained => 1,
Subroutine BEGIN: called CC=1 SCAR=0.0
134 accessors => [qw( plan
135 lines
136 pragmas
137 tests_planned
138 tests_run
139 version
140 is_good_plan
141 skip_all
142 start_time
143 end_time
144 has_problems
145 exit
146 parse_errors
147 parse_errors_msgs
148 summary
149 tapdom_config
150 document_data
151 25 )];
152  
153 146 ▶sub _capture_group {
Subroutine _capture_group: called CC=1 SCAR=0.0
154 146 my ($s, $n) = @_; substr($s, $-[$n], $+[$n] - $-[$n]);
155 }
156  
157 291 ▶sub normalize_tap_line {
Subroutine normalize_tap_line: called CC=3 SCAR=11.0
Pod documented
158 291 my ($line) = @_;
159  
160 291 ▶ return $line unless $line =~ m/^(not\s+)?(ok)\s+/;
Branch: 1 branch
BranchTrueFalseTotal
unless $line =~ /^(not\s+)?(ok)\s+/ 10 281 291
161  
162 281 ▶ $line =~ s{^(not\s)?\s*(ok)\s+(\d+\s)?\s*(-\s+)?\s*}{($1//'').$2.' '}e;
Condition100%2/2
$1 // ""
l!l
47234
MC/DC100%1/1
$1 // ""
$1
Truth table100%2/2
A
A= $1
Aresult
11
00
163 281 $line =~ s/['"]//g;
164 281 $line =~ s/\\(?!#\s*(todo|skip)\b)//gi;
165 281 $line =~ s/\s*(?<!\\)#\s*(todo|skip)\b/' # '.uc($1)/ei;
166 281 $line =~ s/^\s+//g;
167 281 $line =~ s/\s+$//g;
168  
169 281 return $line;
170 }
171  
172 # Optimize the TAP text before parsing it.
173 4 ▶sub preprocess_ignorelines {
Subroutine preprocess_ignorelines: called CC=5 SCAR=16.2
Pod documented
174 4 my %args = @_;
175  
176 4 ▶ if ($args{tap}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"tap"}) 4 0 4
177  
178 4 ▶ if (my $ignorelines = $args{ignorelines}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ignorelines = $args{"ignorelines"}) 4 0 4
179 4 my $dontignorelines = $args{dontignorelines};
180 4 my $tap = $args{tap};
181 4 ▶ if ($dontignorelines) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dontignorelines) { } 2 2 4
182 # HIGHLY EXPERIMENTAL!
183 #
184 # We convert the 'dontignorelines' regex into a negative-lookahead
185 # condition and prepend it before the 'ignorelines'.
186 #
187 # Why? Because we want to utilize the cleanup in one single
188 # operation as fast as the regex engine can do it.
189 2 ▶ my $re_dontignorelines = $dontignorelines ? "(?!$dontignorelines)" : '';
Branch: 1 branch
BranchTrueFalseTotal
$dontignorelines ? : 2 0 2
190 2 my $re_filter = qr/^$re_dontignorelines$ignorelines.*[\r\n]*/m; # the /m scope needs to be here!
191 2 $tap =~ s/$re_filter//g;
192 } else {
193 2 $tap =~ s/^$ignorelines.*[\r\n]*//mg;
194 }
195 4 $args{tap} = $tap;
196 4 delete $args{ignorelines}; # don't try it again during parsing later
197 }
198 }
199  
200 4 return %args
201 }
202  
203 # Filter away obvious non-TAP lines before parsing it.
204 4 ▶sub preprocess_tap {
Subroutine preprocess_tap: called CC=2 SCAR=7.0
Pod documented
205 4 my %args = @_;
206  
207 4 ▶ if ($args{tap}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"tap"}) 4 0 4
208 4 my $tap = $args{tap};
209 4 $tap =~ s/^(?!$obvious_tap_line).*[\r\n]*//mg;
210 4 $args{tap} = $tap;
211 }
212  
213 4 return %args
214 }
215  
216 # Mark empty TAP with replacement lines
217 21 ▶sub noempty_tap {
Subroutine noempty_tap: called CC=5 SCAR=16.1
Pod documented
218 21 my %args = @_;
219  
220 21 ▶ if (defined($args{tap}) and $args{tap} eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $args{'tap'} and $args{'tap'} eq '') { } 3 18 21
elsif (defined $args{'source'} and -z $args{'source'}) { } 1 33 34
Condition100%3/3
defined $args{"tap"} and $args{"tap"} eq ""
!ll&&!rl&&r
2163
MC/DC100%2/2
defined $args{"tap"} and $args{"tap"} eq ""
defined $args{"tap"} $args{"tap"} eq ""
Truth table100%3/3
A and B
A= defined $args{"tap"}B= $args{"tap"} eq ""
ABresult
0X0
100
111
221 3 $args{tap} = $noempty_tap;
222 }
223 ▶ elsif (defined($args{source}) and -z $args{source}) {
Condition100%3/3
defined $args{"source"} and -z $args{"source"}
!ll&&!rl&&r
1611
MC/DC100%2/2
defined $args{"source"} and -z $args{"source"}
defined $args{"source"} -z $args{"source"}
Truth table100%3/3
A and B
A= defined $args{"source"}B= -z $args{"source"}
ABresult
0X0
100
111
224 1 $args{tap} = $noempty_tap;
225 1 delete $args{source};
226 }
227  
228 21 return %args
229 }
230  
231 # Assume TAP is UTF-8 and filter out forbidden characters.
232 #
233 # Convert illegal chars into Unicode 'REPLACEMENT CHARACTER'
234 # (\N{U+FFFD} ... i.e. diamond with question mark in it).
235 #
236 # For more info see:
237 #
238 # - https://stackoverflow.com/a/2656433/1342345
239 # - https://metacpan.org/pod/Encode#FB_DEFAULT
240 # - https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character
241 #
242 # Additionall convert \0 as it's not covered by Encode::decode()
243 # but is still illegal for some tools.
244 2 ▶sub utf8_tap {
Subroutine utf8_tap: called CC=4 SCAR=13.9
Pod documented
245 2 my %args = @_;
246  
247 2 ▶ if ($args{source}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"source"}) 2 0 2
248 2 local $/;
249 2 my $F;
250 2 ▶ if (ref($args{source}) eq 'GLOB') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args{'source'} eq 'GLOB') { } 1 1 2
251 1 $F = $args{source};
252 } else {
253 1 open $F, '<', $args{source};
254 }
255 2 $args{tap} = <$F>;
256 2 close $F;
257 2 delete $args{source};
258 }
259  
260 2 ▶ if ($args{tap}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"tap"}) 2 0 2
261 2 require Encode;
262 2 $args{tap} = Encode::decode('UTF-8', $args{tap});
263 2 $args{tap} =~ s/\0/\N{U+FFFD}/g;
264 2 delete $args{utf8}; # don't try it again during parsing later
265 }
266 2 return %args
267 }
268  
269 80 ▶sub new {
Subroutine new: called CC=106 SCAR=47.1
Pod documented
270 # hash or hash ref
271 80 my $class = shift;
272 0 ▶ my %args = @_ == 1 ? %{$_[0]} : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 80 80
273  
274 80 my @lines;
275 my $plan;
276 80 my $version;
277 80 my @pragmas;
278 80 my $bailout;
279 80 my %document_data;
280 80 my %dangling_kv_data;
281  
282 80 ▶ %args = preprocess_ignorelines(%args) if $args{preprocess_ignorelines};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"preprocess_ignorelines"} 4 76 80
283 80 ▶ %args = preprocess_tap(%args) if $args{preprocess_tap};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"preprocess_tap"} 4 76 80
284 80 ▶ %args = noempty_tap(%args) if $args{noempty_tap};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"noempty_tap"} 21 59 80
285 80 ▶ %args = utf8_tap(%args) if $args{utf8};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"utf8"} 2 78 80
286  
287 80 my %IGNORE = map { $_ => 1 } @{$args{ignore}};
288 80 my $IGNORELINES = $args{ignorelines};
289 80 my $DONTIGNORELINES = $args{dontignorelines};
290 80 my $IGNOREUNKNOWN = $args{ignoreunknown};
291 80 my $USEBITSETS = $args{usebitsets};
292 80 my $SPARSE = $args{sparse};
293 80 my $DISABLE_GLOBAL_KV_DATA = $args{disable_global_kv_data};
294 80 my $PUT_DANGLING_KV_DATA_UNDER_LAZY_PLAN = $args{put_dangling_kv_data_under_lazy_plan};
295 80 ▶ my $DOC_DATA_PREFIX = $args{document_data_prefix} || 'Test-';
Condition50%1/2
$args{'document_data_prefix'} || 'Test-'
l!l
080
MC/DC0%0/1
$args{'document_data_prefix'} || 'Test-'
$args{'document_data_prefix'}
Truth table50%1/2
A
A= $args{'document_data_prefix'}
Aresult
11
00
296 80 my $DOC_DATA_IGNORE = $args{document_data_ignore};
297 80 my $LOWERCASE_FIELDNAMES = $args{lowercase_fieldnames};
298 80 my $LOWERCASE_FIELDVALUES = $args{lowercase_fieldvalues};
299 80 my $TRIM_FIELDVALUES = $args{trim_fieldvalues};
300 80 my $NOEMPTY_TAP = $args{noempty_tap};
301 80 my $NORMALIZE = $args{normalize};
302 80 delete $args{ignore};
303 80 delete $args{ignorelines};
304 80 delete $args{dontignorelines};
305 80 delete $args{ignoreunknown};
306 80 delete $args{usebitsets};
307 80 delete $args{sparse};
308 80 delete $args{disable_global_kv_data};
309 80 delete $args{put_dangling_kv_data_under_lazy_plan};
310 80 delete $args{document_data_prefix};
311 80 delete $args{document_data_ignore};
312 80 delete $args{preprocess_ignorelines};
313 80 delete $args{preprocess_tap};
314 80 delete $args{noempty_tap};
315 80 delete $args{utf8};
316 80 delete $args{lowercase_fieldnames};
317 80 delete $args{lowercase_fieldvalues};
318 80 delete $args{trim_fieldvalues};
319 80 delete $args{normalize};
320  
321 80 my $document_data_regex = qr/^#\s*$DOC_DATA_PREFIX([^:]+)\s*:\s*(.*)$/;
322 80 ▶ my $document_data_ignore = defined($DOC_DATA_IGNORE) ? qr/$DOC_DATA_IGNORE/ : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $DOC_DATA_IGNORE ? : 5 75 80
323  
324 80 my $parser = TAP::Parser->new( { %args } );
325  
326 80 my $aggregate = TAP::Parser::Aggregator->new;
327 80 $aggregate->start;
328  
329 80 my $count_tap_lines = 0;
330 80 my $found_pragma_tapdom_error = 0;
331 80 ▶ while ( my $result = $parser->next ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $result = $parser->next) 870 80 950
332 25 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
333  
334 870 ▶ next if $IGNORELINES && $result->raw =~ m/$IGNORELINES/ && !($DONTIGNORELINES && $result->raw =~ m/$DONTIGNORELINES/);
Branch: 1 branch
BranchTrueFalseTotal
if $IGNORELINES and $result->raw =~ /$IGNORELINES/ and not $DONTIGNORELINES && $result->raw =~ /$DONTIGNORELINES/ 26 844 870
Condition100%9/9
$IGNORELINES and $result->raw =~ /$IGNORELINES/ and not $DONTIGNORELINES && $result->raw =~ /$DONTIGNORELINES/
!ll&&!rl&&r
842226
$IGNORELINES and $result->raw =~ /$IGNORELINES/
!ll&&!rl&&r
8241828
$DONTIGNORELINES && $result->raw =~ /$DONTIGNORELINES/
!ll&&!rl&&r
14122
MC/DC100%4/4
$IGNORELINES and $result->raw =~ /$IGNORELINES/ and not $DONTIGNORELINES && $result->raw =~ /$DONTIGNORELINES/
$IGNORELINES $result->raw =~ /$IGNORELINES/ $DONTIGNORELINES $result->raw =~ /$DONTIGNORELINES/
Truth table100%5/5
A and B and not(C && D)
A= $IGNORELINESB= $result->raw =~ /$IGNORELINES/C= $DONTIGNORELINESD= $result->raw =~ /$DONTIGNORELINES/
ABCDresult
0XXX0
10XX0
11110
110X1
11101
335 844 ▶ next if $IGNOREUNKNOWN and $result->is_unknown;
Branch: 1 branch
BranchTrueFalseTotal
if $IGNOREUNKNOWN and $result->is_unknown 2 842 844
Condition100%3/3
$IGNOREUNKNOWN and $result->is_unknown
!ll&&!rl&&r
821212
MC/DC100%2/2
$IGNOREUNKNOWN and $result->is_unknown
$IGNOREUNKNOWN $result->is_unknown
Truth table100%3/3
A and B
A= $IGNOREUNKNOWNB= $result->is_unknown
ABresult
0X0
100
111
336  
337 842 my $entry = TAP::DOM::Entry->new;
338 842 ▶ $entry->{is_has} = 0 if $USEBITSETS;
Branch: 1 branch
BranchTrueFalseTotal
if $USEBITSETS 7 835 842
339  
340 # test info
341 842 foreach (qw(type raw as_string )) {
342 2526 ▶ $entry->{$_} = $result->$_ unless $IGNORE{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $IGNORE{$_} 2486 40 2526
343 }
344 842 ▶ $entry->{normalized} = $result->is_test ? normalize_tap_line($result->raw) : $result->raw;
Branch: 1 branch
BranchTrueFalseTotal
$result->is_test ? : 281 561 842
345  
346 842 ▶ if ($result->is_test) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_test) 281 561 842
347 281 foreach (qw(directive explanation number description )) {
348 1124 ▶ $entry->{$_} = $result->$_ unless $IGNORE{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $IGNORE{$_} 1116 8 1124
349 }
350 281 foreach (qw(is_ok is_unplanned )) {
351 562 ▶ if ($USEBITSETS) {
Branch: 2 branches
BranchTrueFalseTotal
if ($USEBITSETS) { } 8 554 562
elsif ($SPARSE) { } 8 546 554
352 8 ▶ $entry->{is_has} |= $result->$_ ? ${uc $_} : 0 unless $IGNORE{$_};
Branch: 2 branches
BranchTrueFalseTotal
unless $IGNORE{$_} 8 0 8
$result->$_ ? : 4 4 8
353 } elsif ($SPARSE) {
354 # don't set 'false' fields at all in sparse mode
355 8 ▶ $entry->{$_} = 1 if $result->$_ and not $IGNORE{$_};
Branch: 1 branch
BranchTrueFalseTotal
if $result->$_ and not $IGNORE{$_} 4 4 8
Condition66%2/3
$result->$_ and not $IGNORE{$_}
!ll&&!rl&&r
404
MC/DC50%1/2
$result->$_ and not $IGNORE{$_}
$result->$_ not $IGNORE{$_}
Truth table66%2/3
A and not(B)
A= $result->$_B= not $IGNORE{$_}
ABresult
0X0
100
111
356 } else {
357 546 ▶ $entry->{$_} = $result->$_ ? 1 : 0 unless $IGNORE{$_};
Branch: 2 branches
BranchTrueFalseTotal
unless $IGNORE{$_} 546 0 546
$result->$_ ? : 267 279 546
358 }
359 }
360 }
361  
362 # plan
363 842 ▶ if ($result->is_plan) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_plan) 71 771 842
364 71 $plan = $result->as_string;
365 71 foreach (qw(directive explanation)) {
366 142 ▶ $entry->{$_} = $result->$_ unless $IGNORE{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $IGNORE{$_} 141 1 142
367 }
368  
369 # save Dangling kv_data to plan entry. The situation
370 # that we already collected kv_data but haven't got
371 # a plan yet should only happen in documents with
372 # lazy plans (plan at the end).
373 71 ▶ if ($PUT_DANGLING_KV_DATA_UNDER_LAZY_PLAN and keys %dangling_kv_data) {
Branch: 1 branch
BranchTrueFalseTotal
if ($PUT_DANGLING_KV_DATA_UNDER_LAZY_PLAN and keys %dangling_kv_data) 0 71 71
Condition33%1/3
$PUT_DANGLING_KV_DATA_UNDER_LAZY_PLAN and keys %dangling_kv_data
!ll&&!rl&&r
7100
MC/DC0%0/2
$PUT_DANGLING_KV_DATA_UNDER_LAZY_PLAN and keys %dangling_kv_data
$PUT_DANGLING_KV_DATA_UNDER_LAZY_PLAN keys %dangling_kv_data
Truth table33%1/3
A and B
A= $PUT_DANGLING_KV_DATA_UNDER_LAZY_PLANB= keys %dangling_kv_data
ABresult
0X0
100
111
374 0 $entry->{kv_data}{$_} = $dangling_kv_data{$_} foreach keys %dangling_kv_data;
375 }
376 }
377  
378 # meta info
379 842 foreach ((qw(has_skip has_todo))) {
380 1684 ▶ if ($USEBITSETS) {
Branch: 2 branches
BranchTrueFalseTotal
if ($USEBITSETS) { } 14 1670 1684
elsif ($SPARSE) { } 14 1656 1670
381 14 ▶ $entry->{is_has} |= $result->$_ ? ${uc $_} : 0 unless $IGNORE{$_};
Branch: 2 branches
BranchTrueFalseTotal
unless $IGNORE{$_} 14 0 14
$result->$_ ? : 2 12 14
382 } elsif ($SPARSE) {
383 # don't set 'false' fields at all in sparse mode
384 14 ▶ $entry->{$_} = 1 if $result->$_ and not $IGNORE{$_};
Branch: 1 branch
BranchTrueFalseTotal
if $result->$_ and not $IGNORE{$_} 2 12 14
Condition66%2/3
$result->$_ and not $IGNORE{$_}
!ll&&!rl&&r
1202
MC/DC50%1/2
$result->$_ and not $IGNORE{$_}
$result->$_ not $IGNORE{$_}
Truth table66%2/3
A and not(B)
A= $result->$_B= not $IGNORE{$_}
ABresult
0X0
100
111
385 } else {
386 1656 ▶ $entry->{$_} = $result->$_ ? 1 : 0 unless $IGNORE{$_};
Branch: 2 branches
BranchTrueFalseTotal
unless $IGNORE{$_} 1656 0 1656
$result->$_ ? : 89 1567 1656
387 }
388 }
389 # Idea:
390 # use constants
391 # map to constants
392 # then loop
393 842 foreach (qw( is_pragma is_comment is_bailout is_plan
394 is_version is_yaml is_unknown is_test))
395 {
396 6736 ▶ if ($USEBITSETS) {
Branch: 2 branches
BranchTrueFalseTotal
if ($USEBITSETS) { } 56 6680 6736
elsif ($SPARSE) { } 56 6624 6680
397 56 ▶ $entry->{is_has} |= $result->$_ ? ${uc $_} : 0 unless $IGNORE{$_};
Branch: 2 branches
BranchTrueFalseTotal
unless $IGNORE{$_} 56 0 56
$result->$_ ? : 7 49 56
398 } elsif ($SPARSE) {
399 # don't set 'false' fields at all in sparse mode
400 56 ▶ $entry->{$_} = 1 if $result->$_ and not $IGNORE{$_};
Branch: 1 branch
BranchTrueFalseTotal
if $result->$_ and not $IGNORE{$_} 7 49 56
Condition66%2/3
$result->$_ and not $IGNORE{$_}
!ll&&!rl&&r
4907
MC/DC50%1/2
$result->$_ and not $IGNORE{$_}
$result->$_ not $IGNORE{$_}
Truth table66%2/3
A and not(B)
A= $result->$_B= not $IGNORE{$_}
ABresult
0X0
100
111
401 } else {
402 6624 ▶ $entry->{$_} = $result->$_ ? 1 : 0 unless $IGNORE{$_};
Branch: 2 branches
BranchTrueFalseTotal
unless $IGNORE{$_} 6624 0 6624
$result->$_ ? : 828 5796 6624
403 }
404 }
405 842 ▶ if (! $IGNORE{is_actual_ok}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($IGNORE{"is_actual_ok"}) 842 0 842
406 # XXX:
407 # I think it's confusing when the value of
408 # "is_actual_ok" only has a meaning when
409 # "has_todo" is true.
410 # This makes it difficult to evaluate later.
411 # But it's aligned with TAP::Parser
412 # which also sets this only on "has_todo".
413 #
414 # Maybe the problem is a general philosophical one
415 # in TAP::DOM to always have each hashkey existing.
416 # Hmmm...
417 842 ▶ my $is_actual_ok = ($result->has_todo && $result->is_actual_ok) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$result->has_todo && $result->is_actual_ok ? : 22 820 842
Condition100%3/3
$result->has_todo and $result->is_actual_ok
!ll&&!rl&&r
7813922
MC/DC100%2/2
$result->has_todo and $result->is_actual_ok
$result->has_todo $result->is_actual_ok
Truth table100%3/3
A and B
A= $result->has_todoB= $result->is_actual_ok
ABresult
0X0
100
111
418 842 ▶ if ($USEBITSETS) {
Branch: 2 branches
BranchTrueFalseTotal
if ($USEBITSETS) { } 7 835 842
elsif ($SPARSE) { } 7 828 835
419 7 ▶ $entry->{is_has} |= $is_actual_ok ? $IS_ACTUAL_OK : 0;
Branch: 1 branch
BranchTrueFalseTotal
$is_actual_ok ? : 1 6 7
420 } elsif ($SPARSE) {
421 # don't set 'false' fields at all in sparse mode
422 7 ▶ $entry->{is_actual_ok} = 1 if $is_actual_ok;
Branch: 1 branch
BranchTrueFalseTotal
if $is_actual_ok 1 6 7
423 } else {
424 828 $entry->{is_actual_ok} = $is_actual_ok;
425 }
426 }
427 842 ▶ $entry->{data} = $result->data if $result->is_yaml && !$IGNORE{data};
Branch: 1 branch
BranchTrueFalseTotal
if $result->is_yaml and not $IGNORE{"data"} 33 809 842
Condition66%2/3
$result->is_yaml and not $IGNORE{"data"}
!ll&&!rl&&r
809033
MC/DC50%1/2
$result->is_yaml and not $IGNORE{"data"}
$result->is_yaml not $IGNORE{"data"}
Truth table66%2/3
A and not(B)
A= $result->is_yamlB= not $IGNORE{"data"}
ABresult
0X0
100
111
428  
429 842 ▶ if ($result->is_comment and $result->as_string =~ $document_data_regex)
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_comment and $result->as_string =~ /$document_data_regex/) 73 769 842
Condition100%3/3
$result->is_comment and $result->as_string =~ /$document_data_regex/
!ll&&!rl&&r
46330673
MC/DC100%2/2
$result->is_comment and $result->as_string =~ /$document_data_regex/
$result->is_comment $result->as_string =~ /$document_data_regex/
Truth table100%3/3
A and B
A= $result->is_commentB= $result->as_string =~ /$document_data_regex/
ABresult
0X0
100
111
430 {{ # extra block for 'last'
431 # we can't use $1, $2 because the regex could contain configured other groups
432 73 my ($key, $value) = (_capture_group($result->as_string, -2), _capture_group($result->as_string, -1));
433 73 $key =~ s/^\s+//; # strip leading whitespace
434 73 $key =~ s/\s+$//; # strip trailing whitespace
435  
436 # optional lowercase
437 73 ▶ $key = lc $key if $LOWERCASE_FIELDNAMES;
Branch: 1 branch
BranchTrueFalseTotal
if $LOWERCASE_FIELDNAMES 21 52 73
438 73 ▶ $value = lc $value if $LOWERCASE_FIELDVALUES;
Branch: 1 branch
BranchTrueFalseTotal
if $LOWERCASE_FIELDVALUES 28 45 73
439  
440 # optional value trimming
441 73 ▶ $value =~ s/\s+$// if $TRIM_FIELDVALUES; # there can be no leading whitespace
Branch: 1 branch
BranchTrueFalseTotal
if $TRIM_FIELDVALUES 2 71 73
442  
443 # skip this field according to regex
444 73 ▶ last if $DOC_DATA_IGNORE and $document_data_ignore and $key =~ $document_data_ignore;
Branch: 1 branch
BranchTrueFalseTotal
if $DOC_DATA_IGNORE and $document_data_ignore and $key =~ /$document_data_ignore/ 7 66 73
Condition83%5/6
$DOC_DATA_IGNORE and $document_data_ignore and $key =~ /$document_data_ignore/
!ll&&!rl&&r
52147
$DOC_DATA_IGNORE and $document_data_ignore
!ll&&!rl&&r
52021
MC/DC66%2/3
$DOC_DATA_IGNORE and $document_data_ignore and $key =~ /$document_data_ignore/
$DOC_DATA_IGNORE $document_data_ignore $key =~ /$document_data_ignore/
Truth table75%3/4
A and B and C
A= $DOC_DATA_IGNOREB= $document_data_ignoreC= $key =~ /$document_data_ignore/
ABCresult
0XX0
10X0
1100
1111
445  
446 # Store "# Test-key: value" entries also as
447 # 'kv_data' under their parent line.
448 # That line should be a test or a plan line, so that its
449 # place (or "data path") is structurally always the same.
450 66 ▶ if ($lines[-1]->is_test or $lines[-1]->is_plan or $lines[-1]->is_pragma) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lines[-1]->is_test or $lines[-1]->is_plan or $lines[-1]->is_pragma) { } 56 10 66
Condition100%6/6
$lines[-1]->is_test or $lines[-1]->is_plan or $lines[-1]->is_pragma
l!l&&r!l&&!r
54210
$lines[-1]->is_test or $lines[-1]->is_plan
l!l&&r!l&&!r
45912
MC/DC100%3/3
$lines[-1]->is_test or $lines[-1]->is_plan or $lines[-1]->is_pragma
$lines[-1]->is_test $lines[-1]->is_plan $lines[-1]->is_pragma
Truth table100%4/4
A or B or C
A= $lines[-1]->is_testB= $lines[-1]->is_planC= $lines[-1]->is_pragma
ABCresult
1XX1
01X1
0011
0000
451 56 $lines[-1]->{kv_data}{$key} = $value;
452 } else {
453 10 ▶ if (!$plan) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($plan) 10 0 10
454 # We haven't got a plan yet, so that
455 # kv_data entry would get lost. As we
456 # might still get a lazy plan at end
457 # of document, so we save it up for
458 # that potential plan entry.
459 10 $dangling_kv_data{$key} = $value;
460 }
461 }
462 66 ▶ $document_data{$key} = $value unless $lines[-1]->is_test && $DISABLE_GLOBAL_KV_DATA;
Branch: 1 branch
BranchTrueFalseTotal
unless $lines[-1]->is_test and $DISABLE_GLOBAL_KV_DATA 66 0 66
Condition66%2/3
$lines[-1]->is_test and $DISABLE_GLOBAL_KV_DATA
!ll&&!rl&&r
21450
MC/DC0%0/2
$lines[-1]->is_test and $DISABLE_GLOBAL_KV_DATA
$lines[-1]->is_test $DISABLE_GLOBAL_KV_DATA
Truth table66%2/3
A and B
A= $lines[-1]->is_testB= $DISABLE_GLOBAL_KV_DATA
ABresult
0X0
100
111
463 }}
464  
465 # calculate severity
466 842 ▶ if ($entry->{is_test} or $entry->{is_plan}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->{"is_test"} or $entry->{"is_plan"}) 347 495 842
Condition100%3/3
$entry->{"is_test"} or $entry->{"is_plan"}
l!l&&r!l&&!r
27770495
MC/DC100%2/2
$entry->{"is_test"} or $entry->{"is_plan"}
$entry->{"is_test"} $entry->{"is_plan"}
Truth table100%3/3
A or B
A= $entry->{"is_test"}B= $entry->{"is_plan"}
ABresult
1X1
011
000
467 25 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
468 347 $count_tap_lines++;
469 $entry->{severity} = $severity
470 ->{$entry->{type}}
471 ->{$entry->{is_ok}||0}
472 ->{$entry->{has_todo}||0}
473 ->{$entry->{is_actual_ok}||0}
474 347 ▶ ->{$entry->{has_skip}||0};
Condition100%8/8
$entry->{'is_ok'} || 0
l!l
25394
$entry->{'has_todo'} || 0
l!l
59288
$entry->{'is_actual_ok'} || 0
l!l
21326
$entry->{'has_skip'} || 0
l!l
32315
MC/DC100%1/1
$entry->{'is_ok'} || 0
$entry->{'is_ok'}
MC/DC100%1/1
$entry->{'has_todo'} || 0
$entry->{'has_todo'}
MC/DC100%1/1
$entry->{'is_actual_ok'} || 0
$entry->{'is_actual_ok'}
MC/DC100%1/1
$entry->{'has_skip'} || 0
$entry->{'has_skip'}
Truth table100%2/2
A
A= $entry->{'is_ok'}
Aresult
11
00
Truth table100%2/2
A
A= $entry->{'has_todo'}
Aresult
11
00
Truth table100%2/2
A
A= $entry->{'is_actual_ok'}
Aresult
11
00
Truth table100%2/2
A
A= $entry->{'has_skip'}
Aresult
11
00
475 }
476  
477 842 ▶ if ($entry->{is_pragma} or $entry->{is_unknown}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->{"is_pragma"} or $entry->{"is_unknown"}) 36 806 842
Condition100%3/3
$entry->{"is_pragma"} or $entry->{"is_unknown"}
l!l&&r!l&&!r
1026806
MC/DC100%2/2
$entry->{"is_pragma"} or $entry->{"is_unknown"}
$entry->{"is_pragma"} $entry->{"is_unknown"}
Truth table100%3/3
A or B
A= $entry->{"is_pragma"}B= $entry->{"is_unknown"}
ABresult
1X1
011
000
478 25 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
479 36 ▶ if ($entry->{raw} =~ /^pragma\s+\+tapdom_error\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->{'raw'} =~ /^pragma\s+\+tapdom_error\s*$/) { } 6 30 36
480 6 $found_pragma_tapdom_error=1;
481 6 $entry->{severity} = 5;
482 6 $entry->{is_pragma} = 1;
483 6 $entry->{type} = 'pragma';
484 6 delete $entry->{is_unknown};
485 } else {
486 30 $entry->{severity} = 0;
487 }
488 }
489 842 ▶ $entry->{severity} = 0 if not defined $entry->{severity};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $entry->{"severity"} 543 299 842
490  
491 # yaml and comments are taken as children of the line before
492 842 ▶ if ($result->is_yaml or $result->is_comment and @lines)
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_yaml or $result->is_comment and @lines) { } 411 431 842
Condition100%6/6
$result->is_yaml or $result->is_comment and @lines
l!l&&r!l&&!r
33378431
$result->is_comment and @lines
!ll&&!rl&&r
4301378
MC/DC100%3/3
$result->is_yaml or $result->is_comment and @lines
$result->is_yaml $result->is_comment @lines
Truth table100%4/4
A or B and C
A= $result->is_yamlB= $result->is_commentC= @lines
ABCresult
1XX1
0111
00X0
0100
493 {
494 411 push @{ $lines[-1]->{_children} }, $entry;
495 }
496 else
497 {
498 431 push @lines, $entry;
499 }
500 }
501 80 @pragmas = $parser->pragmas;
502  
503 80 ▶ if (!$count_tap_lines and !$found_pragma_tapdom_error and $NOEMPTY_TAP) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count_tap_lines || $found_pragma_tapdom_error and $NOEMPTY_TAP) 2 78 80
Condition100%6/6
not $count_tap_lines || $found_pragma_tapdom_error and $NOEMPTY_TAP
!ll&&!rl&&r
7532
$count_tap_lines || $found_pragma_tapdom_error
l!l&&r!l&&!r
7055
MC/DC100%3/3
not $count_tap_lines || $found_pragma_tapdom_error and $NOEMPTY_TAP
$count_tap_lines $found_pragma_tapdom_error $NOEMPTY_TAP
Truth table100%4/4
not(A || B) and C
A= $count_tap_linesB= $found_pragma_tapdom_errorC= $NOEMPTY_TAP
ABCresult
1XX0
01X0
0000
0011
504 # pragma +tapdom_error
505 2 ▶ my $error_entry = TAP::DOM::Entry->new(
Branch: 1 branch
BranchTrueFalseTotal
$SPARSE ? : 0 2 2
506 ($SPARSE ? () : (
507 'is_version' => 0,
508 'is_plan' => 0,
509 'is_test' => 0,
510 'is_comment' => 0,
511 'is_yaml' => 0,
512 'is_unknown' => 0,
513 'is_bailout' => 0,
514 'is_actual_ok' => 0,
515 'has_todo' => 0,
516 'has_skip' => 0,
517 )),
518 'is_pragma' => 1,
519 'type' => 'pragma',
520 'raw' => 'pragma +tapdom_error',
521 'as_string' => 'pragma +tapdom_error',
522 'severity' => 5,
523 );
524 2 ▶ $error_entry->{is_has} = $IS_PRAGMA if $USEBITSETS;
Branch: 1 branch
BranchTrueFalseTotal
if $USEBITSETS 0 2 2
525 2 ▶ foreach (qw(raw type as_string explanation)) { delete $error_entry->{$_} if $IGNORE{$_} }
Branch: 1 branch
BranchTrueFalseTotal
if $IGNORE{$_} 0 8 8
526 # pragma +tapdom_error
527 2 ▶ my $error_comment = TAP::DOM::Entry->new(
Branch: 1 branch
BranchTrueFalseTotal
$SPARSE ? : 0 2 2
528 ($SPARSE ? () : (
529 'is_version' => 0,
530 'is_plan' => 0,
531 'is_test' => 0,
532 'is_yaml' => 0,
533 'is_unknown' => 0,
534 'is_bailout' => 0,
535 'is_actual_ok' => 0,
536 'is_pragma' => 0,
537 'has_todo' => 0,
538 'has_skip' => 0,
539 )),
540 'is_comment' => 1,
541 'type' => 'comment',
542 'raw' => '# no tap lines',
543 'as_string' => '# no tap lines',
544 'severity' => 0,
545 );
546 2 ▶ $error_comment->{is_has} = $IS_COMMENT if $USEBITSETS;
Branch: 1 branch
BranchTrueFalseTotal
if $USEBITSETS 0 2 2
547 2 ▶ foreach (qw(raw type as_string explanation)) { delete $error_comment->{$_} if $IGNORE{$_} }
Branch: 1 branch
BranchTrueFalseTotal
if $IGNORE{$_} 0 8 8
548 2 ▶ $error_entry->{_children} //= [];
Condition50%1/2
$error_entry->{"_children"} //= []
l!l
02
MC/DC0%0/1
$error_entry->{"_children"} //= []
$error_entry->{"_children"}
Truth table50%1/2
A
A= $error_entry->{"_children"}
Aresult
11
00
549 2 push @{$error_entry->{_children}}, $error_comment;
550 2 push @lines, $error_entry;
551 2 push @pragmas, 'tapdom_error';
552 }
553  
554 80 $aggregate->add( main => $parser );
555 80 $aggregate->stop;
556  
557 80 ▶ my $summary = TAP::DOM::Summary->new
Branch: 3 branches
BranchTrueFalseTotal
$aggregate->all_passed ? : 57 23 80
$aggregate->has_problems ? : 25 55 80
$aggregate->has_errors ? : 21 59 80
558 (
559 failed => scalar $aggregate->failed,
560 parse_errors => scalar $aggregate->parse_errors,
561 planned => scalar $aggregate->planned,
562 passed => scalar $aggregate->passed,
563 skipped => scalar $aggregate->skipped,
564 todo => scalar $aggregate->todo,
565 todo_passed => scalar $aggregate->todo_passed,
566 wait => scalar $aggregate->wait,
567 exit => scalar $aggregate->exit,
568 elapsed => $aggregate->elapsed,
569 elapsed_timestr => $aggregate->elapsed_timestr,
570 all_passed => $aggregate->all_passed ? 1 : 0,
571 status => $aggregate->get_status,
572 total => $aggregate->total,
573 has_problems => $aggregate->has_problems ? 1 : 0,
574 has_errors => $aggregate->has_errors ? 1 : 0,
575 );
576  
577 80 my $tapdom_config = TAP::DOM::Config->new
578 (
579 ignore => \%IGNORE,
580 ignorelines => $IGNORELINES,
581 dontignorelines => $DONTIGNORELINES,
582 usebitsets => $USEBITSETS,
583 sparse => $SPARSE,
584 disable_global_kv_data => $DISABLE_GLOBAL_KV_DATA,
585 put_dangling_kv_data_under_lazy_plan => $PUT_DANGLING_KV_DATA_UNDER_LAZY_PLAN,
586 document_data_prefix => $DOC_DATA_PREFIX,
587 document_data_ignore => $DOC_DATA_IGNORE,
588 lowercase_fieldnames => $LOWERCASE_FIELDNAMES,
589 lowercase_fieldvalues => $LOWERCASE_FIELDVALUES,
590 trim_fieldvalues => $TRIM_FIELDVALUES,
591 noempty_tap => $NOEMPTY_TAP,
592 );
593  
594 80 my $document_data = TAP::DOM::DocumentData->new(%document_data);
595  
596 80 my $tapdata = {
597 plan => $plan,
598 lines => \@lines,
599 pragmas => \@pragmas,
600 tests_planned => $parser->tests_planned,
601 tests_run => $parser->tests_run,
602 version => $parser->version,
603 is_good_plan => $parser->is_good_plan,
604 skip_all => $parser->skip_all,
605 start_time => $parser->start_time,
606 end_time => $parser->end_time,
607 has_problems => $parser->has_problems,
608 exit => $parser->exit,
609 parse_errors => scalar $parser->parse_errors,
610 parse_errors_msgs => [ $parser->parse_errors ],
611 summary => $summary,
612 tapdom_config => $tapdom_config,
613 document_data => $document_data,
614 };
615 80 return bless $tapdata, $class;
616 }
617  
618 sub _entry_to_tapline
619 100 ▶{
Subroutine _entry_to_tapline: called CC=17 SCAR=29.2
620 100 my ($self, $entry, $use_field) = @_;
621  
622 100 ▶ return $entry->{$use_field} if $use_field;
Branch: 1 branch
BranchTrueFalseTotal
if $use_field 60 40 100
623  
624 40 my %IGNORE = %{$self->{tapdom_config}{ignore}};
625  
626 40 my $tapline;
627  
628 # ok/notok test lines
629 40 ▶ if ($entry->{is_test})
Branch: 2 branches
BranchTrueFalseTotal
if ($entry->{'is_test'}) { } 16 24 40
elsif ($entry->{'is_pragma'} or $entry->{'is_comment'} or $entry->{'is_bailout'} or $entry->{'is_yaml'}) { } 20 4 24
630 {
631 $tapline = join(" ",
632 # the original "NOT" is more difficult to reconstruct than it should...
633 ($entry->{has_todo}
634 ? $entry->{is_actual_ok} ? () : "not"
635 : $entry->{is_ok} ? () : "not"),
636 "ok",
637 ($entry->{number} || ()),
638 ($entry->{description} || ()),
639 ($entry->{has_skip} ? "# SKIP ".($entry->{explanation} || "")
640 16 ▶ : $entry->{has_todo }? "# TODO ".($entry->{explanation} || "")
Branch: 5 branches
BranchTrueFalseTotal
$entry->{'has_todo'} ? : 8 8 16
$entry->{'is_actual_ok'} ? : 4 4 8
$entry->{'is_ok'} ? : 8 0 8
$entry->{'has_skip'} ? : 2 14 16
$entry->{'has_todo'} ? : 8 6 14
Condition50%5/10
$entry->{'number'} || ()
l!l&&r!l&&!r
1600
$entry->{'description'} || ()
l!l&&r!l&&!r
1060
$entry->{'explanation'} || ''
l!l
20
$entry->{'explanation'} || ''
l!l
80
MC/DC0%0/2
$entry->{'number'} || ()
$entry->{'number'} ()
MC/DC0%0/2
$entry->{'description'} || ()
$entry->{'description'} ()
MC/DC0%0/1
$entry->{'explanation'} || ''
$entry->{'explanation'}
MC/DC0%0/1
$entry->{'explanation'} || ''
$entry->{'explanation'}
Truth table33%1/3
A || B
A= $entry->{'number'}B= ()
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= $entry->{'description'}B= ()
ABresult
1X1
011
000
Truth table50%1/2
A
A= $entry->{'explanation'}
Aresult
11
00
Truth table50%1/2
A
A= $entry->{'explanation'}
Aresult
11
00
641 : ()),
642 );
643 }
644 # pragmas and meta lines, but no version nor plan
645 ▶ elsif ($entry->{is_pragma} ||
Condition88%8/9
$entry->{"is_pragma"} or $entry->{"is_comment"} or $entry->{"is_bailout"} or $entry->{"is_yaml"}
l!l&&r!l&&!r
1824
$entry->{"is_pragma"} or $entry->{"is_comment"} or $entry->{"is_bailout"}
l!l&&r!l&&!r
1806
$entry->{"is_pragma"} or $entry->{"is_comment"}
l!l&&r!l&&!r
2166
MC/DC75%3/4
$entry->{"is_pragma"} or $entry->{"is_comment"} or $entry->{"is_bailout"} or $entry->{"is_yaml"}
$entry->{"is_pragma"} $entry->{"is_comment"} $entry->{"is_bailout"} $entry->{"is_yaml"}
Truth table80%4/5
A or B or C or D
A= $entry->{"is_pragma"}B= $entry->{"is_comment"}C= $entry->{"is_bailout"}D= $entry->{"is_yaml"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
646 $entry->{is_comment} ||
647 $entry->{is_bailout} ||
648 $entry->{is_yaml})
649 {
650 20 ▶ $tapline = $IGNORE{raw} ? $entry->{as_string} : $entry->{raw}; # if "raw" was 'ignored' try "as_string"
Branch: 1 branch
BranchTrueFalseTotal
$IGNORE{'raw'} ? : 0 20 20
651 }
652 40 return $tapline;
653 }
654  
655 sub _lines_to_tap
656 20 ▶{
Subroutine _lines_to_tap: called CC=4 SCAR=13.9
657 20 my ($self, $lines, $use_field) = @_;
658  
659 20 my @taplines;
660 20 foreach my $entry (@$lines)
661 {
662 100 my $tapline = $self->_entry_to_tapline($entry, $use_field);
663 100 ▶ push @taplines, $tapline if defined $tapline;
Branch: 1 branch
BranchTrueFalseTotal
if defined $tapline 96 4 100
664 100 ▶ push @taplines, $self->_lines_to_tap($entry->{_children}, $use_field) if $entry->{_children};
Branch: 1 branch
BranchTrueFalseTotal
if $entry->{"_children"} 15 85 100
665 }
666 20 return @taplines;
667 }
668  
669 sub to_tap
670 5 ▶{
Subroutine to_tap: called CC=3 SCAR=11.0
Pod documented
671 5 my ($self, $use_field) = @_;
672  
673 5 my @taplines = $self->_lines_to_tap($self->{lines}, $use_field);
674 5 ▶ unless ($use_field) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($use_field) 2 3 5
675 2 unshift @taplines, $self->{plan};
676 2 unshift @taplines, "TAP version ".$self->{version};
677 }
678  
679 return wantarray
680 ? @taplines
681 5 ▶ : join("\n", @taplines)."\n";
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 4 5
682 }
683  
684 25 1; # End of TAP::DOM
685  
686 __END__
↑ Summary DOM/Archive.pm »