Branch Coverage

blib/lib/PDF/API2/Basic/PDF/File.pm
Criterion Covered Total %
branch 187 322 58.0


line true false branch
190 164 0 unless ($root)
217 8 8 if (ref $filename) { }
219 8 0 if ($update)
226 0 8 unless -f $filename
227 0 8 unless -r $filename
228 8 0 if ($update)
229 0 8 unless -w $filename
234 8 0 if ($update)
243 0 16 unless ($buffer =~ /^\%PDF\-([12]\.\d+)\s*$PDF::API2::Basic::PDF::File::cr/m)
254 16 16 if $buffer =~ /startxref($PDF::API2::Basic::PDF::File::cr|\s*)\d+($PDF::API2::Basic::PDF::File::cr|\s*)\%\%eof.*?/i
256 0 16 unless ($buffer =~ /startxref[^\d]+([0-9]+)($PDF::API2::Basic::PDF::File::cr|\s*)\%\%eof.*?/i)
278 2 7 if (@_)
280 0 2 unless $version =~ /^([12]\.[0-9]+)$/
282 2 0 if ($version >= 1.4) { }
294 4 3 if $trailer_version > $header_version
307 5 9 if (@_)
309 0 5 unless $version =~ /^([12]\.[0-9]+)$/
325 4 8 if (@_)
327 0 4 unless $version =~ /^([12]\.[0-9]+)$/
333 0 8 unless $self->{'Root'}{'Version'}
347 1 2 if $current_version < $min_version
375 0 618 unless ref $self
389 2117 4992 if (&blessed($item) and $item->can('release')) { }
1554 3438 elsif (ref $item eq 'ARRAY') { }
878 2560 elsif (ref $item eq 'HASH') { }
416 0 3 unless $self->{' update'}
423 0 3 if (defined $self->{' newroot'}) { }
432 0 9 unless defined $tdict->{$key}
473 140 0 if (ref $filename) { }
501 4 0 if (ref $filename) { }
531 145 0 if defined $self->{'Info'}
532 0 145 defined $self->{' newroot'} && $self->{' newroot'} ne '' ? :
538 5 140 if $self->{' loc'}
539 5 140 if ($self->{' update'})
541 0 16 unless defined $tdict->{$key}
550 0 145 if ($^O eq "MacOS" and not ref $self->{' fname'})
573 10 821 defined $opts{'update'} ? :
574 821 10 if $update
580 146 685 if ($str =~ /^<
152 533 elsif ($str =~ /^([0-9]+)(?:$PDF::API2::Basic::PDF::File::ws_char|$re_comment)+([0-9]+)(?:$PDF::API2::Basic::PDF::File::ws_char|$re_comment)+R/s) { }
95 438 elsif ($str =~ /^([0-9]+)(?:$PDF::API2::Basic::PDF::File::ws_char|$re_comment)+([0-9]+)(?:$PDF::API2::Basic::PDF::File::ws_char|$re_comment)+obj/s) { }
276 162 elsif ($str =~ m[^/($PDF::API2::Basic::PDF::File::reg_char*)]s) { }
2 160 elsif ($str =~ /^\(/) { }
0 160 elsif ($str =~ /^
74 86 elsif ($str =~ /^\[/) { }
0 86 elsif ($str =~ /^(true|false)($PDF::API2::Basic::PDF::File::irreg_char|$)/) { }
86 0 elsif ($str =~ /^([+-.0-9]+)($PDF::API2::Basic::PDF::File::irreg_char|$)/) { }
0 0 elsif ($str =~ /^null($PDF::API2::Basic::PDF::File::irreg_char|$)/) { }
582 144 2 if $update
589 387 0 if ($str =~ s[^/($PDF::API2::Basic::PDF::File::reg_char+)][]) { }
0 0 elsif ($str =~ s[^/$PDF::API2::Basic::PDF::File::ws_char+][]) { }
0 0 elsif ($str =~ s[^//][/]) { }
592 387 0 unless ((ref $value // "") eq "PDF::API2::Basic::PDF::Null")
599 0 0 unless ((ref $value // "") eq "PDF::API2::Basic::PDF::Null")
606 0 0 unless ((ref $value // "") eq "PDF::API2::Basic::PDF::Null")
613 385 2 if $update
616 144 2 if $update
619 10 136 if ($str =~ s/^stream(?:(?:\015\012)|\012|\015)// and $result->{'Length'}->val != 0)
624 10 0 unless ($opts{'nostreams'})
625 0 10 if ($length > length $str) { }
636 10 0 if $update
641 34 112 if (defined $result->{'Type'} and defined $PDF::API2::Basic::PDF::File::types{$result->{'Type'}->val})
653 119 33 unless ($result = $self->test_obj($num, $value))
676 81 14 if ($result = $self->test_obj($num, $value)) { }
684 91 4 if $update
705 2 0 if ($str =~ /^([^\\()]+)(.*)/s)
711 0 2 if ($str =~ /^(\\[()])/) { }
0 2 elsif ($str =~ /^\(/) { }
2 0 elsif ($str =~ /^\)/) { }
0 0 elsif ($str =~ /^(\\[^()])/) { }
728 2 0 unless $nested_level
742 0 0 unless $fh->read($str, 255, length $str)
760 74 0 if $update
768 224 0 if $update
787 6 78 if ($update and $str =~ /^$re_whitespace*$/s || $str =~ /^$re_whitespace+[0-9]+$re_whitespace*$/s)
791 4 2 if ($str =~ /^$re_whitespace*([0-9]+)$re_whitespace+(?:R|obj)/s)
825 0 77 unless $objind eq $res
838 0 85 unless defined $num
839 0 85 unless defined $gen
840 0 85 unless $num =~ /^[0-9]+$/
841 0 85 unless $gen =~ /^[0-9]+$/
847 4 81 if (ref $object_location)
851 0 4 unless $object_stream
853 4 0 if $object_stream->{' nofilt'}
859 0 4 if ($object_stream->{' streamfile'}) { }
870 0 4 unless $map[$index] == $num
877 2 2 if ($last_object_in_stream == $num) { }
878 2 0 if ($object_stream->{' stream'}) { }
892 0 4 if ($object_stream->{' streamfile'}) { }
925 0 1072 if (defined $self->{' free'} and scalar @{$self->{' free'};} > 0)
927 0 0 if (defined $base) { }
942 0 1073 defined $i ? :
945 0 0 unless (defined $self->locate_obj($i, $ng))
946 0 0 if (defined $base) { }
962 1072 0 if (defined $base) { }
989 1087 1589 unless (exists $self->{' outlist_cache'}{$obj})
1029 0 0 if $self->{' objcache'}{join $;, $objind->{' objnum'}, $objind->{' objgen'}} eq $objind
1048 0 154 unless defined $self->{' OUTFILE'}
1052 154 0 unless scalar @objs > 0
1054 0 890 unless $objind->is_obj($self)
1057 890 0 if ($self->{' outlist'}[$i] eq $objind)
1062 0 890 if $j < 0
1065 0 890 if grep {$_ eq $objind;} @{$$self{" free"};}
1067 0 890 if $objind->{' comments'}
1076 890 0 unless (exists $self->{' printed_cache'}{$objind})
1096 0 0 unless defined $out->{$key}
1103 0 0 unless $nt eq "n"
1105 0 0 if ($nl < $minl or $mini == 0)
1110 0 0 unless ($obj = $self->test_obj($i, $ng))
1120 0 0 defined $filter ? :
1121 0 0 unless not $res or $res->is_obj($out)
1128 0 0 if ($obj->isa("PDF::API2::Basic::PDF::Dict") and $obj->{'Linearized'})
1154 85 9 if (ref $tdict->{' xref'}{$num})
1156 4 81 unless scalar @$ref == 3
1158 81 0 if ($ref->[1] == $gen)
1159 81 0 if $ref->[2] eq "n"
1179 0 1918 if $readDebug
1180 10 1908 if ($instream) { }
1185 0 0 if $readDebug
1192 0 107 if $readDebug
1197 0 1 if $readDebug
1254 26 52 if $width == 1
1255 52 0 if $width == 2
1256 0 0 if $width == 3
1257 0 0 if $width == 4
1258 0 0 if $width == 8
1282 16 3 if ($buf =~ s/^xref$PDF::API2::Basic::PDF::File::cr//i) { }
3 0 elsif ($buf =~ /^(\d+)\s+(\d+)\s+obj/i) { }
1289 0 21 unless ($old_buf =~ /^[0-9]+ [0-9]+$PDF::API2::Basic::PDF::File::cr/)
1297 118 0 unless exists $xlist->{$xmin}
1302 0 16 unless ($buf =~ /^\s*trailer\b/i)
1316 0 3 unless ($tdict->{' stream'})
1328 1 2 if (defined $tdict->{'Index'}) { }
1348 78 0 if $w
1353 1 25 unless defined $cols[0]
1354 0 26 if ($cols[0] > 2)
1358 0 26 if exists $xlist->{$xmin}
1360 1 0 $xmin ? :
25 1 defined $cols[2] ? :
1361 2 20 $cols[0] == 0 ? :
22 4 if $cols[0] < 2
1373 16 3 if $xmin + 1 > $self->{' maxobj'}
1375 3 16 if defined $tdict->{'Prev'} and $tdict->{'Prev'}->val != 0
1376 16 3 unless defined $tdict->{' prev'}
1411 3 145 unless $self->{' printed'}
3 145 unless $self->{' free'}
1414 140 8 unless ($update)
1432 3 145 unless $self->{' free'}
1436 160 878 if ($i > $#xreflist or $self->{' objects'}{$xreflist[$i]->uid}[0] != $j + 1) { }
1437 148 12 $first == -1 ? :
1438 148 12 if ($first == -1)
1439 0 148 defined $freelist[$k] ? :
1444 0 890 if (defined $freelist[$k] and defined $xref and "$freelist[$k]" eq "$xref") { }
1449 0 0 defined $freelist[$k] ? :
1459 12 148 if $i < scalar @xreflist
1465 0 148 if (exists $tdict->{'Type'} and $tdict->{'Type'}->val eq 'XRef') { }
1469 0 0 @a == 2 ? :
1478 0 0 $tloc > 65535 ? :
1479 0 0 $tloc > 65535 ? :
1484 0 0 if $_->[2] eq "f" and $_->[1] == 65535
1485 0 0 $_->[2] eq 'n' ? :