Interface.pm

filter: Statementstmt 100% 64 / 64 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 15 / 15 Podpod 0.0% 0 / 4 totaltotal 94.5% 86 / 91 CC 6 SCAR 5.9
CC
6
Cov
99%
run_tests
4.0
test_message
2.0
this_name
2.0
CRAP 1.8
↑ Summary Interface/ContextReference.pm »
1 package Test::OpenTracing::Interface;
2  
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 18 our $VERSION = 'v0.23.1';
7  
8  
9 package Test::OpenTracing::Interface::Base;
10  
11 18 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 18 ▶use Scalar::Util qw/blessed/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 18 ▶use Types::Standard qw/ClassName Object Str/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16  
17  
18 18 has interface_name => (
19 is => 'ro',
20 isa => Str,
21 );
22  
23 18 has test_this => (
24 is => 'ro',
25 isa => ClassName | Object,
26 );
27  
28 18 has message => (
29 is => 'ro',
30 isa => Str,
31 predicate => 1,
32 );
33  
34 66 ▶sub this_name {
Subroutine this_name: called CC=2 SCAR=6.9
Pod undocumented
35 66 my $self = shift;
36
37 66 ▶ my $this_name = defined blessed( $self->test_this ) ?
Branch: 1 branch
BranchTrueFalseTotal
defined builtin::blessed($self->test_this) ? : 12 54 66
38 blessed( $self->test_this ) : $self->test_this;
39
40 66 return $this_name
41 }
42  
43  
44  
45 package Test::OpenTracing::Interface::CanAll;
46  
47 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 18 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 18 extends 'Test::OpenTracing::Interface::Base';
52  
53 18 ▶use Test::Builder;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 18 ▶use Types::Standard qw/ArrayRef Str/;
Subroutine BEGIN: called CC=1 SCAR=0.0
55  
56  
57  
58 18 has interface_methods => (
59 is => 'ro',
60 isa => ArrayRef[ Str ]
61 );
62  
63  
64  
65 18 ▶sub run_tests{
Subroutine run_tests: called CC=4 SCAR=13.9
Pod undocumented
66 18 my $self = shift;
67
68 18 my $test_name = $self->this_name;
69
70 18 my $Test = Test::Builder->new;
71 18 local $Test::Builder::Level = $Test::Builder::Level + 1;
72
73 18 ▶ no strict qw/refs/;
Subroutine BEGIN: called CC=1 SCAR=0.0
74 18 my @failures;
75 18 foreach my $test_method ( sort @{$self->interface_methods} ) {
76 90 ▶ next if $self->test_this->can($test_method);
Branch: 1 branch
BranchTrueFalseTotal
if $self->test_this->can($test_method) 60 30 90
77 30 $Test->diag( $self->diag_message($test_method) );
78 30 push @failures, $test_method;
79 }
80
81 18 ▶ my $ok = scalar @failures ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
scalar @failures ? : 6 12 18
82 18 return $Test->ok( $ok, $self->test_message );
83
84 }
85  
86  
87  
88 30 ▶sub diag_message {
Subroutine diag_message: called CC=1 SCAR=0.0
Pod undocumented
89 30 my $self = shift;
90 30 my $method_name = shift;
91
92 30 my $this_name = $self->this_name();
93
94 30 return "$this_name->can('$method_name') failed"
95 }
96  
97  
98  
99 18 ▶sub test_message {
Subroutine test_message: called CC=2 SCAR=7.0
Pod undocumented
100 18 my $self = shift;
101
102 18 ▶ return $self->message if $self->has_message;
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_message 0 18 18
103
104 18 my $this_name = $self->this_name();
105 18 my $interface_name = $self->interface_name;
106
107 18 return "$this_name->can_all_ok( '$interface_name' )"
108 }
109  
110  
111  
112 18 1;
↑ Summary Interface/ContextReference.pm »