corpus/lib/Alien/Foo1/ConfigData.pm

filter: Statementstmt 20.0% 9 / 45 Branchbran 3.8% 1 / 26 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 22.2% 2 / 9 Podpod 0.0% 0 / 8 totaltotal 12.1% 12 / 99 CC 15 SCAR 40.8
CC
15
Cov
13%
feature
110.0
write
42.0
set_config
2.0
CRAP 59.3
« blib/lib/Alien/Build/Plugin/PkgConfig/LibPkgConf.pm ↑ Summary corpus/lib/Alien/Foo2/ConfigData.pm »
1 package Alien::Foo1::ConfigData;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶my $arrayref = eval do {local $/; <DATA>}
Branch: 1 branch
BranchTrueFalseTotal
my $arrayref = eval do { local $/; readline DATA } or die "Couldn't load ConfigData data: $@" 1 0 1
4 or die "Couldn't load ConfigData data: $@";
5 1 close DATA;
6 1 my ($config, $features, $auto_features) = @$arrayref;
7  
8 9 ▶sub config { $config->{$_[1]} }
Subroutine config: called CC=1 SCAR=0.0
Pod undocumented
9  
10 0 ▶sub set_config { $config->{$_[1]} = $_[2] }
Subroutine set_config: not called CC=1 SCAR=6.9
Pod undocumented
11 0 ▶sub set_feature { $features->{$_[1]} = 0+!!$_[2] } # Constrain to 1 or 0
Subroutine set_feature: not called CC=1 SCAR=6.9
Pod undocumented
12  
13 0 ▶sub auto_feature_names { grep !exists $features->{$_}, keys %$auto_features }
Subroutine auto_feature_names: not called CC=1 SCAR=6.9
Pod undocumented
14  
15 0 ▶sub feature_names {
Subroutine feature_names: not called CC=1 SCAR=6.9
Pod undocumented
16 0 my @features = (keys %$features, auto_feature_names());
17 0 @features;
18 }
19  
20 0 ▶sub config_names { keys %$config }
Subroutine config_names: not called CC=1 SCAR=6.9
Pod undocumented
21  
22 0 ▶sub write {
Subroutine write: not called CC=6 SCAR=37.4
Pod undocumented
23 0 my $me = __FILE__;
24  
25 # Can't use Module::Build::Dumper here because M::B is only a
26 # build-time prereq of this module
27 0 require Data::Dumper;
28  
29 0 my $mode_orig = (stat $me)[2] & 07777;
30 0 chmod($mode_orig | 0222, $me); # Make it writeable
31 0 ▶ open(my $fh, '+<', $me) or die "Can't rewrite $me: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "+<", $me or die "Can't rewrite ${me}: $!" 0 0 0
32 0 seek($fh, 0, 0);
33 0 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
34 0 ▶ last if /^__DATA__$/;
Branch: 1 branch
BranchTrueFalseTotal
if /^__DATA__$/ 0 0 0
35 }
36 0 ▶ die "Couldn't find __DATA__ token in $me" if eof($fh);
Branch: 1 branch
BranchTrueFalseTotal
if eof $fh 0 0 0
37  
38 0 seek($fh, tell($fh), 0);
39 0 my $data = [$config, $features, $auto_features];
40 0 print($fh 'do{ my '
41 . Data::Dumper->new([$data],['x'])->Purity(1)->Dump()
42 . '$x; }' );
43 0 truncate($fh, tell($fh));
44 0 close $fh;
45  
46 0 ▶ chmod($mode_orig, $me)
Branch: 1 branch
BranchTrueFalseTotal
chmod $mode_orig, $me or warn "Couldn't restore permissions on ${me}: $!" 0 0 0
47 or warn "Couldn't restore permissions on $me: $!";
48 }
49  
50 0 ▶sub feature {
Subroutine feature: not called CC=10 SCAR=47.0
Pod undocumented
51 0 my ($package, $key) = @_;
52 0 ▶ return $features->{$key} if exists $features->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $features->{$key} 0 0 0
53  
54 0 ▶ my $info = $auto_features->{$key} or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $info = $auto_features->{$key} or return 0 0 0 0
55  
56 # Under perl 5.005, each(%$foo) isn't working correctly when $foo
57 # was reanimated with Data::Dumper and eval(). Not sure why, but
58 # copying to a new hash seems to solve it.
59 0 my %info = %$info;
60  
61 0 require Module::Build; # XXX should get rid of this
62 0 ▶ while (my ($type, $prereqs) = each %info) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %info) 0 0 0
63 0 ▶ next if $type eq 'description' || $type eq 'recommends';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "description" or $type eq "recommends" 0 0 0
Condition0%0/3
$type eq "description" or $type eq "recommends"
l!l&&r!l&&!r
000
MC/DC0%0/2
$type eq "description" or $type eq "recommends"
$type eq "description" $type eq "recommends"
Truth table0%0/3
A or B
A= $type eq "description"B= $type eq "recommends"
ABresult
1X1
011
000
64  
65 0 my %p = %$prereqs; # Ditto here.
66 0 ▶ while (my ($modname, $spec) = each %p) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %p) 0 0 0
67 0 my $status = Module::Build->check_installed_status($modname, $spec);
68 0 ▶ if ((!$status->{ok}) xor ($type =~ /conflicts$/)) { return 0; }
Branch: 1 branch
BranchTrueFalseTotal
if (not $status->{"ok"} xor $type =~ /conflicts$/) 0 0 0
Condition0%0/4
not $status->{"ok"} xor $type =~ /conflicts$/
l&&rl&&!r!l&&r!l&&!r
0000
MC/DC0%0/2
not $status->{"ok"} xor $type =~ /conflicts$/
not $status->{"ok"} $type =~ /conflicts$/
Truth table0%0/4
not(A) xor B
A= not $status->{"ok"}B= $type =~ /conflicts$/
ABresult
110
101
011
000
69 0 ▶ if ( ! eval "require $modname; 1" ) { return 0; }
Branch: 1 branch
BranchTrueFalseTotal
unless (eval "require $modname; 1") 0 0 0
70 }
71 }
72 0 return 1;
73 }
74  
75  
76 __DATA__
« blib/lib/Alien/Build/Plugin/PkgConfig/LibPkgConf.pm ↑ Summary corpus/lib/Alien/Foo2/ConfigData.pm »