line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
7
|
use MooseX::Declare; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
10
|
|
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
115698
|
role Test::Sweet::Meta::Class { |
|
2
|
|
|
2
|
|
3
|
|
|
2
|
|
|
2
|
|
55
|
|
|
2
|
|
|
2
|
|
15410
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
19
|
|
|
2
|
|
|
|
|
6706
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
19
|
|
|
2
|
|
|
|
|
177
|
|
4
|
2
|
|
|
2
|
|
115
|
use MooseX::Types::Moose qw(Str ArrayRef ClassName Object); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
21
|
|
5
|
2
|
|
|
2
|
|
8191
|
use Test::Sweet::Meta::Method; |
|
2
|
|
|
|
|
45453
|
|
|
2
|
|
|
|
|
101
|
|
6
|
2
|
|
|
2
|
|
16
|
use Moose::Meta::Class; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
41
|
|
7
|
2
|
|
|
2
|
|
8
|
use List::MoreUtils qw(uniq); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
21
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'local_tests' => ( |
10
|
|
|
|
|
|
|
traits => ['Array'], |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
isa => ArrayRef[Str], |
13
|
|
|
|
|
|
|
required => 1, |
14
|
|
|
|
|
|
|
default => sub { [] }, |
15
|
|
|
|
|
|
|
auto_deref => 1, |
16
|
|
|
|
|
|
|
handles => { |
17
|
|
|
|
|
|
|
'_add_test' => 'push', |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'test_metaclass' => ( |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
isa => Object, |
24
|
|
|
|
|
|
|
lazy_build => 1, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'test_metamethod_roles' => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
isa => ArrayRef[ClassName], |
30
|
|
|
|
|
|
|
required => 1, |
31
|
|
|
|
|
|
|
default => sub { ['Test::Sweet::Meta::Method'] }, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
2
|
|
69062
|
method _build_test_metaclass { |
35
|
|
|
|
|
|
|
return Moose::Meta::Class->create_anon_class( |
36
|
|
|
|
|
|
|
superclasses => [ $self->method_metaclass ], |
37
|
|
|
|
|
|
|
roles => $self->test_metamethod_roles, |
38
|
|
|
|
|
|
|
cache => 1, |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
2
|
|
106795
|
method add_test(Str $name, CodeRef $code) { |
43
|
|
|
|
|
|
|
my $body = $self->test_metaclass->name->wrap( |
44
|
|
|
|
|
|
|
$code, |
45
|
|
|
|
|
|
|
original_body => $code, |
46
|
|
|
|
|
|
|
name => $name, |
47
|
|
|
|
|
|
|
package_name => $self->name, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$self->add_method( $name, $body ); |
51
|
|
|
|
|
|
|
$self->_add_test($name); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# ensure that we get the role's tests (they are available via the MOP, of course) |
55
|
2
|
|
|
2
|
|
70868
|
after add_role($role){ |
56
|
|
|
|
|
|
|
if ( $role->can('local_tests') ) { |
57
|
|
|
|
|
|
|
$self->_add_test($role->local_tests); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
2
|
|
|
2
|
|
66747
|
method get_all_tests { |
62
|
|
|
|
|
|
|
return $self->local_tests unless $self->can('linearized_isa'); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my @ordering = reverse $self->linearized_isa; |
65
|
|
|
|
|
|
|
my @tests = map { |
66
|
|
|
|
|
|
|
eval { |
67
|
|
|
|
|
|
|
my $meta = $_->meta; |
68
|
|
|
|
|
|
|
$meta->local_tests; |
69
|
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
} @ordering; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
return uniq @tests; |
73
|
|
|
|
|
|
|
} |
74
|
2
|
|
|
2
|
|
3234
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 NAME |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Test::Sweet::Meta::Class - metaclass role that provides methods for keeping track of tests |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 METHODS |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 get_all_tests |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Returns the names of all test methods in this class' hierarchy. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 local_tests |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Returns the names of the test methods defined in this class. Includes |
91
|
|
|
|
|
|
|
tests composed in via roles. |