File Coverage

/tmp/ScKyyJbNyr.mite.pm
Criterion Covered Total %
statement 65 118 55.0
branch 3 36 8.3
condition 1 27 3.7
subroutine 18 24 75.0
pod n/a
total 87 205 42.4


line stmt bran cond sub pod time code
1             {
2             use strict;
3 1     1   12 use warnings;
  1         2  
  1         72  
4 1     1   13 no warnings qw( once void );
  1         12  
  1         91  
5 1     1   11  
  1         10  
  1         303  
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", "MyTest2" );
12 1     1   14 ( *after, *around, *before, *extends, *field, *has, *param, *signature_for, *with ) = do {
13 1         9 no warnings 'redefine';
14             (
15 1     1   15 sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) },
  1         7  
  1         347  
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 2         17 );
25 0         0 };
26 1         294  
27             # Mite imports
28             BEGIN {
29             require Scalar::Util;
30             *STRICT = \&Mite::Shim::STRICT;
31             *bare = \&Mite::Shim::bare;
32 1     1   19 *blessed = \&Scalar::Util::blessed;
33 1         4 *carp = \&Mite::Shim::carp;
34 1         13 *confess = \&Mite::Shim::confess;
35 1         8 *croak = \&Mite::Shim::croak;
36 1         8 *false = \&Mite::Shim::false;
37 1         2 *guard = \&Mite::Shim::guard;
38 1         7 *lazy = \&Mite::Shim::lazy;
39 1         3 *lock = \&Mite::Shim::lock;
40 1         10 *ro = \&Mite::Shim::ro;
41 1         4 *rw = \&Mite::Shim::rw;
42 1         2 *rwp = \&Mite::Shim::rwp;
43 1         1 *true = \&Mite::Shim::true;
44 1         8 *unlock = \&Mite::Shim::unlock;
45 1         3 };
46 1         3  
47 1         54 # 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   12 BUILD => [
  1         2  
  1         770  
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   10 my ( $self, $role ) = @_;
  1         2  
  1         467  
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 24     24   35  
120 24         27 # Alias for Moose/Moo-compatibility
121 24 50       36 shift->DOES( @_ );
122 24 50       36 }
123 24 50 0     39  
      33        
124 0 0 0     0 # Method signatures
125             our %SIGNATURE_FOR;
126 24         96  
127             $SIGNATURE_FOR{"bar"} = sub {
128             my $__NEXT__ = shift;
129              
130             my ( %out, %in, %tmp, $tmp, $dtmp, @head );
131 24     24   1355  
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", "bar", 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 bar: %s should be %s", "\$_[0]", "Defined" );
141              
142             %in = ( @_ == 1 and (ref($_[0]) eq 'HASH') ) ? %{ $_[0] } : @_;
143              
144             # Parameter xxx (type: Num)
145             exists( $in{"xxx"} )
146             or croak( "Failure in signature for bar: " . 'Missing required parameter: xxx' );
147             or croak( "Type check failed in signature for bar: %s should be %s", "\$_{\"xxx\"}", "Num" );
148             $out{"xxx"} = $in{"xxx"} if exists( $in{"xxx"} );
149             delete( $in{"xxx"} );
150              
151             # Parameter yyy (type: Object)
152             exists( $in{"yyy"} )
153             or croak( "Failure in signature for bar: " . 'Missing required parameter: yyy' );
154             or croak( "Type check failed in signature for bar: %s should be %s", "\$_{\"yyy\"}", "Object" );
155             $out{"yyy"} = $in{"yyy"} if exists( $in{"yyy"} );
156             delete( $in{"yyy"} );
157 1     1   7  
  1         2  
  1         96  
158             # Unrecognized parameters
159             croak( "Failure in signature for bar: " . sprintf( q{Unrecognized parameter%s: %s}, keys( %in ) > 1 ? q{s} : q{}, join( q{, }, sort keys %in ) ) ) if keys %in;
160              
161             do { @_ = ( @head, bless( \%out, "MyTest2::__NAMED_ARGUMENTS__::bar" ) ); goto $__NEXT__ };
162             };
163              
164             {
165 1     1   7 use strict;
  1         1  
  1         227  
166             no warnings;
167             1;
168              
169             $SIGNATURE_FOR{"foo"} = sub {
170             my $__NEXT__ = shift;
171              
172             my ( %out, %in, %tmp, $tmp, $dtmp, @head );
173              
174             @_ == 2 && (ref($_[1]) eq 'HASH')
175             or @_ % 2 == 1 && @_ == 5
176             or croak( "Wrong number of parameters in signature for %s: got %d, %s", "foo", scalar( @_ ), "that does not seem right" );
177              
178 1     1   8 @head = splice( @_, 0, 1 );
  1         1  
  1         43  
179 1     1   6  
  1         6  
  1         651  
180 0     0   0 # Parameter invocant (type: Defined)
181 0     0   0 (defined($head[0]))
182             or croak( "Type check failed in signature for foo: %s should be %s", "\$_[0]", "Defined" );
183              
184             %in = ( @_ == 1 and (ref($_[0]) eq 'HASH') ) ? %{ $_[0] } : @_;
185              
186             # Parameter xxx (type: Int)
187             exists( $in{"xxx"} )
188             or croak( "Failure in signature for foo: " . 'Missing required parameter: xxx' );
189             (do { my $tmp = $in{"xxx"}; defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/ })
190             or croak( "Type check failed in signature for foo: %s should be %s", "\$_{\"xxx\"}", "Int" );
191             $out{"xxx"} = $in{"xxx"} if exists( $in{"xxx"} );
192             delete( $in{"xxx"} );
193              
194             # Parameter yyy (type: Bool)
195             exists( $in{"yyy"} )
196             or croak( "Failure in signature for foo: " . 'Missing required parameter: yyy' );
197             (!ref $tmp and (!defined $tmp or $tmp eq q() or $tmp eq '0' or $tmp eq '1'))
198             or croak( "Type check failed in signature for foo: %s should be %s", "\$_{\"yyy\"}", "Bool" );
199             $out{"yyy"} = $tmp;
200             delete( $in{"yyy"} );
201              
202             # Unrecognized parameters
203             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;
204              
205             do { @_ = ( @head, bless( \%out, "MyTest2::__NAMED_ARGUMENTS__::foo" ) ); goto $__NEXT__ };
206             };
207              
208             {
209             use strict;
210             no warnings;
211             1;
212              
213              
214             1;