Branch Coverage

blib/lib/Path/Tiny.pm
Criterion Covered Total %
branch 390 476 81.9


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 16 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 6 unless defined $msg
149 7 9 defined $file ? :
158 6 1429 if (defined $raw and ref $raw ne "HASH")
165 1054 1349 if exists $raw->{$k}
167 8 1421 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 "Path::Tiny" and not $path->[5])
237 28 257 if (defined $tilde)
242 28 0 if (defined $homedir and not $File::Glob::ERROR)
256 2409 0 if defined $_
0 1684 unless 1 + @_ == grep({length $_ if defined $_;} $path, @_)
259 118 973 if (not @_ and ref $path eq "Path::Tiny" and not $path->[5])
282 612 1239 if (@_)
283 5 607 _is_root($path) ? :
290 0 1851 if $path eq "/.."
294 57 1794 if (_is_root($path)) { }
432 6 181 if @$maybe_template
437 1 186 $opts->{'realpath'} ? :
448 1 20 $opts->{'realpath'} ? :
460 201 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 206 @_ && ref $_[0] eq 'HASH' ? :
471 5 203 scalar(@_) % 2 == 1 ? :
476 5 197 $leading_template ? :
6 202 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 209 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 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())) { }
0 6 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 438 360 unless defined $self->[3]
928 716 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 ? :
0 3 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 74 273 if (ref $dirs[0] eq "Path::Tiny")
1316 1 73 unless (-r $dirs[0])
1323 1 0 if shift @dirs
1327 0 73 unless opendir $dh, $current->[0]
1330 0 73 if (-l $current->[0] and not $args->{'follow_symlinks'})
1335 0 0 if shift @dirs
1339 142 275 if $next eq "." or $next eq ".."
1342 57 128 if $args->{'recurse'} and -d $path and not !$args->{'follow_symlinks'} && -l $path
1396 62 48 unless defined $binmode
1400 84 26 if ($args->{'count'}) { }
6 20 elsif ($chomp) { }
1404 0 216 unless defined($line = readline $fh)
1406 63 153 if $chomp
1409 36 180 if $counter == $args->{'count'}
1414 3 81 if @result == $mod and $counter % $mod
1421 0 6 if $!
1425 14 6 if (wantarray) { }
1428 0 14 if $!
1433 0 6 if $!
1442 0 15 if ($args->{'chomp'} and not $args->{'count'}) { }
1456 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'}) { }
0 31 elsif (defined $HAS_PU ? $HAS_PU : ($HAS_PU = _check_PU())) { }
1493 47 1 unless ref $args eq "HASH"
1495 48 0 unless defined $args->{'error'}
1502 0 48 unless ($ok)
1505 0 48 if ($err and @$err)
1523 1 1 unless ref $args eq "HASH"
1525 2 0 unless defined $args->{'error'}
1528 0 2 if ($err and @$err)
1562 1 148 unless File::Copy::move($self->[0], $dest)
1565 1 147 -d $dest ? :
1617 2 68 @args && ref $args[0] eq 'HASH' ? :
1620 69 1 unless defined $binmode
1626 21 18 @args && ref $args[0] eq 'HASH' ? :
1632 0 18 @args && ref $args[0] eq 'HASH' ? :
1635 18 0 defined $HAS_PU ? :
0 18 if (defined $HAS_PU ? $HAS_PU : ($HAS_PU = _check_PU())) { }
1665 190 168 unless defined $level and $level > 0
1666 162 196 unless defined $self->[4]
1668 316 42 if (length $self->[4]) { }
42 0 elsif (length $self->[3]) { }
1669 58 258 if ($self->[4] eq '.' or $self->[4] eq '..') { }
1679 35 7 if ($self->[3] =~ m[(?:^\.\./|/\.\./|/\.\.\z)]) { }
1690 274 84 $level == 1 ? :
1695 203 55 defined $string && length $string ? :
1732 19 13 unless defined $self->[4]
1738 28 4 $check_parent ? :
1741 1 31 unless defined $realpath and length $realpath and -e $realpath
1743 27 4 $check_parent ? :
1791 69 3 defined $base && length $base ? :
1794 22 50 if $self->is_relative
1795 24 48 if $base->is_relative
1798 0 72 if not length $self->volume and length $base->volume
1799 0 72 if length $self->volume and not length $base->volume
1802 0 72 unless (_same($self->volume, $base->volume))
1807 6 66 if _same($self->[0], $base->[0])
1810 20 46 if ($base->subsumes($self))
1811 2 18 if $base->is_rootdir
1823 6 40 if ($self->is_rootdir) { }
1841 6 40 if (my $new_base = $self->_resolve_between(\@common, \@base_parts))
1854 87 0 unless length $self_vol
1867 4 137 if ($p eq "..")
1869 2 2 if (-e $path) { }
1876 2 139 if (-l $path)
1881 6 40 $changed ? :
1899 1 1 unless -e $self->[0] or -l $self->[0]
1927 2 1 unless -e $self->[0] or -l $self->[0]
1928 19 1 unless ref $args eq "HASH"
1930 20 0 unless defined $args->{'error'}
1931 19 1 unless defined $args->{'safe'}
1935 0 20 if ($err and @$err)
1999 4 3 defined $args->{'format'} ? :
2000 1 6 unless my $fmt_opts = $formats{$format}
2003 5 1 defined $size ? :
2007 34 58 $_[0] == int $_[0] ? :
2012 3 95 if $size == 0
2016 65 27 length int $size == 1 ? :
3 92 $mag == 0 ? :
2020 9 86 if ($size >= $base)
2025 27 68 $mag == 0 || length int $size > 1 ? :
2065 44 70 unless defined $binmode
2067 76 37 defined $binmode ? :
41 72 if ((defined $binmode ? $binmode : '') eq ':unix' and my $size = -s $fh) { }
2072 0 41 unless defined $rc
2078 0 72 unless defined $buf
2086 26 1 defined $HAS_UU ? :
16 1 defined $HAS_PU ? :
10 17 if (defined $HAS_UU ? $HAS_UU : ($HAS_UU = _check_UU())) { }
0 17 elsif (defined $HAS_PU ? $HAS_PU : ($HAS_PU = _check_PU())) { }
2132 69 69 @data && ref $data[0] eq 'HASH' ? :
2136 69 68 unless defined $binmode
2144 5 259 ref $_ eq 'ARRAY' ? :
0 136 unless print {$fh;} map({ref $_ eq "ARRAY" ? @$_ : $_;} @data)
2145 0 136 unless close $fh
2153 30 3 defined $HAS_UU ? :
20 2 defined $HAS_PU ? :
11 22 if (defined $HAS_UU ? $HAS_UU : ($HAS_UU = _check_UU())) { }
0 22 elsif (defined $HAS_PU ? $HAS_PU : ($HAS_PU = _check_PU())) { }
2158 1 28 ref $_ eq 'ARRAY' ? :
2207 22 2663 $_[0][0] =~ /^~/ ? :
2234 0 96 unless defined $_[0]
2239 3 93 if ($self->is_absolute and not $other->is_absolute) { }
2 105 elsif ($other->is_absolute and not $self->is_absolute) { }
2248 0 96 if (length $self->volume and not length $other->volume) { }
0 192 elsif (length $other->volume and not length $self->volume) { }
2255 2 94 if ($self->[0] eq '.') { }
4 90 elsif ($self->is_rootdir) { }
2288 25 2 unless (-e $self->[0])
2290 0 25 unless close $fh
2292 1 26 if (defined $epoch) { }
2293 0 1 unless utime $epoch, $epoch, $self->[0]
2298 0 26 unless utime undef, undef, $self->[0]
2322 9 7 unless $parent->exists
2379 0 12 unless defined $cb and ref $cb eq "CODE"
2386 2 234 if ref $r eq "SCALAR" and not $$r
2407 53 634 unless defined $self->[2]