Branch Coverage

blib/lib/PDF/Tiny.pm
Criterion Covered Total %
branch 224 362 61.8


line true false branch
49 14 2 if (@_ == 1) { }
61 14 2 if (defined $file) { }
62 0 14 unless open my $fh, '<', $file
64 0 14 unless defined read($fh, my $read, 1024)
65 0 14 unless ($read =~ /%PDF-([0-9.]+)/)
71 10 4 if ($self->[2][1]{'ID'})
78 2 0 if (not $opts{'empty'}) { }
100 2 12 unless seek $fh, -1024, 2
101 0 14 unless read $fh, my $read, 1024
113 0 15 unless seek $fh, $startxref, 0
115 0 15 unless read $fh, my $read, 1024, length $read
117 2 13 if ($read =~ /^$S*[0-9]/o) { }
127 1 1 $hash->{'Index'} ? :
136 0 20 unless $widths[0]
138 12 8 if ($type == 1) { }
7 1 elsif ($type == 2) { }
141 12 0 unless exists $xref->{$obj_ref}
146 7 0 unless exists $xref->{$obj_ref}
150 0 1 if $ix and $gen != 65535
153 0 20 if ($ix++ > $last)
161 0 0 unless read $fh, $read, 1024, length $read
177 218 30 if (substr($_1, 17, 1) eq 'n') { }
179 218 0 unless exists $xref->{$obj_ref}
184 17 13 unless substr($_1, 11, 5) == 65535
190 14 1 unless ($self->[2])
193 0 14 if exists $trailer->[1]{'Encrypt'}
197 1 14 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 3 unless (defined $self->[5])
306 0 3 unless (%{$self->[9];})
309 0 3 if ($self->[2][1]{'Type'})
312 0 3 unless open my $fh, '>>', $self->[5]
322 0 3 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 3 4 $_ == 0 ? :
377 0 3 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 3 unless @_
494 1 2 if (@_ == 1 and not $_[0] =~ m[^/])
495 0 1 unless $_[0] =~ /^[0-9]+ [0-9]+\z/
500 2 0 if $last_ref
511 0 66 unless $id =~ /^[0-9]+ [0-9]+\z/
512 0 66 unless ($self->[1])
516 0 66 if (ref $loc)
532 0 0 @numbers ? :
544 0 68 unless read $self->[1], my $buf, 1024
548 0 146 unless defined read($self->[1], $buf, 1024, length $buf)
552 0 68 if ($id and $read_id ne $id)
557 10 58 if ($tokens[-1] eq 'stream') { }
567 4 6 if (length $buf < $stream_length) { }
569 0 4 unless read $self->[1], $new_obj->[2], $stream_length - length($buf), length $buf
601 116 132 if (ref $obj) { }
38 94 elsif ($obj =~ m[^/]) { }
602 36 80 if ($obj->[0] eq 'ref')
608 2 36 if (not $subobj) { }
609 2 0 if ($vivify) { }
610 0 2 @_ ? :
624 0 174 unless $obj
626 4 95 if ($obj->[0] eq 'stream')
629 82 17 $key =~ m[^/] ? :
630 1 98 if (not $subobj) { }
631 1 0 if ($vivify) { }
632 1 0 $key =~ m[^/] ? :
0 1 @_ ? :
640 31 68 if ($obj and $obj->[0] eq 'ref')
646 0 174 if $obj->[0] eq 'null'
651 0 277 if ($obj->[0] eq 'flat') { }
67 210 elsif ($obj->[0] eq 'tokens') { }
660 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 ? :
672 0 25 unless ($_[1] =~ /^[a-z]+\z/)
676 2 23 if $lastref
701 0 4 unless (ref $obj)
702 0 0 unless $obj =~ /^[0-9]+ [0-9]+\z/
703 0 0 if ($cach->{$obj})
717 16 4 unless (ref $obj)
723 6 14 $obj->[0] eq 'tokens' ? :
0 20 $obj->[0] eq 'flat' ? :
725 202 20 unless $tokens[$_] eq 'R'
727 16 4 unless ($cach->{$id})
740 16 4 $id && ($cach->{$id} || die("Internal error: $obj got uncached")) ? :
750 5 15 if ($obj->[0] eq 'stream') { }
760 4 0 if ref $ret
776 0 2 if ($filters[0][0] eq 'array') { }
782 2 0 if (@params)
783 0 2 if ($params[0][0] eq 'array')
797 0 2 unless $filter eq 'FlateDecode'
800 2 0 if ($params)
802 2 0 if $params->[1]{'Predictor'}
803 0 2 unless $predictor == 1 or $predictor >= 10
806 0 2 if $params->[1]{'BitsPerComponent'}
807 2 0 if $params->[1]{'Columns'}
808 0 2 if $params->[1]{'Colours'}
809 0 2 if $bpc % 8
815 0 2 unless my $x = &Compress::Zlib::inflateInit()
818 0 2 unless $flate_stat == &Compress::Zlib::Z_STREAM_END
820 2 0 if ($predictor >= 10) { }
827 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) { }
852 0 0 $pb <= $pc ? :
0 0 $pa <= $pb && $pa <= $pc ? :
881 137 1303 if ($more and length $_ < 500) { }
0 1303 elsif (not length $_ or length $_ == $prev_length) { }
889 1395 45 if (s(^(($R+)|<<|>>|[\[\]\{\}]|/$R*))[]o)
891 81 1314 if defined $endtoken and length $2 and $1 =~ /$endtoken/
895 15 30 if (s/^\(//)
906 17 13 if s/^(<[^>]*>)//
922 3 1027 if (length($_) + length($line) > 254 and /^$S*([(<])/o) { }
933 0 65 unless $piecepiece =~ /^[^\\]*(?:\\.[^\\]*)*\z/s
934 1 64 $hex ? :
944 7 1020 ref $_ eq 'SCALAR' ? :
945 425 523 if (length $line and !($line =~ /$D\z/o || /^$D/o) || length($line) + length($_) > 254)
963 13 0 unless wantarray
979 128 408 if ($_ =~ /^\d+$/ and (@$tokens >= 2 and $tokens->[0] =~ /^\d+$/ and $tokens->[1] eq 'R')) { }
71 337 elsif (s[^/][]) { }
80 257 elsif ($_ eq '<<') { }
52 205 elsif ($_ eq '[') { }
14 191 elsif (s/^\(//) { }
174 17 elsif (/^[+\-]?\d+$/ or /^[+\-]?[\d\.]+$/ and tr/.// == 1) { }
17 0 elsif (s/^
0 0 elsif ($_ eq 'true') { }
0 0 elsif ($_ eq 'false') { }
0 0 elsif ($_ eq 'null') { }
1002 80 292 if ($name eq '>>') { }
1011 0 292 if $tmp_hash{$name}[0] eq 'null'
1021 52 154 if ($tokens->[0] eq ']') { }
1038 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 ? :
1100 135 327 if ($_->[0] eq 'num')
1101 36 99 if not $_ or $_ == 0
1102 99 0 if /^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]*)\z/
1104 0 0 unless $ret =~ /e([+-][0-9]+)/
1111 60 267 if ($_->[0] eq 'name')
1119 64 203 if ($_->[0] eq 'dict')
1130 101 102 if $_->[0] eq 'ref'
1133 43 59 if ($_->[0] eq 'array')
1142 14 45 if ($_->[0] eq 'stream')
1147 32 13 if ($_->[0] eq 'str')
1150 3 0 $1 eq "\r" ? :
1155 6 7 if $_->[0] eq 'tokens'
1158 0 7 if $_->[0] eq 'bool'
1160 7 0 if $_->[0] eq 'flat'
1162 0 0 if $_->[0] eq 'null'