blib/lib/Test/Core.pm

filter: Statementstmt 100% 46 / 46 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 13 / 13 Podpod 0.0% 0 / 2 totaltotal 94.3% 67 / 71 CC 6 SCAR 6.9
CC
6
Cov
96%
mock_object
4.0
mock_module
3.0
BEGIN
1.0
CRAP 2.0
↑ Summary
1 package Test::Core;
2 5 $Test::Core::VERSION = '0.0200';
3 5 ▶use Data::Dump ();
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use Import::Into;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Module::Load ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Test::Modern ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Test::MockModule ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Test::MockObject ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use Test::MockObject::Extends ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
12 4 my $caller = scalar caller();
13 4 Test::Modern->import::into($caller, qw(-default -deeper !TD));
14 4 Data::Dump->import::into($caller);
15  
16 5 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 *{$caller . '::MM'} = \&mock_module;
18 4 *{$caller . '::MO'} = \&mock_object;
19 }
20  
21 1 ▶sub mock_module {
Subroutine mock_module: called CC=3 SCAR=11.0
Pod undocumented
22 1 my ($class, %mocks) = @_;
23 1 my $mock_module = Test::MockModule->new($class);
24 1 ▶ while (my ($method, $override) = each(%mocks)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %mocks) 1 1 2
25 $mock_module->mock(
26 $method,
27 2 ▶ ('CODE' eq ref $override ? $override : sub { $override })
Subroutine __ANON__: called CC=1 SCAR=0.0
28 1 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
'CODE' eq ref $override ? : 0 1 1
29 }
30 1 return $mock_module;
31 }
32  
33 2 ▶sub mock_object {
Subroutine mock_object: called CC=4 SCAR=13.9
Pod undocumented
34 2 my (%mocks) = @_;
35 2 my $isa = delete $mocks{isa};
36 2 ▶ my $mock_object = $isa
Branch: 1 branch
BranchTrueFalseTotal
$isa ? : 1 1 2
37 ? Test::MockObject::Extends->new($isa)
38 : Test::MockObject->new;
39 2 ▶ while (my ($method, $override) = each(%mocks)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %mocks) 2 2 4
40 $mock_object->mock(
41 $method,
42 2 ▶ ('CODE' eq ref $override ? $override : sub { $override })
Subroutine __ANON__: called CC=1 SCAR=0.0
43 2 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
'CODE' eq ref $override ? : 0 2 2
44 }
45 2 return $mock_object;
46 }
47  
48 5 1;
49  
50 # ABSTRACT: Modern Perl testing with a single import
51  
52 __END__
↑ Summary