Branch Coverage

blib/lib/Net/IMP/ProtocolPinning.pm
Criterion Covered Total %
branch 190 264 71.9


line true false branch
43 0 60 unless my $r = delete $args{'rules'}
46 50 10 if ($max_unbound)
47 0 50 if @$max_unbound > 2
49 32 68 unless defined $max_unbound->[$_]
50 0 68 unless $max_unbound->[$_] =~ /^\d+$/
76 0 132 unless ($dir // -1) ~~ [0, 1]
77 0 132 unless ($r->[$i]{'rxlen'} || 0) > 0
79 0 132 if ref $rx ne 'Regexp'
80 0 132 if '' ~~ $rx
82 76 56 if (not $ignore_order) { }
48 8 elsif (not @{$ruleset[$dir];}) { }
84 6 26 $dir ? :
85 58 18 if ($lastdir != $dir)
97 120 12 if ($allow_reorder or not @{$ruleset[$dir][-1];}) { }
122 0 30 unless eval { do { my(@x) = _compile_cfg(%args) } }
149 8 33 $fargs->{'allow_dup'} ? :
165 0 63 if ($Net::IMP::ProtocolPinning::DEBUG)
171 32 31 if ($r->{'rxlen'} <= $lbuf) { }
172 30 2 if (substr($$rbuf, 0, $r->{'rxlen'}) =~ s/\A$r->{'rx'}//)
174 0 30 if $Net::IMP::ProtocolPinning::DEBUG
177 0 2 if $Net::IMP::ProtocolPinning::DEBUG
180 19 12 if ($$rbuf =~ /\A$r->{'rx'}/g)
183 0 19 if $Net::IMP::ProtocolPinning::DEBUG
186 0 12 if $Net::IMP::ProtocolPinning::DEBUG
197 0 30 if $r->{'rxlen'} < $len
198 22 8 $$rbuf =~ /\A$r->{'rx'}\Z/ ? :
206 8 106 unless ($self->{'buf'})
208 0 8 if $Net::IMP::ProtocolPinning::DEBUG
213 0 106 if $offset
217 36 70 $type > 0 ? :
219 7 99 if ($data eq '')
223 0 7 if $Net::IMP::ProtocolPinning::DEBUG
225 2 5 if (@$rs and my $match_in_progress = $self->{'off_passed'}[$dir] - $self->{'off_buf'}[$dir])
234 2 0 unless (@{$rs->[0];})
237 2 0 unless (@$rs and $rs->[0])
238 0 2 $dir ? :
239 2 0 if @$ors and not $ors->[0]
241 0 2 unless @$rs
246 5 2 if (my($r) = grep({$_;} @$rs)) { }
266 0 115 if $Net::IMP::ProtocolPinning::DEBUG
269 15 100 unless (@$rs)
272 0 15 unless $self->{'buf'}[$dir] eq ''
275 1 14 $dir ? :
277 1 14 if (@$ors == 1 and @{$ors->[0];} == 1 and $self->{'off_passed'}[$odir] - $self->{'off_buf'}[$odir] > 0)
287 7 7 unless (defined $max_unbound)
288 0 7 if $Net::IMP::ProtocolPinning::DEBUG
290 5 2 unless ($self->{'paused'}[$dir])
301 0 7 if $Net::IMP::ProtocolPinning::DEBUG
302 4 3 if ($unbound <= $max_unbound)
303 0 4 if $Net::IMP::ProtocolPinning::DEBUG
318 70 30 unless ($type > 0)
324 9 91 unless ($crs)
328 6 3 $dir ? :
330 5 4 if (@$ors and $ors->[0] and my $omatch_in_progress = $self->{'off_passed'}[$odir] - $self->{'off_buf'}[$odir])
332 0 5 if $Net::IMP::ProtocolPinning::DEBUG
336 5 0 unless (@{$ors->[0];})
338 5 0 unless @$ors and $ors->[0]
339 0 0 unless @$ors or @$rs
346 0 0 if ($type > 0 and $self->{'matched'} and $self->{'buf'}[$dir] eq '' and my $matched = $self->{'matched'}[$dir])
349 0 0 if (defined(my $r = $matched->{$hpkt}))
350 0 0 if $Net::IMP::ProtocolPinning::DEBUG
356 0 4 if $Net::IMP::ProtocolPinning::DEBUG
359 2 2 $dir ? :
365 5 86 if (my $match_in_progress = $self->{'off_passed'}[$dir] - $self->{'off_buf'}[$dir])
368 0 5 if ($type > 0) { }
372 0 5 unless $matched
373 4 1 if ($removed) { }
1 0 elsif ($matched > $match_in_progress) { }
375 0 4 if $Net::IMP::ProtocolPinning::DEBUG
377 3 1 if ($removed > $match_in_progress)
385 0 1 if $Net::IMP::ProtocolPinning::DEBUG
391 0 0 if $Net::IMP::ProtocolPinning::DEBUG
398 0 0 if $Net::IMP::ProtocolPinning::DEBUG
406 4 0 unless (@$crs)
409 2 2 unless (@$rs and $rs->[0])
410 0 2 $dir ? :
411 0 2 if @$ors and not $ors->[0]
412 0 0 unless @$ors or @$rs
415 3 1 if ($type > 0 or $self->{'buf'}[$dir] ne '')
417 1 2 unless (@$rs)
429 28 58 if ($type > 0) { }
431 0 28 if ($self->{'buf'}[$dir] ne '')
439 22 8 if (my($len) = &$match($$rules[$crs->[$i]], \$data))
443 9 13 if ($self->{'matched'})
452 4 18 if (@$crs > 1) { }
454 0 4 if $Net::IMP::ProtocolPinning::DEBUG
459 0 18 if $Net::IMP::ProtocolPinning::DEBUG
463 14 4 unless (@$rs and $rs->[0])
464 5 9 $dir ? :
465 10 4 if @$ors and not $ors->[0]
470 10 12 unless @$rs
476 5 1 if ($self->{'matched'} and my $dup = $self->{'matched'}[$dir])
478 5 0 if (defined $r)
482 0 5 if $Net::IMP::ProtocolPinning::DEBUG
488 0 1 if $Net::IMP::ProtocolPinning::DEBUG
504 2 56 if (not defined $len) { }
12 44 elsif (not $len) { }
514 9 9 if (not $removed and @$crs == 1 and @$rs == 1)
518 2 7 unless (defined($ma && $ma->[$dir]))
525 16 28 if (not $removed) { }
528 0 16 if $i > 0
536 7 9 if (@$crs == 1 and @$rs == 1)
538 2 5 $dir ? :
539 1 3 $dir ? :
1 3 $dir ? :
3 4 if (not @$ors or @$ors == 1 and not $ors->[0] or @$ors == 1 and @{$ors->[0];} == 1 and $self->{'off_passed'}[$dir ? 0 : 1] - $self->{'off_buf'}[$dir ? 0 : 1] > 0)
559 3 25 if (@$crs > 1) { }
561 0 3 if $Net::IMP::ProtocolPinning::DEBUG
566 0 25 if $Net::IMP::ProtocolPinning::DEBUG
570 23 2 unless (@$rs and $rs->[0])
571 14 9 $dir ? :
572 7 16 if @$ors and not $ors->[0]
573 13 0 unless @$ors or @$rs
581 8 20 if ($final_match and $self->{'buf'}[$dir] ne '')
587 1 19 unless @$rs
591 2 12 unless ($temp_fail)
593 0 2 if $Net::IMP::ProtocolPinning::DEBUG
604 0 28 if @$rs
608 18 10 $dir ? :
2 26 if @{$self->{'ruleset'}[$dir ? 0 : 1];}
611 0 26 if $Net::IMP::ProtocolPinning::DEBUG
618 47 5 unless $self->{'paused'}[$_]
625 19 46 unless $pass_until
637 0 2 unless my $rules = delete $cfg{'rules'}
642 2 0 if (my $max_unbound = delete $cfg{'max_unbound'})
654 6 9 unless defined(my $dir = delete $cfg{"dir$i"})
655 0 9 unless defined(my $rxlen = delete $cfg{"rxlen$i"})
657 0 9 unless defined(my $rx = delete $cfg{"rx$i"})
659 0 9 unless $rx = eval { do { qr/$rx/ } }
664 0 6 unless @$rules
668 12 0 if exists $cfg{"max_unbound$_"}
674 0 6 if %scfg