Unit/Sugar/Shared.pm

filter: Statementstmt 97.5% 40 / 41 Branchbran 75.0% 6 / 8 Conditioncond 77.7% 7 / 9 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 1 totaltotal 86.6% 65 / 75 CC 9 SCAR 14.5
CC
9
Cov
91%
parser
8.1
import
2.0
BEGIN
1.0
CRAP 4.3
« Unit/Sugar/TestCase.pm ↑ Summary Unit/Sugar/Reuse.pm »
1 # Defines the behavior of the +shared+ keyword.
2 # @api private
3 package Test::Mini::Unit::Sugar::Shared;
4 13 ▶use base 'Devel::Declare::Context::Simple';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 13 ▶use Devel::Declare ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 47 ▶sub import {
Subroutine import: called CC=2 SCAR=6.9
11 47 my ($class, %args) = @_;
12 47 ▶ my $caller = $args{into} || caller;
Condition66%2/3
$args{'into'} || caller
l!l&&r!l&&!r
16310
MC/DC0%0/2
$args{'into'} || caller
$args{'into'} caller
Truth table66%2/3
A || B
A= $args{'into'}B= caller
ABresult
1X1
011
000
13  
14 {
15 13 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 47 ▶ *{"$caller\::shared"} = sub (&) {};
Subroutine __ANON__: not called CC=1 SCAR=0.0
17 }
18  
19 Devel::Declare->setup_for(
20 3 ▶ $caller => { shared => { const => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
21 3 $class->new(%args)->parser(@_);
22 } } }
23 47 );
24 }
25  
26 3 ▶sub parser {
Subroutine parser: called CC=8 SCAR=20.9
Pod undocumented
27 3 my $self = shift;
28 3 $self->init(@_);
29  
30 3 $self->skip_declarator();
31  
32 3 my $name = $self->strip_name();
33 3 ▶ die unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 3 3
34  
35 3 my $pkg = $self->get_curstash_name();
36 3 my $base = 'Test::Mini::Unit::SharedBehavior';
37  
38 # Nested packages should be namespaced under their parent, unless the
39 # package name is qualified or they're in the top level.
40 3 ▶ $name = join('::', $pkg, $name) unless $name =~ s/^::// || $pkg eq 'main';
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ s/^::// or $pkg eq "main" 1 2 3
Condition100%3/3
$name =~ s/^::// or $pkg eq "main"
l!l&&r!l&&!r
111
MC/DC100%2/2
$name =~ s/^::// or $pkg eq "main"
$name =~ s/^::// $pkg eq "main"
Truth table100%3/3
A or B
A= $name =~ s/^:://B= $pkg eq "main"
ABresult
1X1
011
000
41 3 (my $file = $name) =~ s/::/\//g;
42  
43 3 my $Sugar = 'Test::Mini::Unit::Sugar';
44 0 ▶ my @with = ref $self->{with} ? @{$self->{with}} : $self->{with} || ();
Branch: 1 branch
BranchTrueFalseTotal
ref $self->{'with'} ? : 0 3 3
Condition66%2/3
$self->{"with"} or ()
l!l&&r!l&&!r
102
MC/DC50%1/2
$self->{"with"} or ()
$self->{"with"} ()
Truth table66%2/3
A or B
A= $self->{"with"}B= ()
ABresult
1X1
011
000
45 3 ▶ my $with = @with ? 'with => ["' . join('","', @with) . '"]' : '';
Branch: 1 branch
BranchTrueFalseTotal
@with ? : 1 2 3
46  
47 3 $self->inject_if_block($_) for reverse (
48 $self->scope_injector_call(),
49 "package $name;",
50 "use base '$base';",
51  
52 "\$INC{'${file}.pm'} = __FILE__;",
53  
54 "use Test::Mini::Assertions;",
55  
56 "use ${Sugar}::Test;",
57 "use ${Sugar}::Advice (name => 'setup', order => 'pre');",
58 "use ${Sugar}::Advice (name => 'teardown', order => 'post');",
59 1 (map { "use $_;" } reverse @with),
60 );
61  
62 3 ▶ $self->shadow(sub (&) { shift->(); 1; });
Subroutine __ANON__: called CC=1 SCAR=0.0
63 }
64  
65 13 1;
« Unit/Sugar/TestCase.pm ↑ Summary Unit/Sugar/Reuse.pm »