lib/Mite/Trait/HasDestructor.pm

filter: Statementstmt 100% 28 / 28 Branchbran 100% 2 / 2 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 41 / 41 CC 3 SCAR 5.6
CC
3
Cov
100%
__ANON__
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.8
« lib/Mite/App/Command/compile.pm ↑ Summary lib/Mite/Trait/HasMOP.pm »
1 117 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 117 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 117 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Mite::Trait::HasDestructor;
6 117 ▶use Mite::Miteception -role, -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 117 our $AUTHORITY = 'cpan:TOBYINK';
9 117 our $VERSION = '0.013000';
10  
11 117 requires qw(
12 linear_isa
13 _get_parent
14 _compile_meta
15 );
16  
17 118 ▶around compilation_stages => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
18 118 my ( $next, $self ) = ( shift, shift );
19  
20 # Check if we are inheriting from a Mite class in this project
21 118 my $inherit_from_mite = do {
22 # First parent
23 118 my $first_isa = do {
24 118 my @isa = $self->linear_isa;
25 118 shift @isa;
26 118 shift @isa;
27 };
28 118 ▶ !! ( $first_isa and $self->_get_parent( $first_isa ) );
Condition100%3/3
$first_isa && $self->_get_parent($first_isa)
!ll&&!rl&&r
92224
MC/DC100%2/2
$first_isa && $self->_get_parent($first_isa)
$first_isa $self->_get_parent($first_isa)
Truth table100%3/3
A && B
A= $first_isaB= $self->_get_parent($first_isa)
ABresult
0X0
100
111
29 };
30  
31 118 my @stages = $self->$next( @_ );
32  
33 # Only need these stages if not already inheriting from Mite
34 118 ▶ push @stages, qw(
Branch: 1 branch
BranchTrueFalseTotal
unless $inherit_from_mite 94 24 118
35 _compile_destroy
36 ) unless $inherit_from_mite;
37  
38 118 return @stages;
39 117 };
40  
41 94 ▶sub _compile_destroy {
Subroutine _compile_destroy: called CC=1 SCAR=0.0
42 94 my $self = shift;
43 94 sprintf <<'CODE', $self->_compile_meta( '$class', '$self' );
44 # Destructor should call DEMOLISH methods
45 sub DESTROY {
46 my $self = shift;
47 my $class = ref( $self ) || $self;
48 my $meta = %s;
49 my $in_global_destruction = defined ${^GLOBAL_PHASE}
50 ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
51 : Devel::GlobalDestruction::in_global_destruction();
52 for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
53 my $e = do {
54 local ( $?, $@ );
55 eval { $demolisher->( $self, $in_global_destruction ) };
56 $@;
57 };
58 no warnings 'misc'; # avoid (in cleanup) warnings
59 die $e if $e; # rethrow
60 }
61 return;
62 }
63 CODE
64 }
65  
66 117 1;
« lib/Mite/App/Command/compile.pm ↑ Summary lib/Mite/Trait/HasMOP.pm »