File Coverage

/tmp/fRmwS3ywj8.mite.pm
Criterion Covered Total %
statement 149 178 83.7
branch 45 88 51.1
condition 15 54 27.7
subroutine 32 35 91.4
pod n/a
total 241 355 67.8


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