blib/lib/Inline/Foo.pm

filter: Statementstmt 85.0% 57 / 67 Branchbran 70.0% 14 / 20 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 58.3% 14 / 24 Podpod 0.0% 0 / 7 totaltotal 70.1% 87 / 124 CC 13 SCAR 11.8
CC
13
Cov
80%
validate
7.1
build
5.9
load
3.0
CRAP 3.2
« blib/lib/Inline/C/ParseRecDescent.pm ↑ Summary /home/cpancover/.cpan/build/Inline-0.54_02-0/blib/lib/Inline/C/ParseRecDescent.pm »
1 package Inline::Foo;
2 5 $VERSION = '0.01';
3 5 require Inline;
4 5 @ISA = qw(Inline);
5 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub register {
10 return {
11 0 ▶ language => 'Foo',
Subroutine register: not called CC=1 SCAR=6.9
Pod undocumented
12 aliases => ['foo'],
13 type => 'interpreted',
14 suffix => 'foo',
15 };
16 }
17  
18 sub usage_config {
19 2 ▶ my $key = shift;
Subroutine usage_config: called CC=1 SCAR=0.0
Pod undocumented
20 2 "'$key' is not a valid config option for Inline::Foo\n";
21 }
22  
23 sub usage_config_bar {
24 0 ▶ "Invalid value for Inline::Foo config option BAR";
Subroutine usage_config_bar: not called CC=1 SCAR=6.9
Pod undocumented
25 }
26  
27 sub validate {
28 12 ▶ my $o = shift;
Subroutine validate: called CC=7 SCAR=19.6
Pod undocumented
29 12 ▶ $o->{ILSM}{PATTERN} ||= 'foo-';
Condition50%1/2
$o->{"ILSM"}{"PATTERN"} ||= "foo-"
l!l
012
MC/DC0%0/1
$o->{"ILSM"}{"PATTERN"} ||= "foo-"
$o->{"ILSM"}{"PATTERN"}
Truth table50%1/2
A
A= $o->{"ILSM"}{"PATTERN"}
Aresult
11
00
30 12 ▶ $o->{ILSM}{BAR} ||= 0;
Condition50%1/2
$o->{"ILSM"}{"BAR"} ||= 0
l!l
012
MC/DC0%0/1
$o->{"ILSM"}{"BAR"} ||= 0
$o->{"ILSM"}{"BAR"}
Truth table50%1/2
A
A= $o->{"ILSM"}{"BAR"}
Aresult
11
00
31 12 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 4 11 15
32 4 my ($key, $value) = splice @_, 0, 2;
33 4 ▶ if ($key eq 'PATTERN') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "PATTERN") 1 3 4
34 1 $o->{ILSM}{PATTERN} = $value;
35 1 next;
36 }
37 3 ▶ if ($key eq 'BAR') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "BAR") 2 1 3
38 2 ▶ croak usage_config_bar
Branch: 1 branch
BranchTrueFalseTotal
unless $value =~ /^[01]$/ 0 2 2
39 unless $value =~ /^[01]$/;
40 2 $o->{ILSM}{BAR} = $value;
41 2 next;
42 }
43 1 croak usage_config($key);
44 }
45 }
46  
47 sub build {
48 11 ▶ my $o = shift;
Subroutine build: called CC=5 SCAR=17.8
Pod undocumented
49 11 my $code = $o->{API}{code};
50 11 my $pattern = $o->{ILSM}{PATTERN};
51 11 $code =~ s/$pattern//g;
52 11 ▶ $code =~ s/bar-//g if $o->{ILSM}{BAR};
Branch: 1 branch
BranchTrueFalseTotal
if $o->{"ILSM"}{"BAR"} 2 9 11
53 11 sleep 1; # imitate compile delay
54 {
55 11 package Foo::Tester;
56 11 ▶ eval $code;
Subroutine add: not called CC=1 SCAR=5.1
Subroutine subtract: not called CC=1 SCAR=5.1
Subroutine test1: not called CC=1 SCAR=5.1
Subroutine test2: not called CC=1 SCAR=5.1
Subroutine test3: not called CC=1 SCAR=5.1
Subroutine test4: not called CC=1 SCAR=5.1
Subroutine test5: not called CC=1 SCAR=5.1
57 }
58 11 ▶ croak "Foo build failed:\n$@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 11 11
59 11 my $path = File::Spec->catdir($o->{API}{install_lib},'auto',$o->{API}{modpname});
60 11 my $obj = $o->{API}{location};
61 11 ▶ $o->mkpath($path) unless -d $path;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $path 11 0 11
62 11 ▶ open FOO_OBJ, "> $obj"
Branch: 1 branch
BranchTrueFalseTotal
open FOO_OBJ, "> $obj" or croak("Can't open $obj for output\n$!") 0 11 11
63 or croak "Can't open $obj for output\n$!";
64 11 print FOO_OBJ $code;
65 11 close \*FOO_OBJ;
66 }
67  
68 sub load {
69 11 ▶ my $o = shift;
Subroutine load: called CC=3 SCAR=11.0
Pod undocumented
70 11 my $obj = $o->{API}{location};
71 11 ▶ open FOO_OBJ, "< $obj"
Branch: 1 branch
BranchTrueFalseTotal
open FOO_OBJ, "< $obj" or croak("Can't open $obj for output\n$!") 0 11 11
72 or croak "Can't open $obj for output\n$!";
73 11 my $code = join '', <FOO_OBJ>;
74 11 close \*FOO_OBJ;
75 11 ▶ eval "package $o->{API}{pkg};\n$code";
Subroutine add: called CC=1 SCAR=0.0
Subroutine subtract: called CC=1 SCAR=0.0
Subroutine test1: called CC=1 SCAR=0.0
Subroutine test2: called CC=1 SCAR=0.0
Subroutine test3: called CC=1 SCAR=0.0
Subroutine test4: called CC=1 SCAR=0.0
Subroutine test5: called CC=1 SCAR=0.0
76 11 ▶ croak "Unable to load Foo module $obj:\n$@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 11 11
77 }
78  
79 sub info {
80 0 ▶ my $o = shift;
Subroutine info: not called CC=1 SCAR=6.9
Pod undocumented
81 }
82  
83 5 1;
84  
85 __END__
« blib/lib/Inline/C/ParseRecDescent.pm ↑ Summary /home/cpancover/.cpan/build/Inline-0.54_02-0/blib/lib/Inline/C/ParseRecDescent.pm »