Branch Coverage

lib/PDF/Data.pm
Criterion Covered Total %
branch 0 422 0.0


line true false branch
39 0 0 if ref $_[0]
40 0 0 if ref $_[0]
41 0 0 if &is_hash
89 0 0 unless ($x and $y and $x > 0 and $y > 0)
91 0 0 unless $sizes{$x}
96 0 0 unless $x and $y and $x > 0 and $y > 0
99 0 0 if $x < 72
100 0 0 if $y < 72
153 0 0 if (($file // '-') eq '-') { }
156 0 0 unless binmode STDIN
158 0 0 unless close STDIN
161 0 0 unless open my $IN, "<", $file
162 0 0 unless binmode $IN
164 0 0 unless close $IN
183 0 0 unless my($pdf_version, $pdf_data) = $data =~ /%PDF-(\d+\.\d+)$s*?$n(.*)%%EOF/ds
189 0 0 unless $pdf_version =~ /^1\.[0-7]$/d
203 0 0 if ($objects[$i][0] eq "trailer")
205 0 0 unless $i < $#objects and $objects[$i + 1][1]{'type'} eq "dict"
212 0 0 unless defined $trailer
226 0 0 $self->{'-novalidate'} ? :
240 0 0 if (($file // '-') eq '-') { }
243 0 0 unless binmode STDOUT
244 0 0 unless print STDOUT $pdf_data
247 0 0 unless open my $OUT, ">", $file
248 0 0 unless binmode $OUT
249 0 0 unless print $OUT $pdf_data
250 0 0 unless close $OUT
253 0 0 if $time
268 0 0 if $time
316 0 0 if not defined $file or $file eq ""
325 0 0 unless open my $OUT, ">$file"
331 0 0 unless printf $OUT "\$pdf = %s;\n", $self->dump_object($self, "\$pdf", $seen, 0, $mode)
334 0 0 unless close $OUT
337 0 0 if ($mode eq 'outline') { }
338 0 0 unless $file eq "-"
340 0 0 unless $file eq "-"
357 0 0 unless &is_array($streams)
361 0 0 unless &is_stream($stream)
379 0 0 if &is_stream($content_stream)
393 0 0 if m[^(?:/Figure <>BDC|/PlacedGraphic /MC\d BDC|EMC|/GS\d gs|BX /Sh\d sh EX Q|[Qqh]|W n|$n $n $n $n $n $n cm)$s*$]d
396 0 0 if (my($x1, $y1, $x2, $y2, $x3, $y3) = /^($n) ($n) (?:[ml]|($n) ($n) (?:[vy]|($n) ($n) c))$/d) { }
0 0 elsif (my($x, $y, $width, $height) = /^($n) ($n) ($n) ($n) re$/d) { }
413 0 0 unless $new
451 0 0 wantarray ? :
476 0 0 if $det == 0
535 0 0 if ($@)
537 0 0 if ($self->{'-validate'}) { }
556 0 0 unless &is_array(my $kids = $page_tree_node->{'Kids'})
558 0 0 unless &is_hash(my $kid = $kids->[$i])
559 0 0 unless $kid->{'Type'}
560 0 0 if ($kid->{'Type'} eq '/Pages') { }
0 0 elsif ($kid->{'Type'} eq '/Page') { }
571 0 0 if &is_hash($page_tree_node->{'Resources'})
574 0 0 if (($page_tree_node->{'Count'} || 0) != $count)
587 0 0 if (my $contents = $page->{'Contents'})
588 0 0 if &is_array($contents)
589 0 0 unless &is_stream($contents)
595 0 0 if &is_hash($page->{'Resources'})
603 0 0 if &is_hash($resources->{'XObject'})
621 0 0 unless &is_stream($xobject)
625 0 0 if $xobject->{'Subtype'} eq "/Form"
628 0 0 if &is_hash($xobject->{'Resources'})
637 0 0 if $@
640 0 0 if $self->{'-minify'}
659 0 0 if PDF::Data::dump([map({$_->[0];} @{$objects;})]) ne PDF::Data::dump([map({$_->[0];} $self->parse_objects({}, $stream->{'-data'}, 0))])
672 0 0 if ($object->[1]{'type'} eq 'dict') { }
0 0 elsif ($object->[1]{'type'} eq 'array') { }
0 0 elsif ($object->[1]{'type'} eq 'image') { }
699 0 0 if ($i % 2) { }
700 0 0 if (&is_hash($pairs[$i])) { }
0 0 elsif (&is_array($pairs[$i])) { }
721 0 0 if (&is_hash($obj)) { }
0 0 elsif (&is_array($obj)) { }
745 0 0 if ($self->{'-minify'})
751 0 0 if length(${$stream;}) - (rindex(${$stream;}, "\n") + 1) + length($object) >= 255
754 0 0 unless ${$stream;} =~ /(^|[$ss)>\[\]{}])$/d or $object =~ m(^[$ss()<>\[\]{}/%])d
765 0 0 unless $hash
768 0 0 unless &is_hash($hash)
771 0 0 if (defined $value and !defined($hash->{$key}) || $hash->{$key} ne $value) { }
0 0 elsif (not defined $value and exists $hash->{$key}) { }
772 0 0 if $hash->{$key}
775 0 0 if $hash->{$key}
820 0 0 if (s/\A$ws//d) { }
0 0 elsif (s/\A(<<((?:[^<>]+|<[^<>]+>|(?1))*)$ws?>>)//d) { }
0 0 elsif (s/\A(\[((?:(?>[^\[\]]+)|(?1))*)\])//d) { }
0 0 elsif (s/\A(\((?:(?>[^\\()]+)|\\.|(?1))*\))//d) { }
0 0 elsif (s/\A(<[0-9A-Fa-f$ss]*>)//d) { }
0 0 elsif (s(\A(/?[^$ss()<>\[\]{}/%]+))[]d) { }
826 0 0 $i % 2 ? :
839 0 0 if ($token eq 'obj' or $token eq 'R') { }
0 0 elsif ($token eq 'ID') { }
0 0 elsif ($token eq 'stream') { }
0 0 elsif ($token eq 'endobj') { }
0 0 elsif ($token eq 'xref') { }
0 0 elsif ($token =~ /^[+-]?\d+$/d) { }
0 0 elsif ($token =~ /^[+-]?(?:\d+\.\d*|\.\d+)$/d) { }
0 0 elsif ($token =~ m[^/(.*)$]d) { }
0 0 elsif ($token =~ /^(?:true|false)$/d) { }
841 0 0 $token eq 'R' ? :
843 0 0 unless "$id->[1]{'type'} $gen->[1]{'type'}" eq "int int"
848 0 0 $token eq 'R' ? :
850 0 0 unless s/\A$s(.*?)(?:\r\n|$s)?EI$s//ds
858 0 0 unless $stream->[1]{'type'} eq "dict"
859 0 0 unless $id->[1]{'type'} eq "obj"
862 0 0 unless defined(my $length = $stream->{'Length'})
867 0 0 if ($type eq '/ObjStm') { }
0 0 elsif ($type eq '/XRef') { }
0 0 elsif (not $type =~ m[^(?:/(?:CMap|Metadata|XObject))?$]d) { }
876 0 0 unless (defined $length and not ref $length and substr($_, $length) =~ /\A($s*endstream$ws)/d)
877 0 0 if (/\A((?>(?:[^e]+|(?!endstream$s)e)*))endstream$s/d) { }
891 0 0 if $stream->{'Filter'}
894 0 0 unless $id->[1]{'type'} eq "obj"
901 0 0 unless s/\A$ws\d+$ws\d+$n(?>\d{10}\ \d{5}\ [fn](?:\ [\r\n]|\r\n))+//d
938 0 0 wantarray ? :
946 0 0 &is_array($stream->{'Filter'}) ? :
0 0 $stream->{'Filter'} ? :
949 0 0 if ($filters[0] eq "/FlateDecode")
957 0 0 if ($status == Z_OK() or $status == Z_STREAM_END()) { }
968 0 0 if (@filters > 1) { }
0 0 elsif (@filters) { }
983 0 0 &is_array($stream->{'Filter'}) ? :
0 0 $stream->{'Filter'} ? :
989 0 0 unless $zlib->deflate($stream->{'-data'}, $new_stream->{'-data'}) == Z_OK()
990 0 0 unless $zlib->flush($new_stream->{'-data'}, Z_FINISH()) == Z_OK()
992 0 0 @filters ? :
1001 0 0 if (ref $object and builtin::reftype($object) eq "SCALAR")
1003 0 0 if ($objects->{$id}) { }
1005 0 0 if $metadata->{'resolved'}++
1014 0 0 if (&is_hash($object)) { }
0 0 elsif (&is_array($object)) { }
1016 0 0 unless fc $a cmp fc $b
1017 0 0 if ref $object->{$key}
1021 0 0 if (&is_stream($object))
1023 0 0 if $object->{'Length'} and length $object->{'-data'} > $object->{'Length'}
1027 0 0 unless $len == $object->{'Length'}
1032 0 0 if ref $object->[$i]
1083 0 0 $self->{'Root'} ? :
0 0 $self->{'Info'} ? :
0 0 $self->{'Root'}{'Dests'} ? :
0 0 $self->{'Root'}{'Metadata'} ? :
0 0 $self->{'Root'}{'Outlines'} ? :
0 0 $self->{'Root'}{'Pages'} ? :
0 0 $self->{'Root'}{'Threads'} ? :
0 0 $self->{'Root'}{'StructTreeRoot'} ? :
1087 0 0 if $self->{'Root'}{'OCProperties'}
1098 0 0 if (&is_hash($object))
1111 0 0 unless fc $a cmp fc $b
1112 0 0 if (($object->{'Type'} // '') eq '/ExtGState' and $key eq 'Font' and &is_array($object->{'Font'}) and &is_hash($object->{'Font'}[0])) { }
0 0 elsif ($key =~ /^(?:Data|First|ID|Last|Next|Obj|Parent|ParentTree|Popup|Prev|Root|StmOwn|Threads|Widths)$/d or $key =~ /^(?:AN|Annotation|B|C|CI|DocMDP|F|FontDescriptor|I|IX|K|Lock|N|P|Pg|RI|SE|SV|V)$/d and ref $object->{$key} and &is_hash($object->{$key}) or &is_hash($object->{$key}) and $object->{$key}{'-data'} || $object->{$key}{'Kids'} || ($object->{$key}{'Type'} // '') =~ m[^/(?:Filespec|Font)$]d or ($object->{'S'} // '') eq '/Thread' and $key eq 'D' or ($object->{'S'} // '') eq '/Hide' and $key eq 'T') { }
0 0 elsif ($key =~ /^(?:Annots|B|C|CO|Fields|K|Kids|O|Pages|TrapRegions)$/d and &is_array($object->{$key})) { }
0 0 elsif (&is_hash($object->{$key})) { }
1130 0 0 if @objects
1140 0 0 if ($seen->{$object}++)
1141 0 0 unless $objects->[0]{$object}
1146 0 0 if $ancestors->{$object}
1152 0 0 if (&is_hash($object)) { }
0 0 elsif (&is_array($object)) { }
1153 0 0 unless fc $a cmp fc $b
1154 0 0 if ref $object->{$key}
1158 0 0 if ref $obj
1173 0 0 if &is_stream($object)
1176 0 0 if (defined $object and not $objects->[0]{$object})
1191 0 0 if (ref $object and $seen->{$object}++)
1196 0 0 if (&is_hash($object)) { }
0 0 elsif (&is_array($object) and not grep({ref $_;} @{$object;})) { }
0 0 elsif (&is_array($object)) { }
0 0 elsif (builtin::reftype($object) eq 'SCALAR') { }
1198 0 0 if (&is_stream($object))
1200 0 0 if ($self->{'-compress'} || $object->{'-compress'} and not $self->{'-decompress'} || $object->{'-decompress'}) { }
1209 0 0 unless fc $a cmp fc $b
1210 0 0 if $key =~ /^-/d
1212 0 0 if &is_stream($obj)
1214 0 0 if (not ref $obj) { }
0 0 elsif ($objects->[0]{$obj}) { }
1219 0 0 ref $object ? :
1225 0 0 if (&is_stream($object))
1227 0 0 if $indent
1228 0 0 substr($object->{'-data'}, -1) eq "\n" ? :
1234 0 0 if ($self->{'-minify'}) { }
1244 0 0 if &is_stream($obj)
1245 0 0 unless $self->{'-minify'}
1246 0 0 if (not ref $obj) { }
0 0 elsif ($objects->[0]{$obj}) { }
1257 0 0 if $spaces eq " " and not $self->{'-minify'}
1292 0 0 if ($mode eq 'outline') { }
0 0 elsif (ref $object and $seen->{$object}) { }
0 0 elsif (&is_hash($object)) { }
0 0 elsif (&is_array($object) and not grep({ref $_;} @{$object;})) { }
0 0 elsif (&is_array($object)) { }
0 0 elsif (builtin::reftype($object) eq 'SCALAR') { }
1293 0 0 if (ref $object and $seen->{$object}) { }
0 0 elsif (&is_hash($object)) { }
0 0 elsif (&is_array($object) and not grep({ref $_;} @{$object;})) { }
0 0 elsif (&is_array($object)) { }
0 0 elsif (builtin::reftype($object) eq 'SCALAR') { }
1299 0 0 if (&is_stream($object)) { }
1303 0 0 unless ($priority{$a} // 0) <=> ($priority{$b} // 0) or fc $a cmp fc $b
1307 0 0 unless ref $obj
1309 0 0 ref $object ? :
1311 0 0 if ($output) { }
1324 0 0 if ref $object->[$i]
1326 0 0 if ($output =~ /\A$s+(.*?),\n\z/d) { }
0 0 elsif ($output =~ /\n/d) { }
1347 0 0 unless ($priority{$a} // 0) <=> ($priority{$b} // 0) or fc $a cmp fc $b
1352 0 0 if ($key eq '-data') { }
0 0 elsif (not ref $obj) { }
1354 0 0 $obj =~ /\A(?:<\?xpacket|[\n\t -~]*\z)/d ? :
1358 0 0 ref $object ? :
1365 0 0 /^\d+\.\d+$/d ? :
1372 0 0 if (ref $obj) { }
1380 0 0 if $spaces eq " "