line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Event::Plan; |
2
|
57
|
|
|
57
|
|
478
|
use strict; |
|
57
|
|
|
|
|
51
|
|
|
57
|
|
|
|
|
1240
|
|
3
|
57
|
|
|
57
|
|
171
|
use warnings; |
|
57
|
|
|
|
|
49
|
|
|
57
|
|
|
|
|
2183
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000043'; |
6
|
|
|
|
|
|
|
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) |
7
|
|
|
|
|
|
|
|
8
|
57
|
|
|
57
|
|
172
|
use base 'Test2::Event'; |
|
57
|
|
|
|
|
60
|
|
|
57
|
|
|
|
|
3282
|
|
9
|
57
|
|
|
57
|
|
204
|
use Test2::Util::HashBase qw{max directive reason}; |
|
57
|
|
|
|
|
53
|
|
|
57
|
|
|
|
|
274
|
|
10
|
|
|
|
|
|
|
|
11
|
57
|
|
|
57
|
|
214
|
use Carp qw/confess/; |
|
57
|
|
|
|
|
58
|
|
|
57
|
|
|
|
|
23139
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my %ALLOWED = ( |
14
|
|
|
|
|
|
|
'SKIP' => 1, |
15
|
|
|
|
|
|
|
'NO PLAN' => 1, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub init { |
19
|
111
|
100
|
|
111
|
0
|
407
|
if ($_[0]->{+DIRECTIVE}) { |
20
|
11
|
100
|
|
|
|
32
|
$_[0]->{+DIRECTIVE} = 'SKIP' if $_[0]->{+DIRECTIVE} eq 'skip_all'; |
21
|
11
|
100
|
|
|
|
32
|
$_[0]->{+DIRECTIVE} = 'NO PLAN' if $_[0]->{+DIRECTIVE} eq 'no_plan'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
confess "'" . $_[0]->{+DIRECTIVE} . "' is not a valid plan directive" |
24
|
11
|
100
|
|
|
|
191
|
unless $ALLOWED{$_[0]->{+DIRECTIVE}}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
else { |
27
|
|
|
|
|
|
|
confess "Cannot have a reason without a directive!" |
28
|
100
|
100
|
|
|
|
346
|
if defined $_[0]->{+REASON}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
confess "No number of tests specified" |
31
|
99
|
100
|
|
|
|
324
|
unless defined $_[0]->{+MAX}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
confess "Plan test count '" . $_[0]->{+MAX} . "' does not appear to be a valid positive integer" |
34
|
98
|
100
|
|
|
|
661
|
unless $_[0]->{+MAX} =~ m/^\d+$/; |
35
|
|
|
|
|
|
|
|
36
|
97
|
|
|
|
|
256
|
$_[0]->{+DIRECTIVE} = ''; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub sets_plan { |
41
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
42
|
|
|
|
|
|
|
return ( |
43
|
|
|
|
|
|
|
$self->{+MAX}, |
44
|
|
|
|
|
|
|
$self->{+DIRECTIVE}, |
45
|
3
|
|
|
|
|
14
|
$self->{+REASON}, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub callback { |
50
|
104
|
|
|
104
|
1
|
127
|
my $self = shift; |
51
|
104
|
|
|
|
|
123
|
my ($hub) = @_; |
52
|
|
|
|
|
|
|
|
53
|
104
|
|
66
|
|
|
626
|
$hub->plan($self->{+DIRECTIVE} || $self->{+MAX}); |
54
|
|
|
|
|
|
|
|
55
|
104
|
100
|
|
|
|
294
|
return unless $self->{+DIRECTIVE}; |
56
|
|
|
|
|
|
|
|
57
|
8
|
100
|
50
|
|
|
56
|
$hub->set_skip_reason($self->{+REASON} || 1) if $self->{+DIRECTIVE} eq 'SKIP'; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub terminate { |
61
|
103
|
|
|
103
|
1
|
137
|
my $self = shift; |
62
|
|
|
|
|
|
|
# On skip_all we want to terminate the hub |
63
|
103
|
100
|
100
|
|
|
337
|
return 0 if $self->{+DIRECTIVE} && $self->{+DIRECTIVE} eq 'SKIP'; |
64
|
97
|
|
|
|
|
307
|
return undef; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub summary { |
68
|
3
|
|
|
3
|
1
|
9
|
my $self = shift; |
69
|
3
|
|
|
|
|
5
|
my $max = $self->{+MAX}; |
70
|
3
|
|
|
|
|
3
|
my $directive = $self->{+DIRECTIVE}; |
71
|
3
|
|
|
|
|
4
|
my $reason = $self->{+REASON}; |
72
|
|
|
|
|
|
|
|
73
|
3
|
100
|
66
|
|
|
18
|
return "Plan is $max assertions" |
74
|
|
|
|
|
|
|
if $max || !$directive; |
75
|
|
|
|
|
|
|
|
76
|
2
|
100
|
|
|
|
8
|
return "Plan is '$directive', $reason" |
77
|
|
|
|
|
|
|
if $reason; |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
4
|
return "Plan is '$directive'"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |