File Coverage

/tmp/ctMQdGjj74.mite.pm
Criterion Covered Total %
statement 43 94 45.7
branch 3 36 8.3
condition 1 27 3.7
subroutine 10 14 71.4
pod n/a
total 57 171 33.3


line stmt bran cond sub pod time code
1             {
2             use strict;
3 4     4   24 use warnings;
  4         8  
  4         148  
4 4     4   28 no warnings qw( once void );
  4         8  
  4         144  
5 4     4   16  
  4         4  
  4         564  
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", "MyTest4" );
12 4     4   16 ( *after, *around, *before, *extends, *field, *has, *param, *signature_for, *with ) = do {
13 4         12 no warnings 'redefine';
14             (
15 4     4   24 sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) },
  4         36  
  4         1052  
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 4         28 );
25 0         0 };
26 4         744  
27             # Mite imports
28             BEGIN {
29             require Scalar::Util;
30             *STRICT = \&Mite::Shim::STRICT;
31             *bare = \&Mite::Shim::bare;
32 4     4   24 *blessed = \&Scalar::Util::blessed;
33 4         12 *carp = \&Mite::Shim::carp;
34 4         8 *confess = \&Mite::Shim::confess;
35 4         8 *croak = \&Mite::Shim::croak;
36 4         8 *false = \&Mite::Shim::false;
37 4         4 *guard = \&Mite::Shim::guard;
38 4         4 *lazy = \&Mite::Shim::lazy;
39 4         8 *ro = \&Mite::Shim::ro;
40 4         8 *rw = \&Mite::Shim::rw;
41 4         4 *rwp = \&Mite::Shim::rwp;
42 4         4 *true = \&Mite::Shim::true;
43 4         8 };
44 4         4  
45 4         136 # Gather metadata for constructor and destructor
46             no strict 'refs';
47             my $class = shift; $class = ref($class) || $class;
48             my $linear_isa = mro::get_linear_isa( $class );
49             return {
50 4     4   20 BUILD => [
  4         4  
  4         2248  
51 0   0 0   0 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  0         0  
52 0         0 map { "$_\::BUILD" } reverse @$linear_isa
53             ],
54             DEMOLISH => [
55 0 0       0 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  0         0  
  0         0  
56 0         0 map { "$_\::DEMOLISH" } @$linear_isa
57             ],
58             HAS_BUILDARGS => $class->can('BUILDARGS'),
59 0 0       0 HAS_FOREIGNBUILDARGS => $class->can('FOREIGNBUILDARGS'),
  0         0  
  0         0  
60 0         0 };
  0         0  
61             }
62              
63              
64             # Standard Moose/Moo-style constructor
65             my $class = ref($_[0]) ? ref(shift) : shift;
66             my $meta = ( $Mite::META{$class} ||= $class->__META__ );
67             my $self = bless {}, $class;
68             my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ };
69             my $no_build = delete $args->{__no_BUILD__};
70 0 0   0   0  
71 0   0     0  
72 0         0  
73 0 0       0 # Call BUILD methods
  0 0       0  
74 0         0 $self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } );
75              
76             # Unrecognized parameters
77              
78             return $self;
79 0 0 0     0 }
  0 0       0  
80              
81             # Used by constructor to call BUILD methods
82 0 0       0 my $class = ref( $_[0] );
  0 0       0  
  0 0       0  
  0         0  
  0         0  
83             my $meta = ( $Mite::META{$class} ||= $class->__META__ );
84 0         0 $_->( @_ ) for @{ $meta->{BUILD} || [] };
85             }
86              
87             # Destructor should call DEMOLISH methods
88             my $self = shift;
89 0     0   0 my $class = ref( $self ) || $self;
90 0   0     0 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
91 0 0       0 my $in_global_destruction = defined ${^GLOBAL_PHASE}
  0         0  
92             ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
93             : Devel::GlobalDestruction::in_global_destruction();
94             for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
95             my $e = do {
96 0     0   0 local ( $?, $@ );
97 0   0     0 eval { $demolisher->( $self, $in_global_destruction ) };
98 0   0     0 $@;
99 0 0       0 };
100             no warnings 'misc'; # avoid (in cleanup) warnings
101             die $e if $e; # rethrow
102 0 0       0 }
  0         0  
103 0         0 return;
104 0         0 }
105 0         0  
  0         0  
106 0         0  
107             # See UNIVERSAL
108 4     4   24 my ( $self, $role ) = @_;
  4         8  
  4         1964  
109 0 0       0 our %DOES;
110             return $DOES{$role} if exists $DOES{$role};
111 0         0 return 1 if $role eq __PACKAGE__;
112             if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) {
113             $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1;
114             }
115             return $self->SUPER::DOES( $role );
116             }
117 88     88   108  
118 88         64 # Alias for Moose/Moo-compatibility
119 88 50       120 shift->DOES( @_ );
120 88 50       100 }
121 88 50 0     128  
      33        
122 0 0 0     0 # Method signatures
123             our %SIGNATURE_FOR;
124 88         328  
125             $SIGNATURE_FOR{"foo"} = sub {
126             my $__NEXT__ = shift;
127              
128             my ( @out, %tmp, $tmp, $dtmp, @head );
129 88     88   9624  
130             @_ == 2
131             or croak( "Wrong number of parameters in signature for %s: got %d, %s", "foo", scalar( @_ ), "expected exactly 2 parameters" );
132              
133             @head = splice( @_, 0, 0 );
134              
135             # Parameter $_[0] (type: Int)
136             (do { my $tmp = $_[0]; defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/ })
137             or croak( "Type check failed in signature for foo: %s should be %s", "\$_[0]", "Int" );
138             push( @out, $_[0] );
139              
140             # Parameter $_[1] (type: Bool)
141             $tmp = ((!ref $_[1] and (!defined $_[1] or $_[1] eq q() or $_[1] eq '0' or $_[1] eq '1'))) ? $_[1] : ((!!1)) ? scalar(do { local $_ = $_[1]; !!$_ }) : $_[1];
142             (!ref $tmp and (!defined $tmp or $tmp eq q() or $tmp eq '0' or $tmp eq '1'))
143             or croak( "Type check failed in signature for foo: %s should be %s", "\$_[1]", "Bool" );
144             push( @out, $tmp );
145              
146             do { @_ = ( @head, @out ); goto $__NEXT__ };
147             };
148              
149              
150             1;