File Coverage

blib/lib/Aspect/Library/TestClass.pm
Criterion Covered Total %
statement 27 43 62.7
branch 0 10 0.0
condition n/a
subroutine 9 12 75.0
pod 0 2 0.0
total 36 67 53.7


line stmt bran cond sub pod time code
1             package Aspect::Library::TestClass;
2              
3 1     1   913 use 5.006;
  1         4  
  1         39  
4 1     1   8 use strict;
  1         1  
  1         35  
5 1     1   15 use warnings;
  1         2  
  1         39  
6 1     1   1188 use Test::Class 0.33 ();
  1         29208  
  1         38  
7 1     1   1199 use Params::Util 1.00 ();
  1         3334  
  1         33  
8 1     1   1010 use Aspect::Modular 1.00 ();
  1         5819  
  1         28  
9 1     1   990 use Aspect::Advice::Before ();
  1         10260  
  1         26  
10 1     1   1035 use Aspect::Pointcut::And ();
  1         12614  
  1         24  
11 1     1   895 use Aspect::Pointcut::Call ();
  1         1114  
  1         320  
12              
13             our $VERSION = '1.00';
14             our @ISA = 'Aspect::Modular';
15              
16             sub Test::Class::make_subject {
17 0     0 0   shift->subject_class->new(@_);
18             }
19              
20             sub get_advice {
21 0     0 0   my $self = shift;
22 0           my $pointcut = shift;
23             Aspect::Advice::Before->new(
24             lexical => $self->lexical,
25             pointcut => Aspect::Pointcut::And->new(
26             Aspect::Pointcut::Call->new(qr/::[a-z][^:]*$/),
27             $pointcut,
28             ),
29             code => sub {
30 0     0     my $self = $_->self;
31 0           my @method = ( $_->package_name, $_->short_name );
32              
33             # Are we in a test class, in a test method, and can
34             # we get a subject_class from the test class.
35             # Would be nice if we could check for existence of test
36             # attribute on the method.
37 0 0         Params::Util::_INSTANCE($self, 'Test::Class') or return;
38 0 0         $self->_method_info(@method) or return;
39 0 0         $self->can('subject_class') or return;
40              
41 0           my @params = ();
42 0 0         if ( $self->can('subject_params') ) {
43 0           @params = $self->subject_params;
44             }
45 0           my $subject = $self->make_subject(@params);
46 0 0         if ( $self->can('init_subject_state') ) {
47 0           $self->init_subject_state($subject)
48             }
49 0           $_->args( $_->args, $subject );
50             },
51 0           );
52             }
53              
54             1;
55              
56             __END__