File Coverage

/tmp/eTP8ZoGrc4.mite.pm
Criterion Covered Total %
statement 71 90 78.8
branch 21 44 47.7
condition 11 39 28.2
subroutine 13 14 92.8
pod n/a
total 116 187 62.0


line stmt bran cond sub pod time code
1             {
2             package FooPos;
3 3     3   45 use strict;
  3         33  
  3         318  
4 3     3   51 use warnings;
  3         54  
  3         417  
5 3     3   54 no warnings qw( once void );
  3         18  
  3         1050  
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   39 my ( $SHIM, $CALLER ) = ( "Mite::Shim", "FooPos" );
13 3         21 ( *after, *around, *before, *extends, *has, *signature_for, *with ) = do {
14             package Mite::Shim;
15 3     3   60 no warnings 'redefine';
  3         66  
  3         1050  
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         81 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         306 );
25             };
26             };
27              
28             # Gather metadata for constructor and destructor
29             sub __META__ {
30 3     3   45 no strict 'refs';
  3         12  
  3         3468  
31 3   33 3   15 my $class = shift; $class = ref($class) || $class;
  3         48  
32 3         72 my $linear_isa = mro::get_linear_isa( $class );
33             return {
34             BUILD => [
35 3 50       18 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  3         39  
  0         0  
36 3         33 map { "$_\::BUILD" } reverse @$linear_isa
37             ],
38             DEMOLISH => [
39 3 50       30 map { ( *{$_}{CODE} ) ? ( *{$_}{CODE} ) : () }
  3         93  
  0         0  
40 3         27 map { "$_\::DEMOLISH" } @$linear_isa
  3         27  
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 3 50   3   720 my $class = ref($_[0]) ? ref(shift) : shift;
51 3   33     48 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
52 3         48 my $self = bless {}, $class;
53 3 50       87 my $args = $meta->{HAS_BUILDARGS} ? $class->BUILDARGS( @_ ) : { ( @_ == 1 ) ? %{$_[0]} : @_ };
  0 50       0  
54 3         24 my $no_build = delete $args->{__no_BUILD__};
55              
56             # Attribute num (type: PositiveInt)
57             # has declaration, file ../../../../tmp/eTP8ZoGrc4, line 3
58 3 50 33     21 if ( exists $args->{"num"} ) { (do { package FooPos::__SAFE_NAMESPACE__; (do { my $tmp = $args->{"num"}; defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/ }) } && do { package FooPos::__SAFE_NAMESPACE__; $args->{"num"} > 0 }) or Mite::Shim::croak "Type check failed in constructor: %s should be %s", "num", "PositiveInt"; $self->{"num"} = $args->{"num"}; } ;
  3 50 33     33  
  3 50       24  
  3         18  
  3         66  
  3         33  
  3         18  
59              
60              
61             # Call BUILD methods
62 3 50 33     27 $self->BUILDALL( $args ) if ( ! $no_build and @{ $meta->{BUILD} || [] } );
  3 50       30  
63              
64             # Unrecognized parameters
65 3 50       12 my @unknown = grep not( /\Anum\z/ ), keys %{$args}; @unknown and Mite::Shim::croak( "Unexpected keys in constructor: " . join( q[, ], sort @unknown ) );
  3         18  
  3         12  
66              
67 3         18 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 3     3   2655 my $self = shift;
80 3   33     36 my $class = ref( $self ) || $self;
81 3   33     27 my $meta = ( $Mite::META{$class} ||= $class->__META__ );
82 3 50       18 my $in_global_destruction = defined ${^GLOBAL_PHASE}
83             ? ${^GLOBAL_PHASE} eq 'DESTRUCT'
84             : Devel::GlobalDestruction::in_global_destruction();
85 3 50       27 for my $demolisher ( @{ $meta->{DEMOLISH} || [] } ) {
  3         21  
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   36 no warnings 'misc'; # avoid (in cleanup) warnings
  3         36  
  3         1773  
92 0 0       0 die $e if $e; # rethrow
93             }
94 3         36 return;
95             }
96              
97             my $__XS = !$ENV{PERL_ONLY} && eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") };
98              
99             # Accessors for num
100             # has declaration, file ../../../../tmp/eTP8ZoGrc4, line 3
101 9 50 33 9   177 sub num { @_ > 1 ? do { (do { package FooPos::__SAFE_NAMESPACE__; (do { my $tmp = $_[1]; defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/ }) } && ($_[1] > 0)) or Mite::Shim::croak( "Type check failed in %s: value should be %s", "accessor", "PositiveInt" ); $_[0]{"num"} = $_[1]; $_[0]; } : ( $_[0]{"num"} ) }
  6 100 66     9  
  6 100       9  
  6         12  
  6         192  
  3         18  
  3         9  
102              
103              
104             # See UNIVERSAL
105             sub DOES {
106 21     21   39 my ( $self, $role ) = @_;
107 21         33 our %DOES;
108 21 50       57 return $DOES{$role} if exists $DOES{$role};
109 21 50       45 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         117 return $self->SUPER::DOES( $role );
114             }
115              
116             # Alias for Moose/Moo-compatibility
117             sub does {
118 21     21   2703 shift->DOES( @_ );
119             }
120              
121             1;
122             }