line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Able::Planner; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
3639
|
use Moose::Role; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
42
|
|
4
|
8
|
|
|
8
|
|
30670
|
use Moose::Util::TypeConstraints; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
60
|
|
5
|
8
|
|
|
8
|
|
11668
|
use strict; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
339
|
|
6
|
|
|
|
|
|
|
require Test::Builder; |
7
|
8
|
|
|
8
|
|
30
|
use warnings; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
2042
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Test::Able::Planner - Planning role |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This role represents the core of the planning support in Test::Able. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
The vast majority of the time all that's necessary, in terms of planning, is |
18
|
|
|
|
|
|
|
to set the plans at the method level. For a more thorough explanation of how |
19
|
|
|
|
|
|
|
planning in Test::Able works read on. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
In order to facilitate planning there's a hierarchy of plans. That hierarchy |
22
|
|
|
|
|
|
|
is as follows: test-related methods, test objects, test runner object, and |
23
|
|
|
|
|
|
|
Test::Builder. The sum of all the constituent method plans make up the |
24
|
|
|
|
|
|
|
object plan. The sum of all the constituent object plans make up the runner |
25
|
|
|
|
|
|
|
object plan. And the runner object plan gets added to Test::Builder's plan. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Its possible to set a method's plan at any time. To make this possible the |
28
|
|
|
|
|
|
|
object and runner object plans are cleared when a method plan is set. Then, |
29
|
|
|
|
|
|
|
the runner object's plan gets recalculated, at the latest, when it needs to |
30
|
|
|
|
|
|
|
add to Test::Builder's plan. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
At the moment Test::Builder does not support deferred planning. Until such |
33
|
|
|
|
|
|
|
time as Test::Builder supports it Test::Able emulates it as best it can for |
34
|
|
|
|
|
|
|
its own purposes. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
If Test::Builder's plan is set to a numeric value then Test::Able |
37
|
|
|
|
|
|
|
will not touch it. If Test::Builder's plan is no_plan then Test::Able will |
38
|
|
|
|
|
|
|
persuade Test::Builder to do deferred planning with what it thinks is the |
39
|
|
|
|
|
|
|
plan. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Note that as a convenience, if Test::Builder's plan is not declared by the |
42
|
|
|
|
|
|
|
time Test::Able's run_tests() is called the plan will be set to no_plan. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item builder |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
The Test::Builder instance. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has 'builder' => ( |
55
|
|
|
|
|
|
|
is => 'ro', isa => 'Test::Builder', lazy_build => 1, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
subtype 'Test::Able::Plan' => as 'Str' => where { /^no_plan|\d+$/; }; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item plan |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Test plan similar to Test::Builder's. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
has 'plan' => ( |
67
|
|
|
|
|
|
|
is => 'rw', isa => 'Test::Able::Plan', lazy_build => 1, |
68
|
|
|
|
|
|
|
trigger => sub { |
69
|
|
|
|
|
|
|
my ( $self, ) = @_; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
if ( $self->isa( 'Moose::Meta::Method' ) ) { |
72
|
|
|
|
|
|
|
my $in_a_role = $self->associated_metaclass->isa( |
73
|
|
|
|
|
|
|
'Moose::Meta::Role' |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
$self->associated_metaclass->clear_plan unless $in_a_role; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return; |
79
|
|
|
|
|
|
|
}, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item runner_plan |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The plan that the test runner object manages. This is the top level plan that |
85
|
|
|
|
|
|
|
all other plans are aggregated into. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
has 'runner_plan' => ( |
90
|
|
|
|
|
|
|
is => 'rw', isa => 'Test::Able::Plan', lazy_build => 1, |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item last_runner_plan |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Used by the test runner object in calculating Test::Builder's plan. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
has 'last_runner_plan' => ( |
102
|
|
|
|
|
|
|
is => 'rw', isa => 'Test::Able::Plan', |
103
|
|
|
|
|
|
|
predicate => 'has_last_runner_plan', |
104
|
|
|
|
|
|
|
clearer => 'clear_last_runner_plan', |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _build_builder { |
108
|
11
|
|
|
11
|
|
17
|
my ( $self, ) = @_; |
109
|
|
|
|
|
|
|
|
110
|
11
|
|
|
|
|
63
|
return Test::Builder->new; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Justin DeVuyst, C<justin@devuyst.com> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Copyright 2009 by Justin DeVuyst. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify it under |
122
|
|
|
|
|
|
|
the same terms as Perl itself. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |