examples/Example/Exporter.pm

filter: Statementstmt 100% 23 / 23 Branchbran 83.3% 5 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 85.7% 36 / 42 CC 5 SCAR 8.7
CC
5
Cov
91%
fib
4.3
_generate_embiggen
2.0
BEGIN
1.0
CRAP 2.4
« blib/lib/Exporter/Shiny.pm ↑ Summary
1 5 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Example::Exporter;
6  
7 # Inherit from Exporter::Tiny.
8 #
9 5 ▶use base 'Exporter::Tiny';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # The list of functions to export by default.
12 # Be conservative.
13 #
14 5 our @EXPORT = qw( fib );
15  
16 # The list of functions which are allowed to
17 # be exported. Be liberal.
18 #
19 5 our @EXPORT_OK = qw( embiggen );
20  
21 # Note that there was no need to list "fib"
22 # in @EXPORT_OK. It was in @EXPORT, so it's
23 # implicitly ok.
24  
25 # This is the definition of the "fib" function
26 # that we want to export.
27 #
28 sub fib {
29 175 ▶ my $n = $_[0];
Subroutine fib: called CC=4 SCAR=14.6
Pod undocumented
30
31 175 ▶ (int($n) eq $n) && ($n >= 0)
Branch: 1 branch
BranchTrueFalseTotal
int $n eq $n and $n >= 0 or die "Expected natural number as argument; got '${n}'" 0 175 175
Condition33%1/3
int $n eq $n and $n >= 0
!ll&&!rl&&r
00175
MC/DC0%0/2
int $n eq $n and $n >= 0
int $n eq $n $n >= 0
Truth table33%1/3
A and B
A= int $n eq $nB= $n >= 0
ABresult
0X0
100
111
32 or die "Expected natural number as argument; got '$n'";
33
34 175 ▶ return $n if $n < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $n < 2 91 84 175
35
36 84 fib($n - 1) + fib($n - 2);
37 }
38  
39 # We won't define a standard embiggen function.
40 # Instead we will generate one when requested.
41 #
42 sub _generate_embiggen {
43 4 ▶ my ($class, $name, $arg, $globals) = @_;
Subroutine _generate_embiggen: called CC=2 SCAR=6.9
44
45 4 ▶ my $embiggen_amount = exists($arg->{amount}) ? $arg->{amount} : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $arg->{'amount'} ? : 2 2 4
46
47 # This is the sub that will be installed into
48 # the caller's namespace.
49 #
50 return sub ($) {
51 4 ▶ my $n = $_[0];
Subroutine __ANON__: called CC=1 SCAR=0.0
52 4 return $n + $embiggen_amount;
53 }
54 4 }
55  
56 5 1; # Make Perl Happy™
« blib/lib/Exporter/Shiny.pm ↑ Summary