File Coverage

/tmp/8lTe4z41t7.mite.pm
Criterion Covered Total %
statement 94 120 78.3
branch 30 64 46.8
condition 22 72 30.5
subroutine 15 16 93.7
pod n/a
total 161 272 59.1


line stmt bran cond sub pod time code
1             {
2             package Foo;
3 1     1   8 use strict;
  1         7  
  1         83  
4 1     1   21 use warnings;
  1         9  
  1         142  
5 1     1   11 no warnings qw( once void );
  1         7  
  1         367  
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   6 my ( $SHIM, $CALLER ) = ( "Mite::Shim", "Foo" );
13 1         2 ( *after, *around, *before, *extends, *has, *signature_for, *with ) = do {
14             package Mite::Shim;
15 1     1   19 no warnings 'redefine';
  1         3  
  1         340  
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 1         27 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         82 );
25             };
26             };
27              
28             # Gather metadata for constructor and destructor
29             sub __META__ {
30 1     1   27 no strict 'refs';
  1         9  
  1         1449  
31 1   33 1   3 my $class = shift; $class = ref($class) || $class;
  1         19  
32 1         9 my $linear_isa = mro::get_linear_isa( $class );
33             return {
34             BUILD => [
35 1 50       7 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  1         11  
  0         0  
36 1         7 map { "$_\::BUILD" } reverse @$linear_isa
37             ],
38             DEMOLISH => [
39 1 50       3 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  1         27  
  0         0  
40 1         9 map { "$_\::DEMOLISH" } @$linear_isa
  1         5  
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   268 my $class = ref($_[0]) ? ref(shift) : shift;
51 4   66     31 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
52 4         11 my $self = bless {}, $class;
53 4 50       33 my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ };
  0 50       0  
54 4         17 my $no_build = delete $args->{__no_BUILD__};
55              
56             # Attribute truth (type: Bool)
57             # has declaration, file ../../../../tmp/8lTe4z41t7, line 10
58 4 100 66     26 if ( exists $args->{"truth"} ) { do { my $coerced_value = do { my $to_coerce = $args->{"truth"}; ((!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", "truth", "Bool"; $self->{"truth"} = $coerced_value; }; } ;
  3 50 66     4  
  3 100 66     6  
  3         5  
  3         35  
  1         8  
  1         10  
  3         34  
  3         11  
59              
60              
61             # Call BUILD methods
62 4 50 33     16 $self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } );
  4 50       22  
63              
64             # Unrecognized parameters
65 4 50       9 my @unknown = grep not( /\Atruth\z/ ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) );
  4         29  
  4         14  
66              
67 4         24 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 4     4   4823 my $self = shift;
80 4   33     17 my $class = ref( $self ) || $self;
81 4   33     14 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
82 4 50       28 my $in_global_destruction = defined ${^GLOBAL_PHASE}
83             ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
84             : Devel::GlobalDestruction::in_global_destruction();
85 4 50       5 for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
  4         14  
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 1     1   16 no warnings 'misc'; # avoid (in cleanup) warnings
  1         11  
  1         1149  
92 0 0       0 die $e if $e; # rethrow
93             }
94 4         26 return;
95             }
96              
97             my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") };
98              
99             # Accessors for truth
100             # has declaration, file ../../../../tmp/8lTe4z41t7, line 10
101 4 50 33 4   36 sub truth { @_ > 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]{"truth"} = $value; $_[0]; } : do { ( exists($_[0]{"truth"}) ? $_[0]{"truth"} : ( $_[0]{"truth"} = do { my $default_value = do { my $to_coerce = $_[0]->_build_truth; ((!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", "truth", "Bool" ); $default_value } ) ) } }
  1 50 33     3  
  1 0 33     1  
  1 0 0     6  
  1 50 0     2  
  1 100 0     3  
  1         31  
  1         5  
  1         9  
  3         45  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
102 1 50 33 1   8 sub get_truth { @_ == 1 or Mite::Shim::croak( 'Reader "get_truth" usage: $self->get_truth()' ); ( exists($_[0]{"truth"}) ? $_[0]{"truth"} : ( $_[0]{"truth"} = do { my $default_value = do { my $to_coerce = $_[0]->_build_truth; ((!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", "truth", "Bool" ); $default_value } ) ) }
  1 50 33     4  
  1 50 33     2  
  1 50       5  
  1         7  
  1         2  
  1         4  
  1         26  
  1         9  
103 1 50 33 1   9 sub set_truth { @_ == 2 or Mite::Shim::croak( 'Writer "set_truth" usage: $self->set_truth( $newvalue )' ); 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", "writer", "Bool" ); $_[0]{"truth"} = $value; $_[0]; }
  1 50 33     2  
  1 50 33     8  
  1         9  
  1         3  
  1         3  
  1         20  
  1         5  
  1         2  
104              
105              
106             # See UNIVERSAL
107             sub DOES {
108 7     7   18 my ( $self, $role ) = @_;
109 7         9 our %DOES;
110 7 50       22 return $DOES{$role} if exists $DOES{$role};
111 7 50       22 return 1 if $role eq __PACKAGE__;
112 7 50 0     25 if ( $INC{'Moose/Util.pm'} and my $meta = Moose::Util::find_meta( ref $self or $self ) ) {
      33        
113 0 0 0     0 $meta->can( 'does_role' ) and $meta->does_role( $role ) and return 1;
114             }
115 7         60 return $self->SUPER::DOES( $role );
116             }
117              
118             # Alias for Moose/Moo-compatibility
119             sub does {
120 7     7   3591 shift->DOES( @_ );
121             }
122              
123             1;
124             }