Branch Coverage

blib/lib/PDF/Builder/Basic/PDF/File.pm
Criterion Covered Total %
branch 182 360 50.5


line true false branch
202 162 0 unless ($root)
247 15 0 unless defined $options{'-diags'}
251 15 0 if (ref $filename) { }
253 15 0 if ($update)
259 0 0 unless -f $filename
262 0 0 if ($update)
271 0 15 unless ($buffer =~ /^\%PDF\-(\d+\.\d+)(.*?)$PDF::Builder::Basic::PDF::File::cr/mo)
276 0 15 if (defined $2 and length $2 > 0)
289 15 15 if $buffer =~ /startxref($PDF::Builder::Basic::PDF::File::cr|\s*)\d+($PDF::Builder::Basic::PDF::File::cr|\s*)\%\%eof.*?/i
291 0 15 unless ($buffer =~ /startxref[^\d]+([0-9]+)($PDF::Builder::Basic::PDF::File::cr|\s*)\%\%eof.*?/i)
292 0 0 if ($options{'-diags'} == 1)
331 0 127 unless ref $self
340 1800 4453 if (&blessed($item) and $item->can('release')) { }
1332 3121 elsif (ref $item eq 'ARRAY') { }
756 2365 elsif (ref $item eq 'HASH') { }
367 0 8 unless $self->{' update'}
385 0 8 if (defined $self->{' newroot'}) { }
393 0 25 unless defined $tdict->{$key}
435 119 0 if (ref $filename) { }
466 119 0 if defined $self->{'Info'}
467 0 119 defined $self->{' newroot'} && $self->{' newroot'} ne '' ? :
473 0 119 if $self->{' loc'}
474 0 119 if ($self->{' update'})
476 0 0 unless defined $tdict->{$key}
485 0 119 if ($^O eq 'MacOS' and not ref $self->{' fname'})
509 10 1294 defined $opts{'update'} ? :
510 1294 10 if $update
515 134 1170 if ($str =~ /^<
129 1041 elsif ($str =~ /^([0-9]+)(?:$PDF::Builder::Basic::PDF::File::ws_char|$re_comment)+([0-9]+)(?:$PDF::Builder::Basic::PDF::File::ws_char|$re_comment)+R/s) { }
86 955 elsif ($str =~ /^([0-9]+)(?:$PDF::Builder::Basic::PDF::File::ws_char|$re_comment)+([0-9]+)(?:$PDF::Builder::Basic::PDF::File::ws_char|$re_comment)+obj/s) { }
522 433 elsif ($str =~ m[^/($PDF::Builder::Basic::PDF::File::reg_char*)]s) { }
1 432 elsif ($str =~ /^\(/) { }
0 432 elsif ($str =~ /^
83 349 elsif ($str =~ /^\[/) { }
0 349 elsif ($str =~ /^(true|false)($PDF::Builder::Basic::PDF::File::irreg_char|$)/) { }
349 0 elsif ($str =~ /^([+-.0-9]+)($PDF::Builder::Basic::PDF::File::irreg_char|$)/) { }
0 0 elsif ($str =~ /^null($PDF::Builder::Basic::PDF::File::irreg_char|$)/) { }
518 132 2 if $update
525 374 0 if ($str =~ s[^/($PDF::Builder::Basic::PDF::File::reg_char+)][]) { }
0 0 elsif ($str =~ s[^/$PDF::Builder::Basic::PDF::File::ws_char+][]) { }
0 0 elsif ($str =~ s[^//][/]) { }
536 374 0 unless ref $value eq 'PDF::Builder::Basic::PDF::Null'
549 372 2 if $update
553 132 2 if $update
557 11 123 if ($str =~ s/^stream(?:(?:\015\012)|\012|\015)// and $result->{'Length'}->val != 0)
562 11 0 unless ($opts{'nostreams'})
563 0 11 if ($length > length $str) { }
573 11 0 if $update
578 31 103 if (defined $result->{'Type'} and defined $PDF::Builder::Basic::PDF::File::types{$result->{'Type'}->val})
589 107 22 unless ($result = $self->test_obj($num, $value))
610 72 14 if ($result = $self->test_obj($num, $value)) { }
617 82 4 if $update
636 1 0 if ($str =~ /^([^\\()]+)(.*)/s)
642 0 1 if ($str =~ /^(\\[()])/) { }
0 1 elsif ($str =~ /^\(/) { }
1 0 elsif ($str =~ /^\)/) { }
0 0 elsif ($str =~ /^(\\[^()])/) { }
657 1 0 unless $nested_level
670 0 0 unless $fh->read($str, 255, length $str)
687 83 0 if $update
695 729 0 if $update
712 6 341 if ($update and $str =~ /^$re_whitespace*$/s || $str =~ /^$re_whitespace+[0-9]+$re_whitespace*$/s)
716 4 2 if ($str =~ /^$re_whitespace*([0-9]+)$re_whitespace+(?:R|obj)/s)
747 0 68 unless $objind eq $res
761 0 76 unless defined $num
762 0 76 unless defined $gen
763 0 76 unless $num =~ /^[0-9]+$/
764 0 76 unless $gen =~ /^[0-9]+$/
770 4 72 if (ref $object_location)
774 0 4 unless $object_stream
776 4 0 if $object_stream->{' nofilt'}
782 0 4 if ($object_stream->{' streamfile'}) { }
792 0 4 unless $map[$index] == $num
799 2 2 if ($last_object_in_stream == $num) { }
800 2 0 if ($object_stream->{' stream'}) { }
812 0 4 if ($object_stream->{' streamfile'}) { }
844 0 1020 if (defined $self->{' free'} and scalar @{$self->{' free'};} > 0)
846 0 0 if (defined $base) { }
860 0 1021 defined $i ? :
863 0 0 unless (defined $self->locate_obj($i, $ng))
864 0 0 if (defined $base) { }
879 1020 0 if (defined $base) { }
904 1037 1209 unless (exists $self->{' outlist_cache'}{$obj})
945 0 0 if $self->{' objcache'}{join $;, $objind->{' objnum'}, $objind->{' objgen'}} eq $objind
966 0 130 unless defined $self->{' OUTFILE'}
970 130 0 unless scalar @objects > 0
972 0 752 unless $objind->is_obj($self)
975 752 0 if ($self->{' outlist'}[$i] eq $objind)
980 0 752 if $j < 0
983 0 752 if grep {$_ eq $objind;} @{$$self{' free'};}
985 0 752 if $objind->{' comments'}
994 752 0 unless (exists $self->{' printed_cache'}{$objind})
1016 0 0 unless defined $outpdf->{$key}
1023 0 0 unless $nt eq 'n'
1025 0 0 if ($nl < $minl or $mini == 0)
1030 0 0 unless ($obj = $self->test_obj($i, $ng))
1040 0 0 defined $filter ? :
1041 0 0 unless not $res or $res->is_obj($outpdf)
1048 0 0 if ($obj->isa('PDF::Builder::Basic::PDF::Dict') and $obj->{'Linearized'})
1073 76 9 if (ref $tdict->{' xref'}{$num})
1075 4 72 unless scalar @$ref == 3
1077 72 0 if ($ref->[1] == $gen)
1078 72 0 if $ref->[2] eq 'n'
1099 0 2859 if $readDebug
1100 11 2848 if ($instream) { }
1105 0 0 if $readDebug
1111 0 107 if $readDebug
1116 0 1 if $readDebug
1175 0 78 if ($width == 3) { }
0 78 elsif ($width == 5) { }
0 78 elsif ($width == 6) { }
0 78 elsif ($width == 7) { }
1189 26 52 if $width == 1
1190 52 0 if $width == 2
1191 0 0 if $width == 4
1192 0 0 if ($width == 8)
1200 0 0 if (substr($data, 0, 4) eq "\000\000\000\000") { }
1234 15 3 if ($buf =~ s/^xref$PDF::Builder::Basic::PDF::File::cr//i) { }
3 0 elsif ($buf =~ /^(\d+)\s+(\d+)\s+obj/i) { }
1251 0 20 unless ($old_buf =~ /^[0-9]+ [0-9]+$PDF::Builder::Basic::PDF::File::cr/)
1252 0 0 if ($options{'-diags'} == 1)
1262 0 20 if ($xnum < 1)
1263 0 0 if ($options{'-diags'} == 1)
1274 20 0 if ($buf =~ /^(.*?)$PDF::Builder::Basic::PDF::File::cr/)
1277 0 20 if ($entry_size != 20 and $options{'-diags'} == 1)
1291 104 0 if ($buf =~ /^\d{10} \d{5} [nf]$PDF::Builder::Basic::PDF::File::cr/ or $entry_format_error) { }
1295 0 0 if ($options{'-diags'} == 1)
1308 0 104 if (exists $xlist->{$xmin}) { }
1309 0 0 if ($options{'-diags'} == 1)
1314 0 15 if ($xmin == 0 and $subsection_count > 1 and $options{'-diags'} == 1)
1331 0 0 unless (exists $xlist->{'0'} or $xrefListEmpty)
1334 0 0 if ($subsection_count == 1 and exists $xlist->{'1'}) { }
1337 0 0 if ($xlist->{'1'}[0] == 0 and $xlist->{'1'}[1] == 65535 and $xlist->{'1'}[2] eq 'f') { }
1342 0 0 if ($options{'-diags'} == 1)
1355 0 0 if ($options{'-diags'} == 1)
1361 0 0 if ($options{'-diags'} == 1)
1372 15 89 if ($xlist->{$_}[2] eq 'f') { }
89 0 elsif ($xlist->{$_}[2] eq 'n') { }
1373 0 15 if ($xlist->{$_}[1] <= 0 and $options{'-diags'} == 1) { }
1379 0 89 if ($xlist->{$_}[0] <= 0 and $options{'-diags'} == 1)
1382 0 89 if ($xlist->{$_}[1] < 0 and $options{'-diags'} == 1)
1386 0 0 if ($options{'-diags'} == 1)
1393 0 15 if ($xlist->{'0'}[1] != 65535 and $options{'-diags'} == 1)
1397 0 15 if ($xlist->{$next_free}[2] ne 'f') { }
1398 0 0 if ($options{'-diags'} == 1)
1408 0 15 if (scalar @free_list and $options{'-diags'} == 1)
1413 0 15 if (not $buf =~ /^\s*trailer\b/i and $options{'-diags'} == 1)
1428 0 3 unless ($tdict->{' stream'})
1429 0 0 if ($options{'-diags'} == 1)
1442 1 2 if (defined $tdict->{'Index'}) { }
1461 78 0 if $w
1466 1 25 unless defined $cols[0]
1467 0 26 if ($cols[0] > 2 and $options{'-diags'} == 1)
1471 0 26 if exists $xlist->{$xmin}
1473 1 0 $xmin ? :
25 1 defined $cols[2] ? :
1474 2 20 $cols[0] == 0 ? :
22 4 if $cols[0] < 2
1481 0 0 if ($options{'-diags'} == 1)
1491 15 3 if $xmin + 1 > $self->{' maxobj'}
1493 3 15 if defined $tdict->{'Prev'} and $tdict->{'Prev'}->val != 0
1494 15 3 unless defined $tdict->{' prev'}
1531 3 124 unless $self->{' printed'}
3 124 unless $self->{' free'}
1534 119 8 unless ($update)
1552 3 124 unless $self->{' free'}
1560 139 740 if ($i > $#xreflist or $self->{' objects'}{$xreflist[$i]->uid}[0] != $j + 1) { }
1562 127 12 $first == -1 ? :
1563 127 12 if ($first == -1)
1565 0 127 defined $freelist[$k] ? :
1570 0 752 if (defined $freelist[$k] and defined $xref and "$freelist[$k]" eq "$xref") { }
1576 0 0 defined $freelist[$k] ? :
1586 12 127 if $i < scalar @xreflist
1596 0 127 if (exists $tdict->{'Type'} and $tdict->{'Type'}->val eq 'XRef') { }
1601 0 0 @a == 2 ? :
1610 0 0 $tloc > 65535 ? :
1611 0 0 $tloc > 65535 ? :
1618 0 0 if $_->[1] == 65535 and $_->[2] eq 'f'
1621 0 0 if ($_->[1] > 255)
1625 0 0 $_->[2] eq 'n' ? :