blib/lib/XML/Filter/DetectWS.pm

filter: Statementstmt 5.6% 11 / 194 Branchbran 0.0% 0 / 78 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 7.1% 3 / 42 Podpod 8.1% 3 / 37 totaltotal 4.5% 17 / 371 CC 45 SCAR 48.0
CC
45
Cov
4%
characters
462.0
init_handlers
56.0
merge_text
20.0
CRAP 121.6
↑ Summary
1 package XML::Filter::DetectWS;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use XML::Filter::SAXT;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 $VERSION = '0.01';
7  
8 #----------------------------------------------------------------------
9 # CONSTANT DEFINITIONS
10 #----------------------------------------------------------------------
11  
12 # Locations of whitespace
13 0 ▶sub WS_START (%) { 1 } # just after <a>
Subroutine WS_START: not called CC=1 SCAR=6.9
Pod documented
14 0 ▶sub WS_END (%) { 2 } # just before </a>
Subroutine WS_END: not called CC=1 SCAR=6.9
Pod documented
15 0 ▶sub WS_INTER (%) { 0 } # not at the start or end (i.e. intermediate)
Subroutine WS_INTER: not called CC=1 SCAR=6.9
Pod undocumented
16 0 ▶sub WS_ONLY (%) { 3 } # both START and END, i.e. between <a> and </a>
Subroutine WS_ONLY: not called CC=1 SCAR=6.9
Pod undocumented
17  
18 # The states of the WhiteSpace detection code
19 # for regular elements, i.e. elements that:
20 # 1) don't have xml:space="preserve"
21 # 2) have an ELEMENT model that allows text children (i.e. ANY or Mixed content)
22  
23 0 ▶sub START (%) { 0 } # just saw <elem>
Subroutine START: not called CC=1 SCAR=6.9
Pod undocumented
24 0 ▶sub ONLY_WS (%) { 1 } # saw <elem> followed by whitespace (only)
Subroutine ONLY_WS: not called CC=1 SCAR=6.9
Pod undocumented
25 0 ▶sub ENDS_IN_WS (%) { 2 } # ends in whitespace (sofar)
Subroutine ENDS_IN_WS: not called CC=1 SCAR=6.9
Pod undocumented
26 0 ▶sub ENDS_IN_NON_WS (%) { 3 } # ends in non-ws text or non-text node (sofar)
Subroutine ENDS_IN_NON_WS: not called CC=1 SCAR=6.9
Pod undocumented
27  
28 # NO_TEXT States: when <!ELEMENT> model does not allow text
29 # (we assume that all text children are whitespace)
30 0 ▶sub NO_TEXT_START (%) { 4 } # just saw <elem>
Subroutine NO_TEXT_START: not called CC=1 SCAR=6.9
Pod undocumented
31 0 ▶sub NO_TEXT_ONLY_WS (%) { 5 } # saw <elem> followed by whitespace (only)
Subroutine NO_TEXT_ONLY_WS: not called CC=1 SCAR=6.9
Pod undocumented
32 0 ▶sub NO_TEXT_ENDS_IN_WS (%) { 6 } # ends in whitespace (sofar)
Subroutine NO_TEXT_ENDS_IN_WS: not called CC=1 SCAR=6.9
Pod undocumented
33 0 ▶sub NO_TEXT_ENDS_IN_NON_WS (%) { 7 } # ends in non-text node (sofar)
Subroutine NO_TEXT_ENDS_IN_NON_WS: not called CC=1 SCAR=6.9
Pod undocumented
34  
35 # State for elements with xml:space="preserve" (all text is non-WS)
36 0 ▶sub PRESERVE_WS (%) { 8 }
Subroutine PRESERVE_WS: not called CC=1 SCAR=6.9
Pod undocumented
37  
38 #----------------------------------------------------------------------
39 # METHOD DEFINITIONS
40 #----------------------------------------------------------------------
41  
42 # Constructor options:
43 #
44 # SkipIgnorableWS 1 means: don't forward ignorable_whitespace events
45 # Handler SAX Handler that will receive the resulting events
46 #
47  
48 sub new
49 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
50 0 my ($class, %options) = @_;
51  
52 0 my $self = bless \%options, $class;
53  
54 0 $self->init_handlers;
55  
56 0 $self;
57 }
58  
59 # Does nothing
60 0 ▶sub noop {}
Subroutine noop: not called CC=1 SCAR=0.0
Pod undocumented
61  
62 sub init_handlers
63 0 ▶{
Subroutine init_handlers: not called CC=7 SCAR=40.3
Pod undocumented
64 0 my ($self) = @_;
65 0 my %handlers;
66
67 0 my $handler = $self->{Handler};
68
69 0 for my $cb (map { @{$_} } values %XML::Filter::SAXT::SAX_HANDLERS)
70 {
71 0 ▶ if (UNIVERSAL::can ($handler, $cb))
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::can($handler, $cb)) { } 0 0 0
72 {
73 0 $handlers{$cb} = eval "sub { \$handler->$cb (\@_) }";
74 }
75 else
76 {
77 0 $handlers{$cb} = \&noop;
78 }
79 }
80  
81 0 ▶ if ($self->{SkipIgnorableWS})
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'SkipIgnorableWS'}) { } 0 0 0
elsif (UNIVERSAL::can($handler, 'ignorable_whitespace')) { } 0 0 0
82 {
83 0 delete $handlers{ignorable_whitespace}; # if it exists
84 }
85 elsif (UNIVERSAL::can ($handler, 'ignorable_whitespace'))
86 {
87 # Support ignorable_whitespace callback if it exists
88 # (if not, just use characters callback)
89 $handlers{ignorable_whitespace} =
90 0 ▶ sub { $handler->ignorable_whitespace (@_) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
91 }
92 else
93 {
94 0 $handlers{ignorable_whitespace} = $handlers{characters};
95 }
96  
97 0 $handlers{ws} = $handlers{characters};
98 #?? were should whitespace go?
99  
100 # NOTE: 'cdata' is not a valid PerlSAX callback
101 0 ▶ if (UNIVERSAL::can ($handler, 'start_cdata') &&
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::can($handler, 'start_cdata') and UNIVERSAL::can($handler, 'end_cdata')) { } 0 0 0
Condition0%0/3
UNIVERSAL::can($handler, "start_cdata") and UNIVERSAL::can($handler, "end_cdata")
!ll&&!rl&&r
000
MC/DC0%0/2
UNIVERSAL::can($handler, "start_cdata") and UNIVERSAL::can($handler, "end_cdata")
UNIVERSAL::can($handler, "start_cdata") UNIVERSAL::can($handler, "end_cdata")
Truth table0%0/3
A and B
A= UNIVERSAL::can($handler, "start_cdata")B= UNIVERSAL::can($handler, "end_cdata")
ABresult
0X0
100
111
102 UNIVERSAL::can ($handler, 'end_cdata'))
103 {
104 0 ▶ $handlers{cdata} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
105 0 $handler->start_cdata;
106 0 $handler->characters (@_);
107 0 $handler->end_cdata;
108 }
109 0 }
110 else # pass CDATA as regular characters
111 {
112 0 $handlers{cdata} = $handlers{characters};
113 }
114  
115 0 $self->{Callback} = \%handlers;
116 }
117  
118 sub start_cdata
119 0 ▶{
Subroutine start_cdata: not called CC=1 SCAR=6.9
Pod undocumented
120 0 my ($self, $event) = @_;
121  
122 0 $self->{InCDATA} = 1;
123 }
124  
125 sub end_cdata
126 0 ▶{
Subroutine end_cdata: not called CC=1 SCAR=6.9
Pod undocumented
127 0 my ($self, $event) = @_;
128  
129 0 $self->{InCDATA} = 0;
130 }
131  
132 sub entity_reference
133 0 ▶{
Subroutine entity_reference: not called CC=2 SCAR=17.9
Pod undocumented
134 0 my ($self, $event) = @_;
135
136 0 $self->push_event ('entity_reference', $event);
137  
138 0 my $parent = $self->{ParentStack}->[-1];
139 0 ▶ $parent->{State} |= ENDS_IN_NON_WS unless $parent->{State} == PRESERVE_WS;
Branch: 1 branch
BranchTrueFalseTotal
unless $parent->{"State"} == &PRESERVE_WS() 0 0 0
140 }
141  
142 sub comment
143 0 ▶{
Subroutine comment: not called CC=2 SCAR=17.9
Pod documented
144 0 my ($self, $event) = @_;
145
146 0 $self->push_event ('comment', $event);
147  
148 0 my $parent = $self->{ParentStack}->[-1];
149 0 ▶ $parent->{State} |= ENDS_IN_NON_WS unless $parent->{State} == PRESERVE_WS;
Branch: 1 branch
BranchTrueFalseTotal
unless $parent->{"State"} == &PRESERVE_WS() 0 0 0
150 }
151  
152 sub processing_instruction
153 0 ▶{
Subroutine processing_instruction: not called CC=2 SCAR=17.9
Pod undocumented
154 0 my ($self, $event) = @_;
155
156 0 $self->push_event ('processing_instruction', $event);
157  
158 0 my $parent = $self->{ParentStack}->[-1];
159 0 ▶ $parent->{State} |= ENDS_IN_NON_WS unless $parent->{State} == PRESERVE_WS;
Branch: 1 branch
BranchTrueFalseTotal
unless $parent->{"State"} == &PRESERVE_WS() 0 0 0
160 }
161  
162 sub start_document
163 0 ▶{
Subroutine start_document: not called CC=3 SCAR=24.8
Pod undocumented
164 0 my ($self, $event) = @_;
165  
166 # Initialize initial state
167 0 $self->{ParentStack} = [];
168 0 $self->{EventQ} = [];
169 0 $self->{InCDATA} = 0;
170  
171 0 $self->init_handlers;
172  
173 0 ▶ $event = {} unless defined $event;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $event 0 0 0
174 # Don't preserve WS by default (unless specified by the user)
175 $event->{PreserveWS} = defined ($self->{PreserveWS}) ?
176 0 ▶ $self->{PreserveWS} : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'PreserveWS'} ? : 0 0 0
177  
178 # We don't need whitespace detection at the document level
179 0 $event->{State} = PRESERVE_WS;
180  
181 0 $self->push_event ('start_document', $event);
182 0 push @{ $self->{ParentStack} }, $event;
183 }
184  
185 sub end_document
186 0 ▶{
Subroutine end_document: not called CC=2 SCAR=17.9
Pod undocumented
187 0 my ($self, $event) = @_;
188 0 ▶ $event = {} unless defined $event;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $event 0 0 0
189  
190 0 $self->push_event ('end_document', $event);
191  
192 0 $self->flush;
193 }
194  
195 sub start_element
196 0 ▶{
Subroutine start_element: not called CC=3 SCAR=24.8
Pod undocumented
197 0 my ($self, $event) = @_;
198  
199 0 my $pres = $event->{Attributes}->{'xml:space'};
200 0 ▶ if (defined $pres)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pres) { } 0 0 0
201 {
202 0 $event->{PreserveWS} = $pres eq "preserve";
203 }
204 else
205 {
206 0 $event->{PreserveWS} = $self->{ParentStack}->[-1]->{PreserveWS};
207 }
208  
209 0 ▶ if ($self->{NoText}->{ $event->{Name} })
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"NoText"}{$event->{"Name"}}) 0 0 0
210 {
211 0 $event->{NoText} = 1;
212 }
213  
214 0 $event->{State} = $self->get_init_state ($event);
215  
216 0 $self->push_event ('start_element', $event);
217 0 push @{ $self->{ParentStack} }, $event;
218 }
219  
220 sub end_element
221 0 ▶{
Subroutine end_element: not called CC=2 SCAR=17.9
Pod undocumented
222 0 my ($self, $event) = @_;
223  
224 # Mark previous whitespace event as the last event (WS_END)
225 # (if it's there)
226 0 my $prev = $self->{EventQ}->[-1];
227 0 ▶ $prev->{Loc} |= WS_END if exists $prev->{Loc};
Branch: 1 branch
BranchTrueFalseTotal
if exists $prev->{"Loc"} 0 0 0
228  
229 0 $self->push_event ('end_element', $event);
230
231 0 my $elem = pop @{ $self->{ParentStack} };
232 0 delete $elem->{State};
233 }
234  
235 sub characters
236 0 ▶{
Subroutine characters: not called CC=21 SCAR=61.4
Pod undocumented
237 0 my ($self, $event) = @_;
238  
239 0 ▶ if ($self->{InCDATA})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"InCDATA"}) 0 0 0
240 {
241 # NOTE: 'cdata' is not a valid PerlSAX callback
242 0 $self->push_event ('cdata', $event);
243
244 0 my $parent = $self->{ParentStack}->[-1];
245 0 ▶ $parent->{State} |= ENDS_IN_NON_WS unless $parent->{State} == PRESERVE_WS;
Branch: 1 branch
BranchTrueFalseTotal
unless $parent->{"State"} == &PRESERVE_WS() 0 0 0
246 0 return;
247 }
248  
249 0 my $text = $event->{Data};
250 0 ▶ return unless length ($text);
Branch: 1 branch
BranchTrueFalseTotal
unless length $text 0 0 0
251  
252 0 my $state = $self->{ParentStack}->[-1]->{State};
253 0 ▶ if ($state == PRESERVE_WS)
Branch: 7 branches
BranchTrueFalseTotal
if ($state == &PRESERVE_WS()) { } 0 0 0
elsif ($state == &NO_TEXT_START()) { } 0 0 0
elsif ($state == &NO_TEXT_ONLY_WS()) { } 0 0 0
elsif ($state == &NO_TEXT_ENDS_IN_NON_WS()) { } 0 0 0
elsif ($state == &NO_TEXT_ENDS_IN_WS()) { } 0 0 0
elsif ($state == &START()) { } 0 0 0
elsif ($state == &ONLY_WS()) { } 0 0 0
254 {
255 0 $self->push_event ('characters', $event);
256 }
257 elsif ($state == NO_TEXT_START)
258 {
259 # ELEMENT model does not allow regular text.
260 # All characters are whitespace.
261 0 $self->push_event ('ignorable_whitespace', { Data => $text, Loc => WS_START });
262 0 $state = NO_TEXT_ONLY_WS;
263 }
264 elsif ($state == NO_TEXT_ONLY_WS)
265 {
266 0 $self->merge_text ($text, 'ignorable_whitespace', WS_START );
267 }
268 elsif ($state == NO_TEXT_ENDS_IN_NON_WS)
269 {
270 0 $self->push_event ('ignorable_whitespace', { Data => $text, Loc => WS_INTER });
271 0 $state = NO_TEXT_ENDS_IN_WS;
272 }
273 elsif ($state == NO_TEXT_ENDS_IN_WS)
274 {
275 0 $self->merge_text ($text, 'ignorable_whitespace', WS_INTER );
276 }
277 elsif ($state == START)
278 {
279 #?? add support for full Unicode
280 0 $text =~ /^(\s*)(\S(?:.*\S)?)?(\s*)$/;
281 0 ▶ if (length $1)
Branch: 1 branch
BranchTrueFalseTotal
if (length $1) 0 0 0
282 {
283 0 $self->push_event ('ws', { Data => $1, Loc => WS_START });
284 0 $state = ONLY_WS;
285 }
286 0 ▶ if (length $2)
Branch: 1 branch
BranchTrueFalseTotal
if (length $2) 0 0 0
287 {
288 0 $self->push_event ('characters', { Data => $2 });
289 0 $state = ENDS_IN_NON_WS;
290 }
291 0 ▶ if (length $3)
Branch: 1 branch
BranchTrueFalseTotal
if (length $3) 0 0 0
292 {
293 0 $self->push_event ('ws', { Data => $3, Loc => WS_INTER });
294 0 $state = ENDS_IN_WS;
295 }
296 }
297 elsif ($state == ONLY_WS)
298 {
299 0 $text =~ /^(\s*)(\S(?:.*\S)?)?(\s*)$/;
300 0 ▶ if (length $1)
Branch: 1 branch
BranchTrueFalseTotal
if (length $1) 0 0 0
301 {
302 0 $self->merge_text ($1, 'ws', WS_START);
303 }
304 0 ▶ if (length $2)
Branch: 1 branch
BranchTrueFalseTotal
if (length $2) 0 0 0
305 {
306 0 $self->push_event ('characters', { Data => $2 });
307 0 $state = ENDS_IN_NON_WS;
308 }
309 0 ▶ if (length $3)
Branch: 1 branch
BranchTrueFalseTotal
if (length $3) 0 0 0
310 {
311 0 $self->push_event ('ws', { Data => $3, Loc => WS_INTER });
312 0 $state = ENDS_IN_WS;
313 }
314 }
315 else # state == ENDS_IN_WS or ENDS_IN_NON_WS
316 {
317 0 $text =~ /^(.*\S)?(\s*)$/;
318 0 ▶ if (length $1)
Branch: 1 branch
BranchTrueFalseTotal
if (length $1) 0 0 0
319 {
320 0 ▶ if ($state == ENDS_IN_NON_WS)
Branch: 1 branch
BranchTrueFalseTotal
if ($state == &ENDS_IN_NON_WS()) { } 0 0 0
321 {
322 0 $self->merge_text ($1, 'characters');
323 }
324 else
325 {
326 0 $self->push_event ('characters', { Data => $1 });
327 0 $state = ENDS_IN_NON_WS;
328 }
329 }
330 0 ▶ if (length $2)
Branch: 1 branch
BranchTrueFalseTotal
if (length $2) 0 0 0
331 {
332 0 ▶ if ($state == ENDS_IN_WS)
Branch: 1 branch
BranchTrueFalseTotal
if ($state == &ENDS_IN_WS()) { } 0 0 0
333 {
334 0 $self->merge_text ($2, 'ws', WS_INTER);
335 }
336 else
337 {
338 0 $self->push_event ('ws', { Data => $2, Loc => WS_INTER });
339 0 $state = ENDS_IN_WS;
340 }
341 }
342 }
343  
344 0 $self->{ParentStack}->[-1]->{State} = $state;
345 }
346  
347 sub element_decl
348 0 ▶{
Subroutine element_decl: not called CC=2 SCAR=17.9
Pod undocumented
349 0 my ($self, $event) = @_;
350 0 my $tag = $event->{Name};
351 0 my $model = $event->{Model};
352  
353 # Check the model to see if the elements may contain regular text
354 0 ▶ $self->{NoText}->{$tag} = ($model eq 'EMPTY' || $model !~ /\#PCDATA/);
Condition0%0/3
$model eq 'EMPTY' || !($model =~ /\#PCDATA/)
l!l&&r!l&&!r
000
MC/DC0%0/2
$model eq 'EMPTY' || !($model =~ /\#PCDATA/)
$model eq 'EMPTY' !($model =~ /\#PCDATA/)
Truth table0%0/3
A || not(B)
A= $model eq 'EMPTY'B= !($model =~ /\#PCDATA/)
ABresult
1X1
011
000
355  
356 0 $self->push_event ('element_decl', $event);
357 }
358  
359 sub attlist_decl
360 0 ▶{
Subroutine attlist_decl: not called CC=3 SCAR=24.8
Pod undocumented
361 0 my ($self, $event) = @_;
362
363 0 my $prev = $self->{EventQ}->[-1];
364 0 ▶ if ($prev->{EventType} eq 'attlist_decl' &&
Branch: 1 branch
BranchTrueFalseTotal
if ($prev->{'EventType'} eq 'attlist_decl' and $prev->{'ElementName'} eq $event->{'ElementName'}) { } 0 0 0
Condition0%0/3
$prev->{"EventType"} eq "attlist_decl" and $prev->{"ElementName"} eq $event->{"ElementName"}
!ll&&!rl&&r
000
MC/DC0%0/2
$prev->{"EventType"} eq "attlist_decl" and $prev->{"ElementName"} eq $event->{"ElementName"}
$prev->{"EventType"} eq "attlist_decl" $prev->{"ElementName"} eq $event->{"ElementName"}
Truth table0%0/3
A and B
A= $prev->{"EventType"} eq "attlist_decl"B= $prev->{"ElementName"} eq $event->{"ElementName"}
ABresult
0X0
100
111
365 $prev->{ElementName} eq $event->{ElementName})
366 {
367 0 $prev->{MoreFollow} = 1;
368 0 $event->{First} = 0;
369 }
370 else
371 {
372 0 $event->{First} = 1;
373 }
374  
375 0 $self->push_event ('attlist_decl', $event);
376 }
377  
378 sub notation_decl
379 0 ▶{
Subroutine notation_decl: not called CC=1 SCAR=6.9
Pod undocumented
380 0 my ($self, $event) = @_;
381 0 $self->push_event ('notation_decl', $event);
382 }
383  
384 sub unparsed_entity_decl
385 0 ▶{
Subroutine unparsed_entity_decl: not called CC=1 SCAR=6.9
Pod undocumented
386 0 my ($self, $event) = @_;
387 0 $self->push_event ('unparsed_entity_decl', $event);
388 }
389  
390 sub entity_decl
391 0 ▶{
Subroutine entity_decl: not called CC=1 SCAR=6.9
Pod undocumented
392 0 my ($self, $event) = @_;
393 0 $self->push_event ('entity_decl', $event);
394 }
395  
396 sub doctype_decl
397 0 ▶{
Subroutine doctype_decl: not called CC=1 SCAR=6.9
Pod undocumented
398 0 my ($self, $event) = @_;
399 0 $self->push_event ('doctype_decl', $event);
400 }
401  
402 sub xml_decl
403 0 ▶{
Subroutine xml_decl: not called CC=1 SCAR=6.9
Pod undocumented
404 0 my ($self, $event) = @_;
405 0 $self->push_event ('xml_decl', $event);
406 }
407  
408 #?? what about set_document_locator, resolve_entity
409  
410 #
411 # Determine the initial State for the current Element.
412 # By default, we look at the PreserveWS property (i.e. value of xml:space.)
413 # The user can override this to force xml:space="preserve" for a particular
414 # element with e.g.
415 #
416 # sub get_init_state
417 # {
418 # my ($self, $event) = @_;
419 # ($event->{Name} eq 'foo' || $event->{PreserveWS}) ? PRESERVE_WS : START;
420 # }
421 #
422 sub get_init_state
423 0 ▶{
Subroutine get_init_state: not called CC=3 SCAR=24.8
Pod undocumented
424 0 my ($self, $event) = @_;
425 0 my $tag = $event->{Name};
426  
427 0 ▶ if ($self->{NoText}->{$tag}) # ELEMENT model does not allow text
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"NoText"}{$tag}) 0 0 0
428 {
429 0 return NO_TEXT_START;
430 }
431 0 ▶ $event->{PreserveWS} ? PRESERVE_WS : START;
Branch: 1 branch
BranchTrueFalseTotal
$event->{'PreserveWS'} ? : 0 0 0
432 }
433  
434 sub push_event
435 0 ▶{
Subroutine push_event: not called CC=1 SCAR=6.9
Pod undocumented
436 0 my ($self, $type, $event) = @_;
437  
438 0 $event->{EventType} = $type;
439  
440 0 $self->flush;
441 0 push @{ $self->{EventQ} }, $event;
442 }
443  
444 # Merge text with previous event (if it has the same EventType)
445 # or push a new text event
446 sub merge_text
447 0 ▶{
Subroutine merge_text: not called CC=4 SCAR=30.0
Pod undocumented
448 0 my ($self, $str, $eventType, $wsLocation) = @_;
449 0 my $q = $self->{EventQ};
450  
451 0 my $prev = $q->[-1];
452 0 ▶ if (defined $prev && $prev->{EventType} eq $eventType)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $prev and $prev->{'EventType'} eq $eventType) { } 0 0 0
Condition0%0/3
defined $prev and $prev->{"EventType"} eq $eventType
!ll&&!rl&&r
000
MC/DC0%0/2
defined $prev and $prev->{"EventType"} eq $eventType
defined $prev $prev->{"EventType"} eq $eventType
Truth table0%0/3
A and B
A= defined $prevB= $prev->{"EventType"} eq $eventType
ABresult
0X0
100
111
453 {
454 0 $prev->{Data} .= $str;
455 }
456 else
457 {
458 0 my $event = { Data => $str };
459 0 ▶ $event->{Loc} = $wsLocation if defined $wsLocation;
Branch: 1 branch
BranchTrueFalseTotal
if defined $wsLocation 0 0 0
460 0 $self->push_event ($eventType, $event);
461 }
462 }
463  
464 # Forward all events on the EventQ
465 sub flush
466 0 ▶{
Subroutine flush: not called CC=2 SCAR=17.9
Pod undocumented
467 0 my ($self) = @_;
468  
469 0 my $q = $self->{EventQ};
470 0 ▶ while (@$q)
Branch: 1 branch
BranchTrueFalseTotal
if (@$q) 0 0 0
471 {
472 0 my $event = shift @$q;
473 0 my $type = $event->{EventType};
474 0 delete $event->{EventType};
475  
476 0 $self->{Callback}->{$type}->($event);
477 }
478 }
479  
480 1 1; # package return code
481  
482 __END__
↑ Summary