File Coverage

/tmp/S3ywj8oNL4.mite.pm
Criterion Covered Total %
statement 73 93 78.4
branch 23 46 50.0
condition 7 27 25.9
subroutine 14 15 93.3
pod n/a
total 117 181 64.6


line stmt bran cond sub pod time code
1             {
2             package MyTest4;
3 3     3   51 use strict;
  3         21  
  3         273  
4 3     3   33 use warnings;
  3         51  
  3         420  
5 3     3   51 no warnings qw( once void );
  3         24  
  3         1086  
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 3     3   33 my ( $SHIM, $CALLER ) = ( "Mite::Shim", "MyTest4" );
13 3         15 ( *after, *around, *before, *extends, *has, *signature_for, *with ) = do {
14             package Mite::Shim;
15 3     3   42 no warnings 'redefine';
  3         399  
  3         1176  
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 6         84 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 3         384 );
25             };
26             };
27              
28             # Gather metadata for constructor and destructor
29             sub __META__ {
30 3     3   138 no strict 'refs';
  3         15  
  3         4011  
31 3   33 3   6 my $class = shift; $class = ref($class) || $class;
  3         18  
32 3         18 my $linear_isa = mro::get_linear_isa( $class );
33             return {
34             BUILD => [
35 3 50       6 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  3         72  
  0         0  
36 3         12 map { "$_\::BUILD" } reverse @$linear_isa
37             ],
38             DEMOLISH => [
39 3 50       9 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  3         66  
  0         0  
40 3         9 map { "$_\::DEMOLISH" } @$linear_isa
  3         12  
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 6 50   6   777 my $class = ref($_[0]) ? ref(shift) : shift;
51 6   66     48 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
52 6         42 my $self = bless {}, $class;
53 6 50       42 my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ };
  0 50       0  
54 6         15 my $no_build = delete $args->{__no_BUILD__};
55              
56             # Attribute attr
57             # has declaration, file ../../../../tmp/S3ywj8oNL4, line 3
58 6 100       21 if ( exists $args->{"attr"} ) { $self->{"attr"} = $args->{"attr"}; $self->_trigger_attr( $self->{"attr"} ); } ;
  3         21  
  3         36  
59              
60             # Attribute log
61             # has declaration, file ../../../../tmp/S3ywj8oNL4, line 12
62 6 50       30 if ( exists $args->{"log"} ) { $self->{"log"} = $args->{"log"}; } ;
  0         0  
63              
64              
65             # Call BUILD methods
66 6 50 33     27 $self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } );
  6 50       36  
67              
68             # Unrecognized parameters
69 6 50       12 my @unknown = grep not( /\A(?:attr|log)\z/ ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) );
  6         48  
  6         33  
70              
71 6         69 return $self;
72             }
73              
74             # Used by constructor to call BUILD methods
75             sub BUILDALL {
76 0     0   0 my $class = ref( $_[0] );
77 0   0     0 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
78 0 0       0 $_->( @_ ) for @{ $meta->{BUILD} || [] };
  0         0  
79             }
80              
81             # Destructor should call DEMOLISH methods
82             sub DESTROY {
83 6     6   19218 my $self = shift;
84 6   33     27 my $class = ref( $self ) || $self;
85 6   33     21 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
86 6 50       27 my $in_global_destruction = defined ${^GLOBAL_PHASE}
87             ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
88             : Devel::GlobalDestruction::in_global_destruction();
89 6 50       12 for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
  6         27  
90 0         0 my $e = do {
91 0         0 local ( $?, $@ );
92 0         0 eval { $demolisher->( $self, $in_global_destruction ) };
  0         0  
93 0         0 $@;
94             };
95 3     3   75 no warnings 'misc'; # avoid (in cleanup) warnings
  3         54  
  3         2277  
96 0 0       0 die $e if $e; # rethrow
97             }
98 6         30 return;
99             }
100              
101             my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") };
102              
103             # Accessors for attr
104             # has declaration, file ../../../../tmp/S3ywj8oNL4, line 3
105 15 50   15   1947 sub attr { @_ > 1 ? do { my @oldvalue; @oldvalue = $_[0]{"attr"} if exists $_[0]{"attr"}; $_[0]{"attr"} = $_[1]; $_[0]->_trigger_attr( $_[0]{"attr"}, @oldvalue ); $_[0]; } : do { ( exists($_[0]{"attr"}) ? $_[0]{"attr"} : ( $_[0]{"attr"} = do { my $default = "default"; $_[0]->_trigger_attr( $default ); $default } ) ) } }
  12 50       36  
  12 100       51  
  12         66  
  12         54  
  12         36  
  3         24  
  3         9  
  3         12  
  3         27  
106              
107             # Accessors for log
108             # has declaration, file ../../../../tmp/S3ywj8oNL4, line 12
109 24 50   24   81 sub log { @_ == 1 or Mite::Shim::croak( 'Reader "log" usage: $self->log()' ); ( exists($_[0]{"log"}) ? $_[0]{"log"} : ( $_[0]{"log"} = $MyTest4::__log_DEFAULT__->( $_[0] ) ) ) }
  24 100       312  
110              
111              
112             # See UNIVERSAL
113             sub DOES {
114 21     21   45 my ( $self, $role ) = @_;
115 21         48 our %DOES;
116 21 50       69 return $DOES{$role} if exists $DOES{$role};
117 21 50       39 return 1 if $role eq __PACKAGE__;
118 21 50 0     81 if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) {
      33        
119 0 0 0     0 $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1;
120             }
121 21         366 return $self->SUPER::DOES( $role );
122             }
123              
124             # Alias for Moose/Moo-compatibility
125             sub does {
126 21     21   3630 shift->DOES( @_ );
127             }
128              
129             1;
130             }