Branch Coverage

blib/lib/PDF/Tiny.pm
Criterion Covered Total %
branch 228 364 62.6


line true false branch
49 16 2 if (@_ == 1) { }
61 16 2 if (defined $file) { }
62 0 16 unless open my $fh, '<', $file
64 0 16 unless defined read($fh, my $read, 1024)
65 0 16 unless ($read =~ /%PDF-([0-9.]+)/)
71 12 4 if ($self->[2][1]{'ID'})
78 2 0 if (not $opts{'empty'}) { }
100 2 14 unless seek $fh, -1024, 2
101 0 16 unless read $fh, my $read, 1024
113 0 17 unless seek $fh, $startxref, 0
115 0 17 unless read $fh, my $read, 1024, length $read
117 3 14 if ($read =~ /^$S*[0-9]/o) { }
127 1 2 $hash->{'Index'} ? :
136 0 33 unless $widths[0]
138 17 16 if ($type == 1) { }
14 2 elsif ($type == 2) { }
141 17 0 unless exists $xref->{$obj_ref}
146 14 0 unless exists $xref->{$obj_ref}
150 0 2 if $ix and $gen != 65535
153 0 33 if ($ix++ > $last)
161 0 0 unless read $fh, $read, 1024, length $read
177 251 31 if (substr($_1, 17, 1) eq 'n') { }
179 251 0 unless exists $xref->{$obj_ref}
184 17 14 unless substr($_1, 11, 5) == 65535
190 16 1 unless ($self->[2])
193 0 16 if exists $trailer->[1]{'Encrypt'}
197 1 16 defined $trailer->{'Prev'} ? :
214 11 0 if ($self->get_obj($pages, '/Count')->[1] == @{$kids->[1];})
220 0 0 do { $self->get_obj($kid, '/Type') }->[1] eq 'Pages' ? :
234 0 0 if (@{$pages_array->[1];} != $count->[1])
274 0 4 if (@{$pages_array->[1];} != $count->[1])
288 0 0 if $page->[1]{'Parent'}[1] eq $pages_id
303 0 4 unless (defined $self->[5])
306 0 4 unless (%{$self->[9];})
309 0 4 if ($self->[2][1]{'Type'})
312 0 4 unless open my $fh, '>>', $self->[5]
322 0 4 if (@{$id_array->[1];} == 2 and $self->vivify_obj('str', $id_array, 0)->[1] ne $self->[3] || $self->vivify_obj('str', $id_array, 1)->[1] ne $self->[3]) { }
341 1 3 if ($obj->[0] eq 'stream') { }
361 3 1 if ($chunks[-1][-1] + 1 != $_)
370 4 4 $_ == 0 ? :
377 0 4 unless close $fh
385 2 2 if ($args{'filename'}) { }
387 0 2 unless open $fh, '>', $args{'filename'}
399 3 1 if (@{$id_array->[1];} == 2 and $self->vivify_obj('str', $id_array, 0)->[1] ne $self->[3]) { }
417 41 7 unless $trailer[$_] eq 'R'
419 0 7 if $seen{$id}++
426 0 50 unless my $obj = $self->get_obj($id)
429 0 50 $obj->[0] eq 'tokens' ? :
0 50 (my $flat = $obj->[0] eq 'flat') ? :
431 447 54 unless $tokens[$_] eq 'R'
433 11 43 if $seen{$id}++
437 8 42 if ($obj->[0] eq 'stream') { }
454 22 28 if $del
461 46 12 if $ids[$_]
474 16 50 exists $next_free{$_} ? :
481 2 2 if ($args{'filename'})
482 0 2 unless close $fh
493 0 4 unless @_
494 2 2 if (@_ == 1 and not $_[0] =~ m[^/])
495 0 2 unless $_[0] =~ /^[0-9]+ [0-9]+\z/ or $_[0] eq 'trailer'
501 2 0 if $last_ref
512 0 66 unless $id =~ /^[0-9]+ [0-9]+\z/
513 0 66 unless ($self->[1])
517 0 66 if (ref $loc)
533 0 0 @numbers ? :
545 0 69 unless read $self->[1], my $buf, 1024
549 0 177 unless defined read($self->[1], $buf, 1024, length $buf)
553 0 69 if ($id and $read_id ne $id)
558 11 58 if ($tokens[-1] eq 'stream') { }
568 4 7 if (length $buf < $stream_length) { }
570 0 4 unless read $self->[1], $new_obj->[2], $stream_length - length($buf), length $buf
602 126 133 if (ref $obj) { }
39 94 elsif ($obj =~ m[^/]) { }
603 36 90 if ($obj->[0] eq 'ref')
609 2 37 if (not $subobj) { }
610 2 0 if ($vivify) { }
611 0 2 @_ ? :
625 0 184 unless $obj
627 7 100 if ($obj->[0] eq 'stream')
630 86 21 $key =~ m[^/] ? :
631 4 103 if (not $subobj) { }
632 1 3 if ($vivify) { }
633 1 0 $key =~ m[^/] ? :
0 1 @_ ? :
641 31 73 if ($obj and $obj->[0] eq 'ref')
647 0 181 if $obj->[0] eq 'null'
652 0 292 if ($obj->[0] eq 'flat') { }
67 225 elsif ($obj->[0] eq 'tokens') { }
661 0 0 $key =~ m[^/] ? :
0 1 $type eq 'stream' ? :
0 1 $type eq 'null' ? :
0 1 $type eq 'num' ? :
2 1 $type =~ /^(?:array|tokens)\z/ ? :
0 3 $type eq 'dict' ? :
0 3 defined $key ? :
673 0 30 unless ($_[1] =~ /^[a-z]+\z/)
677 2 28 if $lastref
702 0 4 unless (ref $obj)
703 0 0 unless $obj =~ /^[0-9]+ [0-9]+\z/
704 0 0 if ($cach->{$obj})
718 16 4 unless (ref $obj)
724 6 14 $obj->[0] eq 'tokens' ? :
0 20 $obj->[0] eq 'flat' ? :
726 202 20 unless $tokens[$_] eq 'R'
728 16 4 unless ($cach->{$id})
741 16 4 $id && ($cach->{$id} || die("Internal error: $obj got uncached")) ? :
751 5 15 if ($obj->[0] eq 'stream') { }
761 4 0 if ref $ret
777 2 1 if (@filters)
778 0 2 if ($filters[0][0] eq 'array') { }
785 2 1 if (@params)
786 0 2 if ($params[0][0] eq 'array')
800 0 2 unless $filter eq 'FlateDecode'
803 2 0 if ($params)
805 2 0 if $params->[1]{'Predictor'}
806 0 2 unless $predictor == 1 or $predictor >= 10
809 0 2 if $params->[1]{'BitsPerComponent'}
810 2 0 if $params->[1]{'Columns'}
811 0 2 if $params->[1]{'Colours'}
812 0 2 if $bpc % 8
818 0 2 unless my $x = &Compress::Zlib::inflateInit()
821 0 2 unless $flate_stat == &Compress::Zlib::Z_STREAM_END
823 2 0 if ($predictor >= 10) { }
830 20 0 if ($filter == 2) { }
0 0 elsif (not $filter) { }
0 0 elsif ($filter == 1) { }
0 0 elsif ($filter == 3) { }
0 0 elsif ($filter == 4) { }
855 0 0 $pb <= $pc ? :
0 0 $pa <= $pb && $pa <= $pc ? :
884 168 1321 if ($more and length $_ < 500) { }
0 1321 elsif (not length $_ or length $_ == $prev_length) { }
892 1440 49 if (s(^(($R+)|<<|>>|[\[\]\{\}]|/$R*))[]o)
894 83 1357 if defined $endtoken and length $2 and $1 =~ /$endtoken/
898 15 34 if (s/^\(//)
909 21 13 if s/^(<[^>]*>)//
925 3 1044 if (length($_) + length($line) > 254 and /^$S*([(<])/o) { }
936 0 65 unless $piecepiece =~ /^[^\\]*(?:\\.[^\\]*)*\z/s
937 1 64 $hex ? :
947 7 1037 ref $_ eq 'SCALAR' ? :
948 430 533 if (length $line and !($line =~ /$D\z/o || /^$D/o) || length($line) + length($_) > 254)
966 14 0 unless wantarray
982 132 424 if ($_ =~ /^\d+$/ and (@$tokens >= 2 and $tokens->[0] =~ /^\d+$/ and $tokens->[1] eq 'R')) { }
72 352 elsif (s[^/][]) { }
82 270 elsif ($_ eq '<<') { }
55 215 elsif ($_ eq '[') { }
14 201 elsif (s/^\(//) { }
180 21 elsif (/^[+\-]?\d+$/ or /^[+\-]?[\d\.]+$/ and tr/.// == 1) { }
21 0 elsif (s/^
0 0 elsif ($_ eq 'true') { }
0 0 elsif ($_ eq 'false') { }
0 0 elsif ($_ eq 'null') { }
1005 82 303 if ($name eq '>>') { }
1014 0 303 if $tmp_hash{$name}[0] eq 'null'
1024 55 161 if ($tokens->[0] eq ']') { }
1041 0 0 length $match ? :
0 0 $match eq '\\' ? :
0 0 $match eq ')' ? :
0 0 $match eq '(' ? :
0 0 $match eq 'f' ? :
0 0 $match eq 'b' ? :
0 0 $match eq 't' ? :
0 0 $match eq 'r' ? :
0 0 $match eq 'n' ? :
0 0 $match =~ /\d/ ? :
32 0 $match =~ /$N/o ? :
2 32 $unescaped ? :
1103 137 332 if ($_->[0] eq 'num')
1104 36 101 if not $_ or $_ == 0
1105 101 0 if /^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]*)\z/
1107 0 0 unless $ret =~ /e([+-][0-9]+)/
1114 60 272 if ($_->[0] eq 'name')
1122 65 207 if ($_->[0] eq 'dict')
1133 102 105 if $_->[0] eq 'ref'
1136 44 61 if ($_->[0] eq 'array')
1145 14 47 if ($_->[0] eq 'stream')
1150 34 13 if ($_->[0] eq 'str')
1153 3 0 $1 eq "\r" ? :
1158 6 7 if $_->[0] eq 'tokens'
1161 0 7 if $_->[0] eq 'bool'
1163 7 0 if $_->[0] eq 'flat'
1165 0 0 if $_->[0] eq 'null'