Branch Coverage

blib/lib/Path/Tiny.pm
Criterion Covered Total %
branch 405 486 83.3


line true false branch
79 0 0 unless defined $dcwd and length $dcwd
104 2365 1 if ($clause =~ /\A([augo]+)([=+-])([rwx]+)\z/) { }
110 2081 5310 if ($action eq '=') { }
114 2605 2705 $action eq '+' ? :
138 0 26 if ($function =~ /^flock/ and $! =~ /operation not supported|function not implemented/i and not warnings::fatal_enabled('flock')) { }
142 0 0 unless ($WARNED_NO_FLOCK)
148 10 16 unless defined $msg
149 8 18 defined $file ? :
158 6 1430 if (defined $raw and ref $raw ne "HASH")
165 1054 1350 if exists $raw->{$k}
167 8 1422 if (keys %$raw)
225 324 2 if defined $_
5 289 unless 1 + @_ == grep({length $_ if defined $_;} $path, @_)
228 4 266 if (not @_ and ref $path eq __PACKAGE__ and not $path->[5])
237 28 257 if (defined $tilde)
242 28 0 if (defined $homedir and not $File::Glob::ERROR)
256 2416 0 if defined $_
0 1688 unless 1 + @_ == grep({length $_ if defined $_;} $path, @_)
259 118 974 if (not @_ and ref $path eq __PACKAGE__ and not $path->[5])
282 615 1240 if (@_)
283 5 610 _is_root($path) ? :
290 0 1855 if $path eq "/.."
294 57 1798 if (_is_root($path)) { }
432 6 181 if @$maybe_template
437 1 186 $opts->{'realpath'} ? :
448 1 21 $opts->{'realpath'} ? :
460 202 7 if (@_ and $_[0] eq 'Path::Tiny') { }
5 2 elsif (@_ and eval { do { $_[0]->isa('Path::Tiny') } }) { }
463 0 5 unless ($dir->is_dir)
468 2 207 @_ && ref $_[0] eq 'HASH' ? :
471 5 204 scalar(@_) % 2 == 1 ? :
476 5 198 $leading_template ? :
6 203 exists $args{'TEMPLATE'} ? :
497 1 11 if ($seen{$new->[0]}++)
500 0 11 if (++$count > 100)
504 0 11 unless defined $resolved
506 7 4 $resolved->is_absolute ? :
519 1 145 if (length $temp->basename > 255)
567 210 70 if $self->is_absolute
572 64 6 unless defined $base
578 6 0 $base->is_absolute ? :
616 26 21 @data && ref $data[0] eq 'HASH' ? :
619 24 22 unless defined $binmode
620 9 37 $args->{'truncate'} ? :
622 3 88 if (ref $_ eq 'ARRAY') { }
0 46 unless print {$fh;} map({ref $_ eq "ARRAY" ? @$_ : $_;} @data)
623 0 46 unless close $fh
628 3 6 @data && ref $data[0] eq 'HASH' ? :
636 3 6 @data && ref $data[0] eq 'HASH' ? :
638 9 0 defined $HAS_UU ? :
6 0 defined $HAS_PU ? :
3 6 if (defined $HAS_UU ? $HAS_UU : ($HAS_UU = _check_UU())) { }
3 3 elsif (defined $HAS_PU ? $HAS_PU : ($HAS_PU = _check_PU())) { }
669 0 2 unless $assertion
670 2 0 if (ref $assertion eq 'CODE') { }
672 1 1 unless &$assertion()
700 160 9 unless defined $self->[4]
703 4 4 ref $s eq 'Regexp' ? :
704 5 3 if $file =~ s/$re//
739 1 2 unless defined $self->[5]
789 0 9 unless opendir $dh, $self->[0]
791 0 9 unless closedir $dh
793 7 2 if (not defined $filter) { }
1 1 elsif ($filter and ref $filter eq 'Regexp') { }
794 18 7 if $_ ne "."
797 3 2 if $_ ne "." and $_ ne ".."
831 3 3 if ($new_mode =~ /\d/) { }
2 1 elsif ($new_mode =~ /[=+-]/) { }
832 2 1 $new_mode =~ /^0/ ? :
841 1 3 unless CORE::chmod $mode, $self->[0]
862 0 2 unless File::Copy::copy($self->[0], $dest)
865 1 1 -d $dest ? :
888 2 4 @opts && ref $opts[0] eq 'HASH' ? :
890 3 3 unless @opts
893 2 4 if ($args->{'chunk_size'}) { }
898 0 10 unless defined $rc
927 439 360 unless defined $self->[3]
928 717 82 length $self->[3] ? :
957 0 6 unless defined $cb and ref $cb eq "CODE"
961 6 0 exists $args->{'binmode'} ? :
971 0 3 unless defined $cb and ref $cb eq "CODE"
1015 0 9 unless defined $cb and ref $cb eq "CODE"
1020 0 9 unless defined $binmode
1032 0 36 unless defined($_ = readline $in_fh)
1034 0 36 unless $temp_fh->print($_)
1037 0 9 unless close $temp_fh
1038 0 9 unless close $in_fh
1046 3 0 defined $HAS_PU ? :
2 1 if (defined $HAS_PU ? $HAS_PU : ($HAS_PU = _check_PU())) { }
1076 17 15 if -e $_[0][0]
1112 554 1 @args && ref $args[0] eq 'HASH' ? :
1114 146 409 if $args->{'exclusive'}
1117 1 554 unless defined $opentype
1119 0 555 unless grep {$opentype eq $_;} "<", "+<", ">", "+>", ">>", "+>>"
1121 233 322 unless defined $binmode
1123 233 322 unless defined $binmode
1126 448 107 if ($HAS_FLOCK and $args->{'locked'} and not $ENV{'PERL_PATH_TINY_NO_FLOCK'})
1129 155 293 if (grep {$opentype eq $_;} '>', '+>') { }
0 293 elsif ($^O eq 'aix' and $opentype eq '<') { }
1131 155 0 $opentype eq '>' ? :
1133 145 10 if $args->{'exclusive'}
1134 1 154 unless sysopen $fh, $self->[0], $flags
1138 67 87 if ($binmode =~ s/^:unix//)
1140 0 67 unless binmode $fh, ":raw"
1143 0 67 unless binmode $fh, ":pop"
1148 46 108 if (length $binmode)
1149 0 46 unless binmode $fh, $binmode
1161 0 0 if (-w $self->[0])
1167 256 37 $opentype eq '<' ? :
1171 400 154 unless ($fh)
1173 3 397 unless open $fh, $mode, $self->[0]
1176 0 444 unless flock $fh, $lock
444 107 if ($lock)
1177 0 154 unless truncate $fh, 0
154 397 if ($trunc)
1207 3 6 if (-d $fh1)
1210 1 5 if (-d $fh2)
1216 3 2 if ($self->realpath eq $other->realpath)
1223 0 2 if ($res < 0)
1266 4 160 unless defined $self->[3]
1315 75 275 if (ref $dirs[0] eq "Path::Tiny")
1316 1 74 unless (-r $dirs[0])
1323 1 0 if shift @dirs
1327 0 74 unless opendir $dh, $current->[0]
1330 0 74 if (-l $current->[0] and not $args->{'follow_symlinks'})
1335 0 0 if shift @dirs
1339 148 277 if $next eq "." or $next eq ".."
1342 57 130 if $args->{'recurse'} and -d $path and not !$args->{'follow_symlinks'} && -l $path
1398 62 48 unless defined $binmode
1402 84 26 if ($args->{'count'}) { }
6 20 elsif ($chomp) { }
1406 0 216 unless defined($line = readline $fh)
1408 63 153 if $chomp
1411 36 180 if $counter == $args->{'count'}
1416 3 81 if @result == $mod and $counter % $mod
1423 0 6 if $!
1427 14 6 if (wantarray) { }
1430 0 14 if $!
1435 0 6 if $!
1444 0 15 if ($args->{'chomp'} and not $args->{'count'}) { }
1458 33 0 defined $HAS_UU ? :
30 1 defined $HAS_PU ? :
2 31 if (defined $HAS_UU ? $HAS_UU : ($HAS_UU = _check_UU()) and $args->{'chomp'} and not $args->{'count'}) { }
20 11 elsif (defined $HAS_PU ? $HAS_PU : ($HAS_PU = _check_PU())) { }
1499 48 5 unless defined $args
1500 4 49 if (@rest or defined $args and ref $args ne "HASH")
1506 49 0 unless defined $args->{'error'}
1513 0 49 unless ($ok)
1516 0 49 if ($err and @$err)
1538 1 5 unless defined $args
1539 4 2 if (@rest or defined $args and ref $args ne "HASH")
1544 2 0 unless defined $args->{'error'}
1547 0 2 if ($err and @$err)
1581 1 148 unless File::Copy::move($self->[0], $dest)
1584 1 147 -d $dest ? :
1636 2 68 @args && ref $args[0] eq 'HASH' ? :
1639 69 1 unless defined $binmode
1645 21 18 @args && ref $args[0] eq 'HASH' ? :
1651 0 18 @args && ref $args[0] eq 'HASH' ? :
1654 18 0 defined $HAS_PU ? :
12 6 if (defined $HAS_PU ? $HAS_PU : ($HAS_PU = _check_PU())) { }
1684 190 168 unless defined $level and $level > 0
1685 162 196 unless defined $self->[4]
1687 316 42 if (length $self->[4]) { }
42 0 elsif (length $self->[3]) { }
1688 58 258 if ($self->[4] eq '.' or $self->[4] eq '..') { }
1698 35 7 if ($self->[3] =~ m[(?:^\.\./|/\.\./|/\.\.\z)]) { }
1709 274 84 $level == 1 ? :
1714 203 55 defined $string && length $string ? :
1751 19 13 unless defined $self->[4]
1757 28 4 $check_parent ? :
1760 1 31 unless defined $realpath and length $realpath and -e $realpath
1762 27 4 $check_parent ? :
1810 69 3 defined $base && length $base ? :
1813 22 50 if $self->is_relative
1814 24 48 if $base->is_relative
1817 0 72 if not length $self->volume and length $base->volume
1818 0 72 if length $self->volume and not length $base->volume
1821 0 72 unless (_same($self->volume, $base->volume))
1826 6 66 if _same($self->[0], $base->[0])
1829 20 46 if ($base->subsumes($self))
1830 2 18 if $base->is_rootdir
1842 6 40 if ($self->is_rootdir) { }
1860 6 40 if (my $new_base = $self->_resolve_between(\@common, \@base_parts))
1873 87 0 unless length $self_vol
1886 4 137 if ($p eq "..")
1888 2 2 if (-e $path) { }
1895 2 139 if (-l $path)
1900 6 40 $changed ? :
1918 1 1 unless -e $self->[0] or -l $self->[0]
1950 21 2 unless defined $args
1951 1 22 if (@rest or defined $args and ref $args ne "HASH")
1955 2 1 unless -e $self->[0] or -l $self->[0]
1958 20 0 unless defined $args->{'error'}
1959 19 1 unless defined $args->{'safe'}
1963 0 20 if ($err and @$err)
2027 4 3 defined $args->{'format'} ? :
2028 1 6 unless my $fmt_opts = $formats{$format}
2031 5 1 defined $size ? :
2035 34 58 $_[0] == int $_[0] ? :
2040 3 95 if $size == 0
2044 65 27 length int $size == 1 ? :
3 92 $mag == 0 ? :
2048 9 86 if ($size >= $base)
2053 27 68 $mag == 0 || length int $size > 1 ? :
2095 44 70 unless defined $binmode
2097 76 37 defined $binmode ? :
41 72 if ((defined $binmode ? $binmode : '') eq ':unix' and my $size = -s $fh) { }
2102 0 41 unless defined $rc
2108 0 72 unless defined $buf
2116 26 1 defined $HAS_UU ? :
16 1 defined $HAS_PU ? :
10 17 if (defined $HAS_UU ? $HAS_UU : ($HAS_UU = _check_UU())) { }
8 9 elsif (defined $HAS_PU ? $HAS_PU : ($HAS_PU = _check_PU())) { }
2162 69 69 @data && ref $data[0] eq 'HASH' ? :
2166 69 68 unless defined $binmode
2175 1 136 unless ($ok)
2176 1 0 ref $@ eq 'Path::Tiny::Error' ? :
2181 5 259 if (ref $_ eq 'ARRAY') { }
0 136 unless print {$fh;} map({ref $_ eq "ARRAY" ? @$_ : $_;} @data)
2182 0 136 unless close $fh
2190 30 3 defined $HAS_UU ? :
20 2 defined $HAS_PU ? :
11 22 if (defined $HAS_UU ? $HAS_UU : ($HAS_UU = _check_UU())) { }
11 11 elsif (defined $HAS_PU ? $HAS_PU : ($HAS_PU = _check_PU())) { }
2195 1 28 if (ref $_ eq 'ARRAY') { }
2244 22 2671 if ($_[0][0] =~ /^~/) { }
2271 0 96 unless defined $_[0]
2276 3 93 if ($self->is_absolute and not $other->is_absolute) { }
2 105 elsif ($other->is_absolute and not $self->is_absolute) { }
2285 0 96 if (length $self->volume and not length $other->volume) { }
0 192 elsif (length $other->volume and not length $self->volume) { }
2292 2 94 if ($self->[0] eq '.') { }
4 90 elsif ($self->is_rootdir) { }
2325 25 2 unless (-e $self->[0])
2327 0 25 unless close $fh
2329 1 26 if (defined $epoch) { }
2330 0 1 unless utime $epoch, $epoch, $self->[0]
2335 0 26 unless utime undef, undef, $self->[0]
2359 9 7 unless $parent->exists
2416 0 12 unless defined $cb and ref $cb eq "CODE"
2423 2 236 if ref $r eq "SCALAR" and not $$r
2444 53 634 unless defined $self->[2]