Branch Coverage

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


line true false branch
37 0 0 if ref $_[0]
38 0 0 if ref $_[0]
39 0 0 if &is_hash
86 0 0 unless ($x and $y and $x > 0 and $y > 0)
88 0 0 unless $sizes{$x}
93 0 0 unless $x and $y and $x > 0 and $y > 0
96 0 0 if $x < 72
97 0 0 if $y < 72
150 0 0 if (($file // '-') eq '-') { }
153 0 0 unless binmode STDIN
155 0 0 unless close STDIN
158 0 0 unless open my $IN, "<", $file
159 0 0 unless binmode $IN
161 0 0 unless close $IN
180 0 0 unless my($pdf_version, $startxref) = $data =~ /\A(?:%PDF-(\d+\.\d+)$n.*$n)startxref$n(\d+)$n%%EOF$n?\z/ds
183 0 0 unless $pdf_version =~ /^1\.[0-7]$/d
197 0 0 if ($objects[$i][0] eq "trailer")
199 0 0 unless $i < $#objects and $objects[$i + 1][1]{'type'} eq "dict"
206 0 0 unless defined $trailer
220 0 0 $self->{'-novalidate'} ? :
234 0 0 if (($file // '-') eq '-') { }
237 0 0 unless binmode STDOUT
238 0 0 unless print STDOUT $pdf_data
241 0 0 unless open my $OUT, ">", $file
242 0 0 unless binmode $OUT
243 0 0 unless print $OUT $pdf_data
244 0 0 unless close $OUT
247 0 0 if $time
262 0 0 if $time
313 0 0 unless open my $OUT, ">$file"
319 0 0 unless printf $OUT "\$pdf = %s;\n", $self->dump_object($self, "\$pdf", $seen, 0, $mode)
322 0 0 unless close $OUT
325 0 0 if ($mode eq 'outline') { }
326 0 0 unless $file eq "-"
328 0 0 unless $file eq "-"
345 0 0 unless &is_array($streams)
349 0 0 unless &is_stream($stream)
366 0 0 if &is_stream($content_stream)
380 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
383 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) { }
400 0 0 unless $new
438 0 0 wantarray ? :
463 0 0 if $det == 0
522 0 0 if ($@)
524 0 0 if ($self->{'-validate'}) { }
543 0 0 unless &is_array(my $kids = $page_tree_node->{'Kids'})
545 0 0 unless &is_hash(my $kid = $kids->[$i])
546 0 0 unless $kid->{'Type'}
547 0 0 if ($kid->{'Type'} eq '/Pages') { }
0 0 elsif ($kid->{'Type'} eq '/Page') { }
558 0 0 if &is_hash($page_tree_node->{'Resources'})
561 0 0 if (($page_tree_node->{'Count'} || 0) != $count)
571 0 0 if (my $contents = $page->{'Contents'})
572 0 0 if &is_array($contents)
573 0 0 unless &is_stream($contents)
578 0 0 if &is_hash($page->{'Resources'})
586 0 0 if &is_hash($resources->{'XObject'})
604 0 0 unless &is_stream($xobject)
607 0 0 unless $xobject->{'Subtype'} eq "/Form"
613 0 0 if &is_hash($xobject->{'Resources'})
622 0 0 if $@
625 0 0 if $self->{'-minify'}
644 0 0 if PDF::Data::dump([map({$_->[0];} @{$objects;})]) ne PDF::Data::dump([map({$_->[0];} $self->parse_objects({}, $stream->{'-data'}, 0))])
658 0 0 if ($object->[1]{'type'} eq 'dict') { }
0 0 elsif ($object->[1]{'type'} eq 'array') { }
684 0 0 if ($i % 2) { }
685 0 0 if (&is_hash($pairs[$i])) { }
0 0 elsif (&is_array($pairs[$i])) { }
706 0 0 if (&is_hash($obj)) { }
0 0 elsif (&is_array($obj)) { }
722 0 0 if ($self->{'-minify'})
728 0 0 if length((${$stream;} =~ /(.*)\z/d)[0]) + length($object) >= 255
731 0 0 unless ${$stream;} =~ /(^|[\s)>\[\]{}])$/d or $object =~ m(^[\s()<>\[\]{}/%])d
742 0 0 unless $hash
745 0 0 unless &is_hash($hash)
748 0 0 if (defined $value and !defined($hash->{$key}) || $hash->{$key} ne $value) { }
0 0 elsif (not defined $value and exists $hash->{$key}) { }
749 0 0 if $hash->{$key}
752 0 0 if $hash->{$key}
797 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\s]*>)//d) { }
0 0 elsif (s(\A(/?[^\s()<>\[\]{}/%]+))[]d) { }
803 0 0 $i % 2 ? :
816 0 0 if ($token eq 'obj' or $token eq 'R') { }
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) { }
818 0 0 $token eq 'R' ? :
820 0 0 unless "$id->[1]{'type'} $gen->[1]{'type'}" eq "int int"
825 0 0 $token eq 'R' ? :
828 0 0 unless $stream->[1]{'type'} eq "dict"
829 0 0 unless $id->[1]{'type'} eq "obj"
832 0 0 unless defined(my $length = $stream->{'Length'})
836 0 0 unless (defined $length and substr($_, $length) =~ /\A(\s*endstream$ws)/d)
837 0 0 if (/\A((?>(?:[^e]+|(?!endstream\s)e)*))\s*endstream$ws/d) { }
851 0 0 if $stream->{'Filter'}
854 0 0 unless $id->[1]{'type'} eq "obj"
861 0 0 unless s/\A$ws\d+$ws\d+$n(?>\d{10}\ \d{5}\ [fn](?:\ [\r\n]|\r\n))+//d
898 0 0 wantarray ? :
906 0 0 &is_array($stream->{'Filter'}) ? :
0 0 $stream->{'Filter'} ? :
909 0 0 if ($filters[0] eq "/FlateDecode")
917 0 0 if ($status == Z_OK() or $status == Z_STREAM_END()) { }
928 0 0 if (@filters > 1) { }
0 0 elsif (@filters) { }
943 0 0 &is_array($stream->{'Filter'}) ? :
0 0 $stream->{'Filter'} ? :
949 0 0 unless $zlib->deflate($stream->{'-data'}, $new_stream->{'-data'}) == Z_OK()
950 0 0 unless $zlib->flush($new_stream->{'-data'}, Z_FINISH()) == Z_OK()
952 0 0 @filters ? :
961 0 0 if (ref $object and &reftype($object) eq "SCALAR")
963 0 0 if ($objects->{$id}) { }
965 0 0 if $metadata->{'resolved'}++
974 0 0 if (&is_hash($object)) { }
0 0 elsif (&is_array($object)) { }
976 0 0 unless fc $a cmp fc $b
977 0 0 if ref $object->{$key}
981 0 0 if (&is_stream($object))
982 0 0 if $object->{'Length'} and length $object->{'-data'} > $object->{'Length'}
986 0 0 unless $len == $object->{'Length'}
991 0 0 if ref $object->[$i]
1042 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'} ? :
1046 0 0 if $self->{'Root'}{'OCProperties'}
1057 0 0 if (&is_hash($object))
1070 0 0 unless fc $a cmp fc $b
1071 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})) { }
1089 0 0 if @objects
1099 0 0 if ($seen->{$object}++)
1100 0 0 unless $objects->[0]{$object}
1105 0 0 if $ancestors->{$object}
1111 0 0 if (&is_hash($object)) { }
0 0 elsif (&is_array($object)) { }
1112 0 0 unless fc $a cmp fc $b
1113 0 0 if ref $object->{$key}
1117 0 0 if ref $obj
1132 0 0 if (defined $object and not $objects->[0]{$object})
1147 0 0 if (ref $object and $seen->{$object}++)
1152 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 (&reftype($object) eq 'SCALAR') { }
1154 0 0 if (&is_stream($object))
1155 0 0 if ($self->{'-compress'} || $object->{'-compress'} and not $self->{'-decompress'} || $object->{'-decompress'}) { }
1164 0 0 unless fc $a cmp fc $b
1165 0 0 if $key =~ /^-/d
1167 0 0 if &is_stream($obj)
1169 0 0 if (not ref $obj) { }
0 0 elsif ($objects->[0]{$obj}) { }
1174 0 0 ref $object ? :
1180 0 0 if (&is_stream($object))
1181 0 0 if $indent
1182 0 0 substr($object->{'-data'}, -1) eq "\n" ? :
1188 0 0 if ($self->{'-minify'}) { }
1198 0 0 if &is_stream($obj)
1199 0 0 unless $self->{'-minify'}
1200 0 0 if (not ref $obj) { }
0 0 elsif ($objects->[0]{$obj}) { }
1211 0 0 if $spaces eq " " and not $self->{'-minify'}
1232 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 (&reftype($object) eq 'SCALAR') { }
1233 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 (&reftype($object) eq 'SCALAR') { }
1239 0 0 if (&is_stream($object)) { }
1243 0 0 unless fc $a cmp fc $b
1247 0 0 unless ref $obj
1249 0 0 ref $object ? :
1251 0 0 if ($output) { }
1264 0 0 if ref $object->[$i]
1266 0 0 if ($output =~ /\A\s+(.*?),\n\z/d) { }
0 0 elsif ($output =~ /\n/d) { }
1287 0 0 unless fc $a cmp fc $b
1292 0 0 if ($key eq '-data') { }
0 0 elsif (not ref $obj) { }
1294 0 0 $obj =~ /\A(?:<\?xpacket|[\n\t -~]*\z)/d ? :
1298 0 0 ref $object ? :
1305 0 0 /^\d+\.\d+$/d ? :
1312 0 0 if (ref $obj) { }
1320 0 0 if $spaces eq " "