blib/lib/mods.pm

filter: Statementstmt 73.9% 51 / 69 Branchbran 46.4% 13 / 28 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 1 totaltotal 65.2% 77 / 118 CC 18 SCAR 30.6
CC
18
Cov
65%
import
36.7
sim_use
4.1
BEGIN
1.0
CRAP 21.3
↑ Summary
1 # $Id: mods.pm 1.11 Fri, 12 Sep 1997 23:21:20 -0400 jesse $
2  
3 package mods;
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # $Format: "$VERSION='$modsRelease$';"$
9 1 $VERSION='0.004';
10  
11 # $list: undef ~ use Foo; [] ~ use Foo(); [...] ~ use Foo (...)
12 6 ▶sub sim_use($$;$$) {
Subroutine sim_use: called CC=4 SCAR=14.0
Pod undocumented
13 6 my ($callpack, $pkg, $un, $list)=@_;
14 6 my $filename=$pkg;
15 6 $filename =~ s!::!/!g;
16 6 require "$filename.pm";
17 5 ▶ unless ($list and not @$list) { # Null import: use Foo ();
Branch: 1 branch
BranchTrueFalseTotal
unless ($list and not @$list) 5 0 5
Condition66%2/3
$list and not @$list
!ll&&!rl&&r
230
MC/DC0%0/2
$list and not @$list
$list not @$list
Truth table66%2/3
A and not(B)
A= $listB= not @$list
ABresult
0X0
100
111
18 # Black magic commencing. Yes there is a reason for all this fuss...
19 5 ▶ my $meth=($un ? 'unimport' : 'import');
Branch: 1 branch
BranchTrueFalseTotal
$un ? : 0 5 5
20 1 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 local (*{"${callpack}::__FNORD__"})=
22 eval "package $callpack; sub {\$pkg->\$meth(\@\$list)}";
23 5 &{"${callpack}::__FNORD__"}();
24 }
25 }
26  
27 1 ▶sub import {
Subroutine import: called CC=15 SCAR=36.0
28 1 my ($class, @in)=@_;
29 1 ▶ if (@in==1 and $in[0] !~ /[^0-9.]/) {
Branch: 1 branch
BranchTrueFalseTotal
if (@in == 1 and not $in[0] =~ /[^0-9.]/) 0 1 1
Condition33%1/3
@in == 1 and not $in[0] =~ /[^0-9.]/
!ll&&!rl&&r
010
MC/DC0%0/2
@in == 1 and not $in[0] =~ /[^0-9.]/
@in == 1 not $in[0] =~ /[^0-9.]/
Truth table33%1/3
A and not(B)
A= @in == 1B= not $in[0] =~ /[^0-9.]/
ABresult
0X0
100
111
30 0 ▶ if ($VERSION < $in[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mods::VERSION < $in[0]) { } 0 0 0
31 0 require Carp;
32 0 Carp::croak "mods $in[0] requested, only have $VERSION";
33 } else {
34 0 return;
35 }
36 }
37 1 my $callpack=caller;
38 1 my $in=join "\n", @in;
39 1 ▶ unless ($in =~ s/^\s*~//) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($in =~ s/^\s*~//) 1 0 1
40 # Defaults.
41 1 sim_use $callpack, q(strict);
42 1 sim_use $callpack, q(integer);
43 1 sim_use $callpack, q(vars), 0,
44 [qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS @EXPORT_FAIL $AUTOLOAD $VERSION)];
45 }
46 # Custom.
47 1 $in =~ s/(^|\s)\#.*$/$1/gm; # Comments.
48 1 ▶ while ($in =~ m{
Branch: 1 branch
BranchTrueFalseTotal
if ($in =~ / ( # Import directive (!)? # Unimport? \s* ([\w:]+) # Package name \s* ( # Import list, maybe none \( ( [^()]* ) # Imports themselves \) )? ) | ( # BEGIN directive \{ ([^{}]*) # Actual code \} ) | ( # Export directive < ([^<>]*) # Exportables > ) | ( # Inherit \[ ([^][]*) # Superclasses \] ) | ( [\$\@\%] \w+ # Variable ) /gsx) 4 0 4
49 ( # Import directive
50 (!)? # Unimport?
51 \s*
52 ([\w:]+) # Package name
53 \s*
54 ( # Import list, maybe none
55 \(
56 ( [^()]* ) # Imports themselves
57 \)
58 )?
59 ) |
60 ( # BEGIN directive
61 \{
62 ([^{}]*) # Actual code
63 \}
64 ) |
65 ( # Export directive
66 <
67 ([^<>]*) # Exportables
68 >
69 ) |
70 ( # Inherit
71 \[
72 ([^][]*) # Superclasses
73 \]
74 ) |
75 (
76 [\$\@\%] \w+ # Variable
77 )
78 }sgx) {
79 4 ▶ if ($1) {
Branch: 5 branches
BranchTrueFalseTotal
if ($1) { } 1 3 4
elsif ($6) { } 1 2 3
elsif ($8) { } 0 2 2
elsif ($10) { } 0 2 2
elsif ($12) { } 2 0 2
80 # Importation
81 1 my ($un, $pack, $list, $sublist)=($2, $3, $4, $5);
82 1 ▶ sim_use $callpack, $pack, $un, ($list ? [$sublist =~ /([^\s,]+)/g] : undef);
Branch: 1 branch
BranchTrueFalseTotal
$list ? : 0 1 1
83 } elsif ($6) {
84 # Compile code
85 1 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
86 1 ▶ no integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
87 1 eval "package $callpack; $7";
88 } elsif ($8) {
89 # Exporting
90 0 my @what=($9 =~ /([^\s,]+)/g);
91 0 sim_use $callpack, q(Exporter), 0, [];
92 1 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
93 0 push @{"${callpack}::ISA"}, q(Exporter)
94 0 ▶ unless grep {$_ eq q(Exporter)} @{"${callpack}::ISA"};
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq "Exporter";} @{"${callpack}::ISA";} 0 0 0
95 0 foreach (@what) {
96 0 ▶ my $where=(s/!$// ? 'EXPORT' : 'EXPORT_OK');
Branch: 1 branch
BranchTrueFalseTotal
s/!$// ? : 0 0 0
97 0 push @{"${callpack}::$where"}, $_;
98 }
99 0 sim_use $callpack, q(vars), 0, [grep {/^[\$\@\%]/} @what];
100 } elsif ($10) {
101 # Inheritance
102 1 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
103 0 push @{"${callpack}::ISA"}, ($11 =~ /([\w:]+)/g);
104 } elsif ($12) {
105 # Variable
106 2 sim_use $callpack, q(vars), 0, [$12];
107 } # Else comment.
108 }
109 }
110  
111 1 1;
112 __END__
↑ Summary