File Coverage

/tmp/djaSrpmWgK.mite.pm
Criterion Covered Total %
statement 108 149 72.4
branch 22 56 39.2
condition 8 41 19.5
subroutine 23 25 92.0
pod n/a
total 161 271 59.4


line stmt bran cond sub pod time code
1             {
2             package MyTest1;
3 1     1   15 use strict;
  1         3  
  1         66  
4 1     1   7 use warnings;
  1         1  
  1         32  
5 1     1   4 no warnings qw( once void );
  1         2  
  1         186  
6              
7             our $USES_MITE = "Mite::Role";
8             our $MITE_SHIM = "Mite::Shim";
9             our $MITE_VERSION = "0.012000";
10             # Mite keywords
11             BEGIN {
12 1     1   5 my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest1" );
13 1         2 ( *after, *around, *before, *has, *requires, *signature_for, *with ) = do {
14             package Mite::Shim;
15 1     1   8 no warnings 'redefine';
  1         2  
  1         189  
16             (
17 0         0 sub { $SHIM->HANDLE_after( $CALLER, "role", @_ ) },
18 0         0 sub { $SHIM->HANDLE_around( $CALLER, "role", @_ ) },
19 0         0 sub { $SHIM->HANDLE_before( $CALLER, "role", @_ ) },
20 1         4 sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) },
21             sub {},
22 0         0 sub { $SHIM->HANDLE_signature_for( $CALLER, "role", @_ ) },
23 0         0 sub { $SHIM->HANDLE_with( $CALLER, @_ ) },
24 1         47 );
25             };
26             };
27              
28             # Gather metadata for constructor and destructor
29             sub __META__ {
30 1     1   6 no strict 'refs';
  1         2  
  1         439  
31 0   0 0   0 my $class = shift; $class = ref($class) || $class;
  0         0  
32 0         0 my $linear_isa = mro::get_linear_isa( $class );
33             return {
34             BUILD => [
35 0 0       0 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  0         0  
  0         0  
36 0         0 map { "$_\::BUILD" } reverse @$linear_isa
37             ],
38             DEMOLISH => [
39 0 0       0 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  0         0  
  0         0  
40 0         0 map { "$_\::DEMOLISH" } @$linear_isa
  0         0  
41             ],
42             HAS_BUILDARGS => $class->can('BUILDARGS'),
43             HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'),
44             };
45             }
46              
47             # See UNIVERSAL
48             sub DOES {
49 7     7   15 my ( $self, $role ) = @_;
50 7         7 our %DOES;
51 7 50       14 return $DOES{$role} if exists $DOES{$role};
52 7 50       10 return 1 if $role eq __PACKAGE__;
53 7 50 0     14 if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) {
      33        
54 0 0 0     0 $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1;
55             }
56 7         36 return $self->SUPER::DOES( $role );
57             }
58              
59             # Alias for Moose/Moo-compatibility
60             sub does {
61 7     7   2069 shift->DOES( @_ );
62             }
63              
64             # Callback which classes consuming this role will call
65             sub __FINALIZE_APPLICATION__ {
66 1     1   2 my ( $me, $target, $args ) = @_;
67 1         2 our ( %CONSUMERS, @METHOD_MODIFIERS );
68              
69             # Ensure a given target only consumes this role once.
70 1 50       4 if ( exists $CONSUMERS{$target} ) {
71 0         0 return;
72             }
73 1         2 $CONSUMERS{$target} = 1;
74              
75 1     1   7 my $type = do { no strict 'refs'; ${"$target\::USES_MITE"} };
  1         2  
  1         268  
  1         2  
  1         2  
  1         3  
76 1 50       4 return if $type ne 'Mite::Class';
77              
78 1         23 my @missing_methods;
79 1 50       5 @missing_methods = ()
80             and Mite::Shim::croak( "$me requires $target to implement methods: " . join q[, ], @missing_methods );
81              
82 1         6 my @roles = ( );
83 1 50       1 my %nextargs = %{ $args || {} };
  1         13  
84 1   50     40 ( $nextargs{-indirect} ||= 0 )++;
85 1 50       6 Mite::Shim::croak( "PANIC!" ) if $nextargs{-indirect} > 100;
86 1         2 for my $role ( @roles ) {
87 0         0 $role->__FINALIZE_APPLICATION__( $target, { %nextargs } );
88             }
89              
90 1         2 my $shim = "Mite::Shim";
91 1         2 for my $modifier_rule ( @METHOD_MODIFIERS ) {
92 0         0 my ( $modification, $names, $coderef ) = @$modifier_rule;
93 0         0 my $handler = "HANDLE_$modification";
94 0         0 $shim->$handler( $target, "class", $names, $coderef );
95             }
96              
97 1         15 return;
98             }
99              
100             1;
101             }{
102             package MyTest2;
103 1     1   8 use strict;
  1         2  
  1         37  
104 1     1   5 use warnings;
  1         1  
  1         38  
105 1     1   5 no warnings qw( once void );
  1         2  
  1         136  
106              
107             our $USES_MITE = "Mite::Class";
108             our $MITE_SHIM = "Mite::Shim";
109             our $MITE_VERSION = "0.012000";
110             # Mite keywords
111             BEGIN {
112 1     1   7 my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest2" );
113 1         2 ( *after, *around, *before, *extends, *has, *signature_for, *with ) = do {
114             package Mite::Shim;
115 1     1   7 no warnings 'redefine';
  1         8  
  1         202  
116             (
117 0         0 sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) },
118 0         0 sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) },
119 0         0 sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) },
120             sub {},
121 1         8 sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) },
122 0         0 sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) },
123 1         4 sub { $SHIM->HANDLE_with( $CALLER, @_ ) },
124 1         52 );
125             };
126             };
127              
128             # Gather metadata for constructor and destructor
129             sub __META__ {
130 1     1   6 no strict 'refs';
  1         2  
  1         658  
131 1   33 1   2 my $class = shift; $class = ref($class) || $class;
  1         4  
132 1         13 my $linear_isa = mro::get_linear_isa( $class );
133             return {
134             BUILD => [
135 1 50       2 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  1         6  
  0         0  
136 1         4 map { "$_\::BUILD" } reverse @$linear_isa
137             ],
138             DEMOLISH => [
139 1 50       2 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  1         15  
  0         0  
140 1         3 map { "$_\::DEMOLISH" } @$linear_isa
  1         10  
141             ],
142             HAS_BUILDARGS => $class->can('BUILDARGS'),
143             HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'),
144             };
145             }
146              
147              
148             # Standard Moose/Moo-style constructor
149             sub new {
150 1 50   1   186 my $class = ref($_[0]) ? ref(shift) : shift;
151 1   33     9 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
152 1         3 my $self = bless {}, $class;
153 1 50       4 my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ };
  0 50       0  
