File Coverage

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