File Coverage

/tmp/RD3UeTP8Zo.mite.pm
Criterion Covered Total %
statement 83 102 81.3
branch 25 50 50.0
condition 16 54 29.6
subroutine 13 14 92.8
pod n/a
total 137 220 62.2


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