154 1         2 my $no_build = delete $args->{__no_BUILD__};
155              
156             # Attribute abc
157             # has declaration, file ../../../../tmp/djaSrpmWgK, line 7
158 1 50       17 $self->{"abc"} = ( exists( $args->{"abc"} ) ? $args->{"abc"} : "456" );
159              
160              
161             # Call BUILD methods
162 1 50 33     6 $self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } );
  1 50       5  
163              
164             # Unrecognized parameters
165 1 50       2 my @unknown = grep not( /\Aabc\z/ ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) );
  1         2  
  1         3  
166              
167 1         4 return $self;
168             }
169              
170             # Used by constructor to call BUILD methods
171             sub BUILDALL {
172 0     0   0 my $class = ref( $_[0] );
173 0   0     0 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
174 0 0       0 $_->( @_ ) for @{ $meta->{BUILD} || [] };
  0         0  
175             }
176              
177             # Destructor should call DEMOLISH methods
178             sub DESTROY {
179 1     1   2135 my $self = shift;
180 1   33     4 my $class = ref( $self ) || $self;
181 1   33     5 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
182 1 50       5 my $in_global_destruction = defined ${^GLOBAL_PHASE}
183             ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
184             : Devel::GlobalDestruction::in_global_destruction();
185 1 50       2 for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
  1         4  
186 0         0 my $e = do {
187 0         0 local ( $?, $@ );
188 0         0 eval { $demolisher->( $self, $in_global_destruction ) };
  0         0  
189 0         0 $@;
190             };
191 1     1   7 no warnings 'misc'; # avoid (in cleanup) warnings
  1         2  
  1         197  
192 0 0       0 die $e if $e; # rethrow
193             }
194 1         9 return;
195             }
196              
197             my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") };
198              
199             # Accessors for abc
200             # has declaration, file ../../../../tmp/djaSrpmWgK, line 7
201             if ( $__XS ) {
202             Class::XSAccessor->import(
203             chained => 1,
204             "getters" => { "abc" => "abc" },
205             );
206             }
207             else {
208             *abc = sub { @_ == 1 or Mite::Shim::croak( 'Reader "abc" usage: $self->abc()' ); $_[0]{"abc"} };
209             }
210              
211              
212             BEGIN {
213            
214            
215 1     1   199 our %DOES = ( "MyTest2" => 1, "MyTest1" => 1 );
216             }
217              
218             # See UNIVERSAL
219             sub DOES {
220 7     7   10 my ( $self, $role ) = @_;
221 7         8 our %DOES;
222 7 50       13 return $DOES{$role} if exists $DOES{$role};
223 7 50       12 return 1 if $role eq __PACKAGE__;
224 7 50 0     16 if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) {
      33        
225 0 0 0     0 $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1;
226             }
227 7         30 return $self->SUPER::DOES( $role );
228             }
229              
230             # Alias for Moose/Moo-compatibility
231             sub does {
232 7     7   684 shift->DOES( @_ );
233             }
234              
235             1;
236             }