File Coverage

/tmp/bNyrSsGBRy.mite.pm
Criterion Covered Total %
statement 97 156 62.1
branch 6 44 13.6
condition 2 36 5.5
subroutine 24 28 85.7
pod n/a
total 129 264 48.8


line stmt bran cond sub pod time code
1             {
2             use strict;
3 1     1   15 use warnings;
  1         5  
  1         73  
4 1     1   15 no warnings qw( once void );
  1         7  
  1         91  
5 1     1   8  
  1         2  
  1         267  
6             our $USES_MITE = "Mite::Class";
7             our $MITE_SHIM = "Mite::Shim";
8             our $MITE_VERSION = "0.011000";
9             # Mite keywords
10             BEGIN {
11             my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest1" );
12 1     1   10 ( *after, *around, *before, *extends, *field, *has, *param, *signature_for, *with ) = do {
13 1         9 no warnings 'redefine';
14             (
15 1     1   12 sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) },
  1         2  
  1         330  
16             sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) },
17 0         0 sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) },
18 0         0 sub {},
19 0         0 sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) },
20             sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) },
21 0         0 sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) },
22 0         0 sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) },
23 0         0 sub { $SHIM->HANDLE_with( $CALLER, @_ ) },
24 1         13 );
25 0         0 };
26 1         320  
27             # Mite imports
28             BEGIN {
29             require Scalar::Util;
30             *STRICT = \&Mite::Shim::STRICT;
31             *bare = \&Mite::Shim::bare;
32 1     1   27 *blessed = \&Scalar::Util::blessed;
33 1         11 *carp = \&Mite::Shim::carp;
34 1         3 *confess = \&Mite::Shim::confess;
35 1         2 *croak = \&Mite::Shim::croak;
36 1         7 *false = \&Mite::Shim::false;
37 1         3 *guard = \&Mite::Shim::guard;
38 1         6 *lazy = \&Mite::Shim::lazy;
39 1         5 *lock = \&Mite::Shim::lock;
40 1         6 *ro = \&Mite::Shim::ro;
41 1         2 *rw = \&Mite::Shim::rw;
42 1         3 *rwp = \&Mite::Shim::rwp;
43 1         14 *true = \&Mite::Shim::true;
44 1         3 *unlock = \&Mite::Shim::unlock;
45 1         6 };
46 1         5  
47 1         44 # Gather metadata for constructor and destructor
48             no strict 'refs';
49             my $class = shift; $class = ref($class) || $class;
50             my $linear_isa = mro::get_linear_isa( $class );
51             return {
52 1     1   7 BUILD => [
  1         3  
  1         760  
53 0   0 0   0 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  0         0  
54 0         0 map { "$_\::BUILD" } reverse @$linear_isa
55             ],
56             DEMOLISH => [
57 0 0       0 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  0         0  
  0         0  
58 0         0 map { "$_\::DEMOLISH" } @$linear_isa
59             ],
60             HAS_BUILDARGS => $class->can('BUILDARGS'),
61 0 0       0 HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'),
  0         0  
  0         0  
62 0         0 };
  0         0  
63             }
64              
65              
66             # Standard Moose/Moo-style constructor
67             my $class = ref($_[0]) ? ref(shift) : shift;
68             my $meta = ( $Mite::META{$class} ||= $class->__META__ );
69             my $self = bless {}, $class;
70             my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ };
71             my $no_build = delete $args->{__no_BUILD__};
72 0 0   0   0  
73 0   0     0  
74 0         0  
75 0 0       0 # Call BUILD methods
  0 0       0  
76 0         0 $self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } );
77              
78             # Unrecognized parameters
79              
80             return $self;
81 0 0 0     0 }
  0 0       0  
82              
83             # Used by constructor to call BUILD methods
84 0 0       0 my $class = ref( $_[0] );
  0 0       0  
  0 0       0  
  0         0  
  0         0  
85             my $meta = ( $Mite::META{$class} ||= $class->__META__ );
86 0         0 $_->( @_ ) for @{ $meta->{BUILD} || [] };
87             }
88              
89             # Destructor should call DEMOLISH methods
90             my $self = shift;
91 0     0   0 my $class = ref( $self ) || $self;
92 0   0     0 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
93 0 0       0 my $in_global_destruction = defined ${^GLOBAL_PHASE}
  0         0  
94             ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
95             : Devel::GlobalDestruction::in_global_destruction();
96             for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
97             my $e = do {
98 0     0   0 local ( $?, $@ );
99 0   0     0 eval { $demolisher->( $self, $in_global_destruction ) };
100 0   0     0 $@;
101 0 0       0 };
102             no warnings 'misc'; # avoid (in cleanup) warnings
103             die $e if $e; # rethrow
104 0 0       0 }
  0         0  
105 0         0 return;
106 0         0 }
107 0         0  
  0         0  
108 0         0  
109             # See UNIVERSAL
110 1     1   7 my ( $self, $role ) = @_;
  1         2  
  1         819  
111 0 0       0 our %DOES;
112             return $DOES{$role} if exists $DOES{$role};
113 0         0 return 1 if $role eq __PACKAGE__;
114             if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) {
115             $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1;
116             }
117             return $self->SUPER::DOES( $role );
118             }
119 48     48   94  
120 48         45 # Alias for Moose/Moo-compatibility
121 48 50       70 shift->DOES( @_ );
122 48 50       64 }
123 48 50 0     76  
      33        
