Branch Coverage

blib/lib/Test/MockFile.pm
Criterion Covered Total %
branch 352 512 68.7


line true false branch
200 49 0 unless &Internals::SvREADONLY(\$_[0])
212 0 0 unless ref \$handle eq "GLOB"
279 0 32 unless defined $command and defined $_file_arg_post->{$command}
282 2 18 if $command eq "open" and ref $at_under_ref and scalar @$at_under_ref == 2
294 0 119 unless scalar @stack
295 0 119 unless defined $stack[0]
297 66 53 if $stack[0] eq "Test::MockFile"
298 20 33 if $stack[0] eq "Overload::FileCheck"
300 1 32 if $authorized_strict_mode_packages{$stack[0]}
366 0 11 unless defined $command_rule
369 0 11 unless defined $action
371 1 10 ref $command_rule eq 'ARRAY' ? :
372 2 9 ref $file_rule eq 'ARRAY' ? :
376 12 3 ref $c_rule eq 'Regexp' ? :
9 6 ref $f_rule eq 'Regexp' || !defined($f_rule) ? :
498 33 51 $STRICT_MODE_STATUS & 2 ? :
504 51 33 unless is_strict_mode()
507 0 33 if grep {$command eq $_;} "readdir", "telldir", "rewinddir", "seekdir", "closedir"
510 1 32 unless scalar @stack
517 32 0 if ($file_arg >= 0)
518 0 32 scalar @$at_under_ref <= $file_arg ? :
522 1 31 if defined $filename and $filename =~ /^\*?(?:main::)?[<*&+>]*STD(?:OUT|IN|ERR)$/
526 0 31 if UNIVERSAL::isa($filename, "GLOB")
529 0 19 if $command eq "open" and $at_under_ref->[1] and $at_under_ref->[1] =~ /&/
540 15 16 if $pass
542 0 16 if $file_arg == -1
556 14 8 if (defined $rule->{'file_rule'})
557 5 9 unless defined $context->{'filename'} and $context->{'filename'} =~ /$rule->{'file_rule'}/
561 1 16 unless $context->{'command'} =~ /$rule->{'command_rule'}/
564 4 12 ref $rule->{'action'} ? :
566 15 1 if defined $answer
580 18 13 grep({$_ eq 'nostrict';} @args) ? :
582 0 31 if (defined $STRICT_MODE_STATUS and not $STRICT_MODE_STATUS & 4 and $STRICT_MODE_STATUS != $strict_mode)
594 21 0 unless defined $opt and $opt eq "plugin"
631 0 70 unless defined $file and length $file
632 0 70 if _is_path_mocked($file)
637 0 67 if (@stats > 1)
644 0 67 if not defined $contents and @stats
648 1 66 if (@stats)
649 0 1 unless ref $stats[0] eq "HASH"
655 1 66 defined $stats{'mode'} ? :
662 7 40 if (defined $contents and $files_being_mocked{$dirname})
693 0 1 unless (open $fh, "<", $file_on_disk)
727 0 12 unless defined $file and length $file
728 0 12 unless not defined $readlink or length $readlink
730 0 12 if _is_path_mocked($file)
736 4 8 if ($files_being_mocked{$dirname})
755 5 222 if ($path =~ m[ ( ^ | / ) \.{2} ( / | $ ) ]msx)
822 0 46 unless defined $dirname and length $dirname
823 0 46 if _is_path_mocked($dirname)
829 44 0 if $path ne "/"
832 5 39 if @_ > 2
876 4 3 $opts ? :
877 1 1 if (ref $opts eq "HASH" and $opts->{'mode'})
881 1 0 if (keys %{$opts;} == 0)
887 1 3 if ($mode) { }
940 118 0 if (scalar @_ == 1 and ref $_[0]) { }
0 0 elsif (scalar @_ % 2) { }
950 0 118 unless my $path = $opts{'path'}
952 0 118 unless ($path =~ m[^/])
983 0 366 unless exists $self->{$key}
1001 1 100 unless $type
1003 6 1 $type eq 'lstat' ? :
93 7 $type eq 'stat' ? :
1009 0 99 if (scalar @_ != 2)
1015 2 97 unless (defined $file_or_fh and length $file_or_fh)
1023 1 96 if defined $file and defined bless( {}, 'A::BROKEN::SYMLINK' ) and $file eq bless( {}, 'A::BROKEN::SYMLINK' )
1024 1 95 if defined $file and defined bless( {}, 'A::CIRCULAR::SYMLINK' ) and $file eq bless( {}, 'A::CIRCULAR::SYMLINK' )
1026 0 95 unless (defined $file and length $file)
1032 17 78 unless ($file_data)
1033 16 1 unless ref $file_or_fh
1038 24 53 unless $file_data->is_link or defined $file_data->contents
1046 0 128 unless my $absolute_path_to_file = _find_file_or_fh($file_path)
1048 0 128 $files_being_mocked{$absolute_path_to_file} ? :
1054 0 312 unless my $file = _find_file_or_fh($file_path)
1067 625 0 if $absolute_path_to_file ne "/"
1074 2 623 if $depth and not $mock_object
1077 589 34 unless $mock_object and $mock_object->is_link
1084 7 27 unless $follow_link
1090 2 25 if ($depth > 10)
1103 2 631 unless defined $fh and length $fh
1109 1104 57 unless $mock_fh
1110 13 44 unless "$mock_fh" eq "$fh"
1131 1 740 unless defined $path
1136 21 770 if $path =~ s[//+][/]gmsx
1137 8 783 if $path =~ s[/\.$][/]
1138 11 780 if $path =~ s[(?:[^/]+)/\.\.(/|$)][$1]
1139 35 756 if $path =~ s[/$][]
1142 1 739 if $path eq "/.."
1144 680 59 if $path =~ m[^/]msx
1149 0 59 if ($path =~ m[ ^(~ ([^/]+)? ) ]msx)
1158 0 0 if ($pwdata[0] eq $username)
1166 0 0 unless $pw_homedir
1175 0 59 if $path eq "."
1181 0 118 unless ref $self
1186 0 118 unless defined $path
1191 118 0 if (defined $files_being_mocked{$path})
1192 0 118 unless $self == $files_being_mocked{$path}
1214 0 270 unless $self
1216 0 270 if $self->is_link
1220 141 129 if ($self->is_dir)
1221 0 141 if $new_contents
1224 15 126 unless $self->{'has_content'}
1238 66 6 defined $_->{'contents'} || $_->is_link || $_->is_dir ? :
1247 129 0 if ($self->is_file)
1248 12 117 if (defined $new_contents)
1249 0 12 if ref $new_contents
1282 0 214 unless $self
1295 0 9 unless $self
1297 1 8 unless ($self->exists)
1302 2 6 if ($self->is_dir)
1303 0 2 if ($] < 5.019 and $^O eq 'darwin' || $^O =~ /bsd/i) { }
1312 1 5 if ($self->is_link) { }
1336 0 6 unless $self
1339 2 4 unless $self->is_file
1343 2 2 unless (defined $pre_size)
1398 0 27 unless $self->is_link
1400 0 27 if (scalar @_ == 2)
1401 0 0 if (defined $readlink and ref $readlink)
1420 78 952 defined $self->{'readlink'} && length $self->{'readlink'} && $self->{'mode'} & 40960 ? :
1432 204 142 ($self->{'mode'} & 61440) == 16384 ? :
1444 219 62 ($self->{'mode'} & 61440) == 32768 ? :
1457 2 111 if $self->is_link
1460 0 111 if ($] < "5.012")
1461 0 0 unless $self->exists
1477 3 0 defined $self->{'readlink'} ? :
3 138 if $self->is_link
1480 70 15 defined $self->{'contents'} ? :
85 53 if $self->is_file
1483 23 29 $self->{'has_content'} ? :
52 1 if $self->is_dir
1498 0 54 if (int $blocks > $blocks)
1548 5 0 if (scalar @_ == 2 and defined $time and $time =~ /^[0-9]+$/)
1567 5 0 if (@_ == 2 and defined $time and $time =~ /^[0-9]+$/)
1586 5 0 if (@_ == 2 and defined $time and $time =~ /^[0-9]+$/)
1620 0 0 unless $code_ref and ref $code_ref eq "CODE"
1717 2 55 if $] < "5.015"
1718 3 52 if $] < "5.021"
1719 2 50 if $] > "5.027"
1736 25 25 m[^(.+)/[^/]+$]msx ? :
1748 0 59 if (defined $_[0] and not ref $_[0])
1761 10 49 if ($arg_count == 2)
1764 7 3 if ($_[1] =~ /^ ( >> | [+]?> | [+]?< ) (.+) $/msx) { }
1 2 elsif ($_[1] =~ m[^[\./\\\w\d\-]+$]msx) { }
1 1 elsif ($_[1] =~ /^\|/msx) { }
1 0 elsif ($_[1] =~ /\|$/msx) { }
1789 0 59 if ($arg_count != 3)
1791 0 0 if _goto_is_available()
1792 0 0 if (@_ == 1) { }
0 0 elsif (@_ == 2) { }
0 0 elsif (@_ >= 3) { }
1804 0 59 if (ref $file and ref $file eq "SCALAR")
1805 0 0 if _goto_is_available()
1810 0 0 if not $abs_path and $mode ne "|-" and $mode ne "-|"
1811 0 59 if $abs_path eq bless( {}, 'A::BROKEN::SYMLINK' )
1821 27 28 if ($mode eq "|-" or $mode eq "-|" or not grep({$_ eq $mode;} ">", "<", ">>", "+<", "+>", "+>>") or not defined $mock_file)
1825 0 23 if _goto_is_available()
1826 0 23 if (@_ == 1) { }
3 20 elsif (@_ == 2) { }
20 0 elsif (@_ >= 3) { }
1840 3 25 if (not defined $mock_file->contents and grep {$mode eq $_;} "<", "+<")
1846 18 7 if grep {$_ eq $mode;} "+<", "+>", "+>>", "<"
1847 11 14 if grep {$_ eq $mode;} "+<", "+>", "+>>", ">", ">>"
1852 0 25 if ($likely_bareword) { }
1856 0 0 $_[1] ? :
1865 25 0 if ref $_[0]
1868 2 23 if ($mode eq '>>' or $mode eq '+>>') { }
7 16 elsif ($mode eq '>' or $mode eq '+>') { }
1895 4 3 unless ($mock_file)
1897 0 3 if _goto_is_available()
1904 0 3 if (($sysopen_mode & 132803) != $sysopen_mode)
1909 0 3 if (($sysopen_mode & 131072) == 131072 and $mock_file->is_link)
1915 0 1 if ($sysopen_mode & 128 and $sysopen_mode & 64 and defined $mock_file->{'contents'})
1921 1 2 if ($sysopen_mode & 64 and not defined $mock_file->{'contents'})
1926 1 2 if ($sysopen_mode & 512 and defined $mock_file->{'contents'})
1932 0 0 $rd_wr_mode == 2 ? :
1 0 $rd_wr_mode == 1 ? :
2 1 $rd_wr_mode == 0 ? :
1939 0 3 if (not defined $mock_file->{'contents'} and $rd_wr_mode == 0)
1951 3 0 if ref $_[0]
1954 1 2 if ($sysopen_mode & 512)
1959 0 3 if ($sysopen_mode & 1024)
1969 1 23 if defined $_[0] and not ref $_[9]
1974 0 24 if (scalar @_ != 2 or not defined $_[1])
1977 0 0 if _goto_is_available()
1982 10 14 unless ($mock_dir)
1984 0 7 if _goto_is_available()
1988 0 14 unless (defined $mock_dir->contents)
1993 1 13 unless ($mock_dir->{'mode'} & 16384)
1998 12 1 if (not defined $_[0]) { }
1 0 elsif (ref $_[0]) { }
2018 28 0 if defined $_[0] and not ref $_[9]
2022 6 22 unless ($mocked_dir)
2024 0 6 if _goto_is_available()
2029 0 22 unless ($obj)
2033 0 22 unless (defined $obj->{'files_in_readdir'})
2037 0 22 unless (defined $obj->{'tell'})
2042 4 18 if $obj->{'tell'} > $#{$$obj{"files_in_readdir"};}
2044 14 4 if (wantarray)
2059 4 0 if defined $_[0] and not ref $_[9]
2064 0 4 unless ($mocked_dir and $mocked_dir->{'obj'})
2066 0 0 if _goto_is_available()
2072 0 4 unless (defined $obj->{'files_in_readdir'})
2076 0 4 unless (defined $obj->{'tell'})
2086 1 0 if defined $_[0] and not ref $_[9]
2091 0 1 unless ($mocked_dir and $mocked_dir->{'obj'})
2093 0 0 if _goto_is_available()
2099 0 1 unless (defined $obj->{'files_in_readdir'})
2103 0 1 unless (defined $obj->{'tell'})
2114 1 0 if defined $_[0] and not ref $_[9]
2119 0 1 unless ($mocked_dir and $mocked_dir->{'obj'})
2121 0 0 if _goto_is_available()
2127 0 1 unless (defined $obj->{'files_in_readdir'})
2131 0 1 unless (defined $obj->{'tell'})
2141 14 0 if defined $_[0] and not ref $_[9]
2146 1 13 unless ($mocked_dir and $mocked_dir->{'obj'})
2148 0 1 if _goto_is_available()
2165 7 4 if (not $mock) { }
2181 2 5 unless (defined $file)
2183 0 2 if ($^O eq 'freebsd') { }
2193 1 4 unless ($mock_object)
2195 0 1 if _goto_is_available()
2199 2 2 unless ($mock_object->is_link)
2212 1 27 unless (defined $file)
2222 2 25 unless ($mock)
2224 0 2 if _goto_is_available()
2229 6 19 if ($mock->exists)
2251 1 13 unless (defined $file)
2258 4 9 unless ($mock)
2260 0 4 if _goto_is_available()
2266 8 1 if ($mock->exists)
2267 1 7 if ($mock->is_file)
2272 1 6 if ($mock->is_link)
2278 1 6 unless ($mock->exists)
2283 1 5 if (_files_in_dir($file))
2295 0 13 if $^O eq "MSWin32"
2300 0 13 unless @files
2304 13 1 ref $_ ? :
2308 1 12 if (@mocked_files and @mocked_files != @files)
2317 2 10 if $uid == -1
2318 2 10 if $gid == -1
2333 0 12 unless ($mock)
2335 0 0 if _goto_is_available()
2340 1 11 unless ($mock->exists)
2343 1 0 unless $set_error
2351 0 11 unless ($is_root)
2352 0 0 if ($> != $uid or not $is_in_group)
2353 0 0 unless $set_error
2374 0 6 unless @files
2380 1 5 unless $mode =~ /^[0-9]+/msx
2387 8 1 ref $_ ? :
2391 1 5 if (@mocked_files and @mocked_files != @files)
2403 0 7 unless ($mock)
2405 0 0 if _goto_is_available()
2411 0 7 unless ($mock->exists)
2430 0 34 !$^V || $^V lt 5.18.0 ? :