File Coverage

/tmp/kLW9nGtjcI.mite.pm
Criterion Covered Total %
statement 57 84 67.8
branch 15 38 39.4
condition 6 27 22.2
subroutine 14 24 58.3
pod n/a
total 92 173 53.1


line stmt bran cond sub pod time code
1             {
2             use strict;
3 1     1   5 use warnings;
  1         1  
  1         25  
4 1     1   5 no warnings qw( once void );
  1         1  
  1         26  
5 1     1   3  
  1         2  
  1         121  
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, *field, *has, *param, *signature_for, *with ) = do {
13 1         2 no warnings 'redefine';
14             (
15 1     1   14 sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) },
  1         4  
  1         198  
16             sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) },
17 0     0   0 sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) },
18 0     0   0 sub {},
19 0     0   0 sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) },
20       0     sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) },
21 1     1   3 sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) },
22 0     0   0 sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) },
23 1     1   6 sub { $SHIM->HANDLE_with( $CALLER, @_ ) },
24 0     0   0 );
25 0     0   0 };
26 1         60  
27             # Mite imports
28             BEGIN {
29             *false = \&Mite::Shim::false;
30             *true = \&Mite::Shim::true;
31             };
32 1     1   4  
33 1         20 # Gather metadata for constructor and destructor
34             no strict 'refs';
35             my $class = shift; $class = ref($class) || $class;
36             my $linear_isa = mro::get_linear_isa( $class );
37             return {
38 1     1   5 BUILD => [
  1         10  
  1         546  
39 1   33 1   3 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  1         5  
40 1         6 map { "$_\::BUILD" } reverse @$linear_isa
41             ],
42             DEMOLISH => [
43 1 50       1 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  1         6  
  0         0  
44 1         4 map { "$_\::DEMOLISH" } @$linear_isa
45             ],
46             HAS_BUILDARGS => $class->can('BUILDARGS'),
47 1 50       1 HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'),
  1         17  
  0         0  
48 1         3 };
  1         3  
49             }
50              
51              
52             # Standard Moose/Moo-style constructor
53             my $class = ref($_[0]) ? ref(shift) : shift;
54             my $meta = ( $Mite::META{$class} ||= $class->__META__ );
55             my $self = bless {}, $class;
56             my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ };
57             my $no_build = delete $args->{__no_BUILD__};
58 3 50   3   2438  
59 3   66     12 # Attribute foo
60 3         5 # param declaration, file ../../../../tmp/kLW9nGtjcI, line 3
61 3 50       12 Mite::Shim::croak "Missing key in constructor: foo" unless exists $args->{"foo"};
  0 50       0  
62 3         4 $self->{"foo"} = $args->{"foo"};
63              
64              
65             # Call BUILD methods
66 3 100       9 $self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } );
67 2         5  
68             # Unrecognized parameters
69             my @unknown = grep not( /\Afoo\z/ ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) );
70              
71 2 50 33     6 return $self;
  2 50       8  
72             }
73              
74 2 100       2 # Used by constructor to call BUILD methods
  2         12  
  2         10  
75             my $class = ref( $_[0] );
76 1         3 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
77             $_->( @_ ) for @{ $meta->{BUILD} || [] };
78             }
79              
80             # Destructor should call DEMOLISH methods
81 0     0   0 my $self = shift;
82 0   0     0 my $class = ref( $self ) || $self;
83 0 0       0 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
  0         0  
84             my $in_global_destruction = defined ${^GLOBAL_PHASE}
85             ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
86             : Devel::GlobalDestruction::in_global_destruction();
87             for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
88 3     3   482 my $e = do {
89 3   33     9 local ( $?, $@ );
90 3   33     19 eval { $demolisher->( $self, $in_global_destruction ) };
91 3 50       11 $@;
92             };
93             no warnings 'misc'; # avoid (in cleanup) warnings
94 3 50       4 die $e if $e; # rethrow
  3         16  
95 0         0 }
96 0         0 return;
97 0         0 }
  0         0  
98 0         0  
99             my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") };
100 1     1   6  
  1         2  
  1         351  
101 0 0       0 # Accessors for bar
102             # field declaration, file ../../../../tmp/kLW9nGtjcI, line 4
103 3         11  
104             # Accessors for foo
105             # param declaration, file ../../../../tmp/kLW9nGtjcI, line 3
106             if ( $__XS ) {
107             Class::XSAccessor->import(
108             chained => 1,
109             "getters" => { "foo" => "foo" },
110 1 50   1   829 );
  1 50       4  
111             }
112             else {
113             *foo = sub { @_ == 1 or Mite::Shim::croak( 'Reader "foo" usage: $self->foo()' ); $_[0]{"foo"} };
114             }
115              
116              
117             # See UNIVERSAL
118             my ( $self, $role ) = @_;
119             our %DOES;
120             return $DOES{$role} if exists $DOES{$role};
121             return 1 if $role eq __PACKAGE__;
122             if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) {
123             $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1;
124             }
125             return $self->SUPER::DOES( $role );
126             }
127 0     0      
128 0           # Alias for Moose/Moo-compatibility
129 0 0         shift->DOES( @_ );
130 0 0         }
131 0 0 0        
      0        
132 0 0 0       1;