124 0 0 0     0 # Method signatures
125             our %SIGNATURE_FOR;
126 48         192  
127             $SIGNATURE_FOR{"foo"} = sub {
128             my $__NEXT__ = shift;
129              
130             my ( %out, %in, %tmp, $tmp, $dtmp, @head );
131 24     24   1169  
132             @_ == 2 && (ref($_[1]) eq 'HASH')
133             or @_ % 2 == 1 && @_ == 5
134             or croak( "Wrong number of parameters in signature for %s: got %d, %s", "foo", scalar( @_ ), "that does not seem right" );
135              
136             @head = splice( @_, 0, 1 );
137              
138             # Parameter invocant (type: Defined)
139             (defined($head[0]))
140             or croak( "Type check failed in signature for foo: %s should be %s", "\$_[0]", "Defined" );
141              
142             %in = ( @_ == 1 and (ref($_[0]) eq 'HASH') ) ? %{ $_[0] } : @_;
143              
144             # Parameter xxx (type: Int)
145             exists( $in{"xxx"} )
146             or croak( "Failure in signature for foo: " . 'Missing required parameter: xxx' );
147             (do { my $tmp = $in{"xxx"}; defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/ })
148             or croak( "Type check failed in signature for foo: %s should be %s", "\$_{\"xxx\"}", "Int" );
149             $out{"xxx"} = $in{"xxx"} if exists( $in{"xxx"} );
150             delete( $in{"xxx"} );
151              
152             # Parameter yyy (type: Bool)
153             exists( $in{"yyy"} )
154             or croak( "Failure in signature for foo: " . 'Missing required parameter: yyy' );
155             (!ref $tmp and (!defined $tmp or $tmp eq q() or $tmp eq '0' or $tmp eq '1'))
156             or croak( "Type check failed in signature for foo: %s should be %s", "\$_{\"yyy\"}", "Bool" );
157             $out{"yyy"} = $tmp;
158             delete( $in{"yyy"} );
159              
160             # Unrecognized parameters
161             croak( "Failure in signature for foo: " . sprintf( q{Unrecognized parameter%s: %s}, keys( %in ) > 1 ? q{s} : q{}, join( q{, }, sort keys %in ) ) ) if keys %in;
162              
163             do { @_ = ( @head, bless( \%out, "MyTest1::__NAMED_ARGUMENTS__::foo" ) ); goto $__NEXT__ };
164             };
165              
166             {
167             use strict;
168             no warnings;
169             1;
170              
171              
172             1;
173             use strict;
174             use warnings;
175             no warnings qw( once void );
176              
177             our $USES_MITE = "Mite::Class";
178             our $MITE_SHIM = "Mite::Shim";
179 1     1   8 our $MITE_VERSION = "0.011000";
  1         3  
  1         44  
180 1     1   6 # Mite keywords
  1         2  
  1         130  
181 2     2   9 BEGIN {
182 2     2   22 my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest2" );
183             ( *after, *around, *before, *extends, *field, *has, *param, *signature_for, *with ) = do {
184             no warnings 'redefine';
185             (
186             sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) },
187             sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) },
188             sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) },
189             sub {},
190 1     1   8 sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) },
  1         1  
  1         20  
191 1     1   4 sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) },
  1         2  
  1         34  
192 1     1   6 sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) },
  1         3  
  1         127  
193             sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) },
194             sub { $SHIM->HANDLE_with( $CALLER, @_ ) },
195             );
196             };
197              
198             # Mite imports
199 1     1   4 BEGIN {
200 1         2 require Scalar::Util;
201             *STRICT = \&Mite::Shim::STRICT;
202 1     1   10 *bare = \&Mite::Shim::bare;
  1         3  
  1         226  
203             *blessed = \&Scalar::Util::blessed;
204 0         0 *carp = \&Mite::Shim::carp;
205 0         0 *confess = \&Mite::Shim::confess;
206 0         0 *croak = \&Mite::Shim::croak;
207             *false = \&Mite::Shim::false;
208 0         0 *guard = \&Mite::Shim::guard;
209 0         0 *lazy = \&Mite::Shim::lazy;
210 0         0 *lock = \&Mite::Shim::lock;
211 1         5 *ro = \&Mite::Shim::ro;
212 0         0 *rw = \&Mite::Shim::rw;
213 1         200 *rwp = \&Mite::Shim::rwp;
214             *true = \&Mite::Shim::true;
215             *unlock = \&Mite::Shim::unlock;
216             };
217              
218              
219 1     1   7 BEGIN {
220 1         3
221 1         2
222 1         11 use mro 'c3';
223 1         3 our @ISA;
224 1         2 push @ISA, "MyTest1";
225 1         5 }
226 1         10  
227 1         2  
228 1         2 # See UNIVERSAL
229 1         2 my ( $self, $role ) = @_;
230 1         2 our %DOES;
231 1         8 return $DOES{$role} if exists $DOES{$role};
232 1         2 return 1 if $role eq __PACKAGE__;
233 1         2 if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) {
234 1         36 $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1;
235             }
236             return $self->SUPER::DOES( $role );
237             }
238              
239             # Alias for Moose/Moo-compatibility
240             shift->DOES( @_ );
241 1     1   8 }
  1         6  
  1         24  
242 1     1   57  
243 1         279 # Method signatures
244             our %SIGNATURE_FOR;
245              
246             $SIGNATURE_FOR{"foo"} = $MyTest1::SIGNATURE_FOR{"foo"};
247              
248              
249 24     24   33 1;