Readlink/Perl510.pm

filter: Statementstmt 66.6% 22 / 33 Branchbran 10.0% 1 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 87.5% 7 / 8 Podpod 100% 1 / 1 totaltotal 50.8% 31 / 61 CC 7 SCAR 32.5
CC
7
Cov
47%
readlink
50.4
__ANON__
1.1
BEGIN
1.0
CRAP 25.7
« Readlink/Perl58.pm ↑ Summary Readlink.pm »
1 package
2 Win32::Shortcut::Readlink;
3  
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Carp qw( carp );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use constant _is_cygwin => $^O eq 'cygwin';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use constant _is_mswin32 => $^O eq 'MSWin32';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use constant _is_windows => _is_cygwin || _is_mswin32;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub _real_readlink (_);
12 # TODO: only warn in 5.14 or earlier if warnings on in caller
13 0 ▶*_real_readlink = eval { require 5.016000 } ? \&CORE::readlink : sub (_) { CORE::readlink($_[0]) };
Subroutine __ANON__: not called CC=1 SCAR=0.6
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require 5.016 } } ? : 2 0 2
14  
15 sub readlink (_)
16 15 ▶{
Subroutine readlink: called CC=7 SCAR=39.2
Pod documented
17 15 goto &_real_readlink unless _is_windows;
18
19 0 ▶ if(defined $_[0] && $_[0] =~ /\.lnk$/ && -r $_[0])
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0] and $_[0] =~ /\.lnk$/ and -r $_[0]) 0 0 0
Condition0%0/6
defined $_[0] and $_[0] =~ /\.lnk$/ and -r $_[0]
!ll&&!rl&&r
000
defined $_[0] and $_[0] =~ /\.lnk$/
!ll&&!rl&&r
000
MC/DC0%0/3
defined $_[0] and $_[0] =~ /\.lnk$/ and -r $_[0]
defined $_[0] $_[0] =~ /\.lnk$/ -r $_[0]
Truth table0%0/4
A and B and C
A= defined $_[0]B= $_[0] =~ /\.lnk$/C= -r $_[0]
ABCresult
0XX0
10X0
1100
1111
20 {
21 0 my $target = _win32_resolve(_is_cygwin ? Cygwin::posix_to_win_path($_[0]) : $_[0]);
22 0 ▶ return $target if defined $target;
Branch: 1 branch
BranchTrueFalseTotal
if defined $target 0 0 0
23 }
24  
25 0 goto &_real_readlink if _is_cygwin;
26  
27 # else is MSWin32
28 # emulate unix failues
29 0 ▶ if(!defined $_[0])
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $_[0]) { } 0 0 0
elsif (-e $_[0]) { } 0 0 0
30 {
31 # TODO: only warn if warnings on in caller
32 0 carp "Use of uninitialized value in readlink";
33 0 $! = 22;
34 }
35 elsif(-e $_[0])
36 {
37 0 $! = 22; # Invalid argument
38 }
39 else
40 {
41 0 $! = 2; # No such file or directory
42 }
43
44 0 return;
45 }
46  
47 2 1;
48  
49 __END__
« Readlink/Perl58.pm ↑ Summary Readlink.pm »