Branch Coverage

blib/lib/Tie/File.pm
Criterion Covered Total %
branch 350 458 76.4


line true false branch
28 0 2987 if (@_ % 2 != 0)
35 0 57 unless ($good_opt{$key})
39 0 57 if ($key =~ s/^-+//)
44 0 2987 if ($opts{'concurrent'})
48 2983 4 unless (defined $opts{'memory'})
53 0 2983 if defined $opts{'dw_size'} and $opts{'dw_size'} > $DEFAULT_MEMORY_SIZE
56 2986 1 unless defined $opts{'dw_size'}
57 0 2987 if ($opts{'dw_size'} > $opts{'memory'})
61 2987 0 unless defined $opts{'defer'}
70 2970 17 unless defined $opts{'autodefer'}
74 2987 0 unless defined $opts{'autodefer_threshhold'}
76 2987 0 unless defined $opts{'autodefer_filelen_threshhold'}
80 2974 13 unless (defined $opts{'recsep'})
84 0 2987 if ($opts{'recseplen'} == 0)
88 2968 19 unless defined $opts{'autochomp'}
90 2984 3 unless defined $opts{'mode'}
96 2 2985 if (UNIVERSAL::isa($file, 'GLOB')) { }
0 2985 elsif (ref $file) { }
101 1 1 unless (seek $file, 1, 0)
110 0 2985 if ($] < "5.006")
115 0 2985 unless sysopen $fh, $file, $opts{'mode'}, 438
120 0 2986 if (defined $opts{'discipline'} and $] >= "5.006")
123 0 0 if $@ =~ /unknown discipline/i
124 0 0 if $@
136 8 1039 if exists $self->{'deferred'}{$n}
137 1039 8 unless defined $rec
141 747 290 if defined $rec and $self->{'autochomp'}
148 97 48 unless $self->{'autochomp'}
149 48 0 if ($self->{'autochomp'})
151 0 68 unless defined $_
160 25 221 unless $self->{'autochomp'}
161 84 137 unless defined $rec
171 644 1207 if defined $cached
174 23 1184 if ($#{$$self{"offsets"};} < $n)
175 12 11 if $self->{'eof'}
178 6 5 unless defined $o
197 1157 32 if defined $rec and not $self->{'flushing'}
203 0 371 if $DIAGNOSTIC
207 231 140 if ($self->{'autodefer'})
211 71 300 if $self->_is_deferring
220 40 260 unless (defined $oldrec)
239 68 5 if (defined $self->{'deferred_max'} and $n > $self->{'deferred_max'})
245 2 71 if defined $old_deferred
248 1 72 if ($self->{'deferred_s'} > $self->{'dw_size'}) { }
2 70 elsif ($self->_cache_too_full) { }
260 2 4 unless defined $rec
262 4 0 if (defined $self->{'deferred_max'} and $n == $self->{'deferred_max'})
273 568 24 $self->{'eof'} ? :
276 3 589 if defined $top_deferred and $n < $top_deferred + 1
283 16 1 if ($self->{'autodefer'})
288 0 17 if $len == $olen
291 6 11 if ($len > $olen)
292 1 5 if ($self->_is_deferring) { }
303 2 9 if ($self->_is_deferring)
333 1 3 if $size == 0
352 21 10 if ($self->{'autodefer'})
370 2 26 if $self->_is_deferring
379 4 5 if ($self->{'autodefer'})
385 4 5 if $self->_is_deferring
386 4 5 if ($n == $lastrec) { }
4 1 elsif ($n < $lastrec) { }
404 1 10 if exists $self->{'deferred'}{$n}
411 339 54 if ($self->{'autodefer'})
415 1 392 if $self->_is_deferring
416 145 248 if (wantarray) { }
426 2 2984 if $self->_is_deferring
427 2986 0 if defined $self->{'cache'}
428 2985 1 if ($self->{'fh'} and $self->{'ourfh'})
438 7 386 unless defined $pos
444 15 378 unless defined $nrecs
447 73 320 if ($pos < 0)
449 2 71 if ($pos < 0)
455 14 377 if ($pos > $oldsize)
456 6 8 unless @data
461 10 375 if ($nrecs < 0)
463 4 6 if $nrecs < 0
468 33 352 if ($nrecs + $pos > $oldsize)
480 0 512 unless defined $self->_fill_offsets_to($_)
482 0 512 unless defined $rec
492 512 0 if defined $self->{'offsets'}[$_ + 1]
510 194 318 if (defined $new) { }
534 147 94 @result ? :
144 241 wantarray ? :
548 0 179 unless (defined $pos)
554 30 149 if ($len_diff == 0)
587 71 78 if $len_diff < 0
604 0 101 if $c < 0
606 0 101 if $e < $s
627 0 2959 unless @_ % 3 == 0
639 4283 860 if ($len >= $dlen) { }
653 926 4217 if ($delta == 0) { }
3370 847 elsif ($delta < 0) { }
657 1263 2107 if (@_) { }
665 346 501 if (@_) { }
683 0 3424 if ($dpos > $spos) { }
16 3408 elsif ($dpos == $spos) { }
690 771 1091 $len > $blocksize ? :
6103 1862 !defined($len) ? :
698 2121 5844 if ($data eq "")
705 1862 3982 if defined $len
721 375 493 $len > $blocksize ? :
1480 868 !defined($len) ? :
728 680 1668 if ($last_read_was_short) { }
736 5 2343 if $writable eq ""
739 675 1668 if $last_read_was_short and $data eq ""
740 868 800 if defined $len
781 10 858 if $i + 1 > $#{$$self{"offsets"};}
795 567 141 if ($delta)
803 0 708 unless @{$self->{'offsets'};}
818 5 829 unless defined $_
820 828 6 unless substr($_, -$self->{'recseplen'}) eq $self->{'recsep'}
840 0 1378 unless defined $o
842 0 1378 unless seek $self->{'fh'}, $o, 0
849 0 26928 unless seek $self->{'fh'}, $b, 0
858 942 18 if $self->{'eof'}
867 56 13 if (defined $rec) { }
904 0 15140 unless print $fh $rec
916 69 1427 unless defined $rec
917 7 1420 if (substr($rec, -$self->{'recseplen'}) ne $self->{'recsep'})
922 4 3 unless ($self->{'rdonly'})
993 71 78 if $n <= 0
995 56 22 if $n & 8191
1007 0 2 unless (@_ <= 3)
1012 1 1 unless defined $op
1015 1 1 if ($locked and $op & 3)
1030 2 2 if (@_) { }
1043 4 18 if ($#{$$self{"offsets"};} < $n)
1044 3 1 if $self->{'eof'}
1047 1 0 unless defined $o
1115 10 15 unless (defined $end)
1156 4417 147 unless $self->{'defer'}
1162 591 1 if defined $self->{'deferred_max'}
1165 1 0 if $key > $max
1179 2 0 if (@_) { }
1182 1 1 if ($old)
1217 0 611 unless $self->{'autodefer'}
1218 66 545 if $self->{'defer'}
1219 520 25 unless $self->{'offsets'}[-1] >= $self->{'autodefer_filelen_threshhold'}
1222 2 23 if ($n eq 'CLEAR') { }
23 0 elsif ($n =~ /^\d+$/) { }
1226 1 22 if (@H == 0) { }
1229 19 3 if ($H[1] == $n - 1) { }
1231 16 3 if ($H[1] - $H[0] + 1 >= $self->{'autodefer_threshhold'})
1248 5 23 if ($self->{'autodeferring'})
1263 0 2998 if ($^O eq "MSWin32")
1295 0 380 if (not defined $rs) { }
0 380 elsif ($rs eq '') { }
0 380 elsif ($rsl != length $rs) { }
1307 0 380 if (not defined $self->{'offsets'}[0]) { }
0 380 elsif ($self->{'offsets'}[0] != 0) { }
1328 0 2132 if (defined $offset and $offset != $ao)
1332 0 938 if (defined $cached and $_ ne $cached and not $self->{'deferred'}{$n})
1336 0 2132 if (defined $cached and substr($cached, -$rsl) ne $rs)
1340 0 12 if (not defined $offset and $self->{'eof'})
1346 0 380 if (@{$self->{'offsets'};} > $. + 1)
1356 938 0 if $n + 1 <= $.
1361 0 380 if ($cached != $b)
1368 0 380 unless $self->{'cache'}->_check_integrity
1372 0 380 if (not $self->_is_deferring and %{$self->{'deferred'};})
1381 0 87 if (defined $self->{'cache'}->_produce($n))
1385 0 87 if (substr($r, -$rsl) ne $rs)
1392 0 380 if ($deferred_s != $self->{'deferred_s'})
1398 0 380 if ($deferred_s > $self->{'dw_size'})
1405 0 380 if ($deferred_s + $cached > $self->{'memory'})
1413 0 380 if (not $self->{'autodefer'} and @{$self->{'ad_history'};})
1417 0 9 if ($self->{'autodeferring'} and $self->{'defer'})
1421 366 14 if (@{$self->{'ad_history'};} == 0) { }
14 0 elsif (@{$self->{'ad_history'};} == 2) { }
1425 0 14 if (@non_number) { }
0 14 elsif ($self->{'ad_history'}[1] < $self->{'ad_history'}[0]) { }
1466 0 2988 unless defined $max
1491 3154 433 if (defined $n) { }
1501 0 1227 unless defined $key
1502 0 1227 unless (defined $self->[2])
1505 0 1227 unless defined $val
1506 83 1144 if length $val > $self->[2]
1514 0 1144 if (defined $oldnode) { }
1521 21 1123 if $self->[3] > $self->[2]
1527 6 50 unless defined $old_data
1544 99 339 unless exists $self->[1]{$key}
1555 0 1878 unless defined $key
1565 669 1209 if (exists $self->[1]{$key}) { }
1576 1281 1923 unless defined $loc
1604 0 505 unless defined $key
1605 21 484 if (length $val > $self->[2]) { }
449 35 elsif (exists $self->[1]{$key}) { }
1607 0 21 if defined $oldval
1611 449 0 if defined $oldval
1624 0 386 unless defined $nkeys
1625 0 386 unless @$nkeys == @$okeys
1656 0 44 unless defined $old_data
1666 36 490 if $self->[3] > $self->[2]
1682 0 406 unless $self->[0]->_check_integrity
1687 0 1063 if ($k ne 0 and not $k =~ /^[1-9][0-9]*$/)
1693 0 1063 if (not defined $h) { }
0 1063 elsif ($h == 0) { }
1701 0 1063 if (not defined $j) { }
1706 0 1063 if ($k ne $j->[1])
1715 0 406 if ($bytes != $self->[3])
1721 0 406 if ($bytes > $self->[2])
1750 0 2988 unless eval { do { $cache->can("_heap_move") } }
1805 1179 0 unless defined $seq
1824 0 0 unless defined $i
1826 0 0 if ($self->[$i][0] > $item->[0])
1832 0 0 unless defined $$self[2 * $i]
1833 0 0 unless defined $$self[2 * $i + 1]
1834 0 0 unless defined $dir
1848 0 439 unless defined $i
1850 6 433 unless defined $top
1857 433 483 unless defined $self->[$L] or defined $self->[$R]
1858 131 352 unless defined $self->[$L]
1859 194 289 unless defined $self->[$R]
1860 158 325 unless (defined $ii)
1861 112 46 $self->[$L][0] < $self->[$R][0] ? :
1890 1123 746 unless defined $self->[$L] or defined $self->[$R]
1891 87 659 unless defined $self->[$L]
1892 188 558 unless defined $self->[$R]
1893 471 275 unless (defined $dir)
1894 292 179 $self->[$L][0] < $self->[$R][0] ? :
1898 1492 0 if defined $self->[$_]
1946 0 406 unless (eval { do { $self->[0][1]->isa("Tie::File::Cache") } })
1950 0 406 unless $self->_satisfies_heap_condition(1)
1953 0 1933 if (defined $self->[$i] and not defined $self->[$p])
1958 824 1109 if (defined $self->[$i])
1959 0 824 if ($seq{$self->[$i][0]}) { }
1978 1636 824 unless defined $self->[$c]
1979 0 824 if ($self->[$n][0] >= $self->[$c])
1983 0 824 unless $self->_satisfies_heap_condition($c)
1998 4 3 unless defined $self->[$i]