Unit/Sugar/TestCase.pm

filter: Statementstmt 100% 42 / 42 Branchbran 90.0% 9 / 10 Conditioncond 77.7% 7 / 9 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 1 totaltotal 89.7% 70 / 78 CC 10 SCAR 15.9
CC
10
Cov
95%
parser
9.0
import
2.0
BEGIN
1.0
CRAP 4.9
↑ Summary Unit/Sugar/Shared.pm »
1 # Defines the behavior of the +case+ keyword.
2 # @api private
3 package Test::Mini::Unit::Sugar::TestCase;
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 43 ▶sub import {
Subroutine import: called CC=2 SCAR=6.9
11 43 my ($class, %args) = @_;
12 43 ▶ my $caller = $args{into} || caller;
Condition66%2/3
$args{'into'} || caller
l!l&&r!l&&!r
15280
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 43 ▶ *{"$caller\::case"} = sub (&) {};
Subroutine __ANON__: not called CC=1 SCAR=0.0
17 }
18  
19 Devel::Declare->setup_for(
20 28 ▶ $caller => { case => { const => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
21 28 $class->new(%args)->parser(@_);
22 } } }
23 43 );
24 }
25  
26 28 ▶sub parser {
Subroutine parser: called CC=9 SCAR=22.0
Pod undocumented
27 28 my $self = shift;
28 28 $self->init(@_);
29  
30 28 $self->skip_declarator;
31  
32 28 my $name = $self->strip_name;
33 28 ▶ die unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 28 28
34  
35 28 my $pkg = $self->get_curstash_name;
36 28 my $base = $pkg;
37  
38 # If our current scope isn't a Test::Mini::TestCase, we inherit from that;
39 # otherwise, we inherit from our current scope.
40 28 ▶ $base = 'Test::Mini::TestCase' unless $base->isa('Test::Mini::TestCase');
Branch: 1 branch
BranchTrueFalseTotal
unless $base->isa("Test::Mini::TestCase") 15 13 28
41  
42 # Nested packages should be namespaced under their parent, unless the
43 # package name is qualified or they're in the top level.
44 28 ▶ $name = join('::', $pkg, $name) unless $name =~ s/^::// || $pkg eq 'main';
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ s/^::// or $pkg eq "main" 13 15 28
Condition100%3/3
$name =~ s/^::// or $pkg eq "main"
l!l&&r!l&&!r
11413
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
45 28 (my $file = $name) =~ s/::/\//g;
46  
47 28 my $Sugar = 'Test::Mini::Unit::Sugar';
48 28 ▶ my @with = ref $self->{with} ? @{$self->{with}} : $self->{with} || ();
Branch: 1 branch
BranchTrueFalseTotal
ref $self->{'with'} ? : 3 25 28
Condition66%2/3
$self->{"with"} or ()
l!l&&r!l&&!r
1024
MC/DC50%1/2
$self->{"with"} or ()
$self->{"with"} ()
Truth table66%2/3
A or B
A= $self->{"with"}B= ()
ABresult
1X1
011
000
49 28 ▶ my $with = @with ? 'with => ["' . join('","', @with) . '"]' : '';
Branch: 1 branch
BranchTrueFalseTotal
@with ? : 4 24 28
50  
51 28 $self->inject_if_block($_) for reverse (
52 $self->scope_injector_call(),
53  
54 "package $name;",
55 "use base '$base';",
56  
57 "BEGIN { \$INC{'${file}.pm'} = __FILE__; }",
58  
59 "use Test::Mini::Assertions;",
60  
61 # Provide explicit default advice to avoid some order-specific issues.
62 'sub setup { shift->SUPER::setup(@_) }',
63 'sub teardown { shift->SUPER::teardown(@_) }',
64  
65 "use ${Sugar}::TestCase $with;",
66 "use ${Sugar}::Shared $with;",
67 "use ${Sugar}::Test;",
68 "use ${Sugar}::Reuse;",
69 "use ${Sugar}::Advice (name => 'setup', order => 'pre');",
70 "use ${Sugar}::Advice (name => 'teardown', order => 'post');",
71 4 (map { "use $_;" } reverse @with),
72 );
73  
74 28 ▶ $self->shadow(sub (&) { shift->(); 1; });
Subroutine __ANON__: called CC=1 SCAR=0.0
75 }
76  
77 13 1;
↑ Summary Unit/Sugar/Shared.pm »