File Coverage

/tmp/5RWkZRrKKD.mite.pm
Criterion Covered Total %
statement 61 80 76.2
branch 18 38 47.3
condition 7 27 25.9
subroutine 12 13 92.3
pod n/a
total 98 158 62.0


line stmt bran cond sub pod time code
1             {
2             package MyTestXX;
3 1     1   17 use strict;
  1         3  
  1         59  
4 1     1   14 use warnings;
  1         6  
  1         90  
5 1     1   16 no warnings qw( once void );
  1         7  
  1         273  
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   15 my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTestXX" );
13 1         7 ( *after, *around, *before, *extends, *has, *signature_for, *with ) = do {
14             package Mite::Shim;
15 1     1   13 no warnings 'redefine';
  1         7  
  1         293  
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 3         25 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         63 );
25             };
26             };
27              
28             # Gather metadata for constructor and destructor
29             sub __META__ {
30 1     1   7 no strict 'refs';
  1         6  
  1         841  
31 1   33 1   3 my $class = shift; $class = ref($class) || $class;
  1         6  
32 1         12 my $linear_isa = mro::get_linear_isa( $class );
33             return {
34             BUILD => [
35 1 50       7 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  1         10  
  0         0  
36 1         4 map { "$_\::BUILD" } reverse @$linear_isa
37             ],
38             DEMOLISH => [
39 1 50       2 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  1         31  
  0         0  
40 1         7 map { "$_\::DEMOLISH" } @$linear_isa
  1         10  
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 4 50   4   4694 my $class = ref($_[0]) ? ref(shift) : shift;
51 4   66     23 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
52 4         9 my $self = bless {}, $class;
53 4 50       29 my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ };
  0 50       0  
54 4         5 my $no_build = delete $args->{__no_BUILD__};
55              
56             # Attribute foo
57             # has declaration, file ../../../../tmp/5RWkZRrKKD, line 3
58 4 50       15 $self->{"foo"} = ( exists( $args->{"foo"} ) ? $args->{"foo"} : "99" );
59              
60             # Attribute foo2
61             # has declaration, file ../../../../tmp/5RWkZRrKKD, line 3
62 4 50       15 $self->{"foo2"} = ( exists( $args->{"foo2"} ) ? $args->{"foo2"} : "99" );
63              
64             # Attribute xxx
65             # has declaration, file ../../../../tmp/5RWkZRrKKD, line 6
66 4 100       10 if ( exists $args->{"xxxx"} ) { $self->{"xxx"} = $args->{"xxxx"}; } ;
  1         6  
67              
68              
69             # Call BUILD methods
70 4 50 33     21 $self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } );
  4 50       20  
71              
72             # Unrecognized parameters
73 4 100       7 my @unknown = grep not( /\A(?:foo2?|xxxx)\z/ ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) );
  4         27  
  4         44  
74              
75 1         25 return $self;
76             }
77              
78             # Used by constructor to call BUILD methods
79             sub BUILDALL {
80 0     0   0 my $class = ref( $_[0] );
81 0   0     0 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
82 0 0       0 $_->( @_ ) for @{ $meta->{BUILD} || [] };
  0         0  
83             }
84              
85             # Destructor should call DEMOLISH methods
86             sub DESTROY {
87 4     4   621 my $self = shift;
88 4   33     11 my $class = ref( $self ) || $self;
89 4   33     13 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
90 4 50       64 my $in_global_destruction = defined ${^GLOBAL_PHASE}
91             ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
92             : Devel::GlobalDestruction::in_global_destruction();
93 4 50       8 for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
  4         11  
94 0         0 my $e = do {
95 0         0 local ( $?, $@ );
96 0         0 eval { $demolisher->( $self, $in_global_destruction ) };
  0         0  
97 0         0 $@;
98             };
99 1     1   14 no warnings 'misc'; # avoid (in cleanup) warnings
  1         3  
  1         648  
100 0 0       0 die $e if $e; # rethrow
101             }
102 4         31 return;
103             }
104              
105             my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") };
106              
107             # Accessors for foo
108             # has declaration, file ../../../../tmp/5RWkZRrKKD, line 3
109             if ( $__XS ) {
110             Class::XSAccessor->import(
111             chained => 1,
112             "accessors" => { "foo" => "foo" },
113             );
114             }
115             else {
116             *foo = sub { @_ > 1 ? do { $_[0]{"foo"} = $_[1]; $_[0]; } : ( $_[0]{"foo"} ) };
117             }
118              
119             # Accessors for foo2
120             # has declaration, file ../../../../tmp/5RWkZRrKKD, line 3
121             if ( $__XS ) {
122             Class::XSAccessor->import(
123             chained => 1,
124             "accessors" => { "foo2" => "foo2" },
125             );
126             }
127             else {
128             *foo2 = sub { @_ > 1 ? do { $_[0]{"foo2"} = $_[1]; $_[0]; } : ( $_[0]{"foo2"} ) };
129             }
130              
131             # Accessors for xxx
132             # has declaration, file ../../../../tmp/5RWkZRrKKD, line 6
133             if ( $__XS ) {
134             Class::XSAccessor->import(
135             chained => 1,
136             "getters" => { "xxx" => "xxx" },
137             );
138             }
139             else {
140             *xxx = sub { @_ == 1 or Mite::Shim::croak( 'Reader "xxx" usage: $self->xxx()' ); $_[0]{"xxx"} };
141             }
142              
143             # Accessors for yyy
144             # has declaration, file ../../../../tmp/5RWkZRrKKD, line 7
145             if ( $__XS ) {
146             Class::XSAccessor->import(
147             chained => 1,
148             "getters" => { "yyy" => "yyy" },
149             );
150             }
151             else {
152             *yyy = sub { @_ == 1 or Mite::Shim::croak( 'Reader "yyy" usage: $self->yyy()' ); $_[0]{"yyy"} };
153             }
154              
155              
156             # See UNIVERSAL
157             sub DOES {
158 7     7   12 my ( $self, $role ) = @_;
159 7         8 our %DOES;
160 7 50       14 return $DOES{$role} if exists $DOES{$role};
161 7 50       19 return 1 if $role eq __PACKAGE__;
162 7 50 0     25 if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) {
      33        
163 0 0 0     0 $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1;
164             }
165 7         42 return $self->SUPER::DOES( $role );
166             }
167              
168             # Alias for Moose/Moo-compatibility
169             sub does {
170 7     7   2845 shift->DOES( @_ );
171             }
172              
173             1;
174             }