line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Event::Plan; |
2
|
54
|
|
|
54
|
|
492
|
use strict; |
|
54
|
|
|
|
|
44
|
|
|
54
|
|
|
|
|
1143
|
|
3
|
54
|
|
|
54
|
|
159
|
use warnings; |
|
54
|
|
|
|
|
46
|
|
|
54
|
|
|
|
|
1509
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000042'; |
6
|
|
|
|
|
|
|
|
7
|
54
|
|
|
54
|
|
160
|
use base 'Test2::Event'; |
|
54
|
|
|
|
|
51
|
|
|
54
|
|
|
|
|
3065
|
|
8
|
54
|
|
|
54
|
|
204
|
use Test2::Util::HashBase qw{max directive reason}; |
|
54
|
|
|
|
|
48
|
|
|
54
|
|
|
|
|
225
|
|
9
|
|
|
|
|
|
|
|
10
|
54
|
|
|
54
|
|
194
|
use Carp qw/confess/; |
|
54
|
|
|
|
|
55
|
|
|
54
|
|
|
|
|
19880
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %ALLOWED = ( |
13
|
|
|
|
|
|
|
'SKIP' => 1, |
14
|
|
|
|
|
|
|
'NO PLAN' => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
107
|
100
|
|
107
|
0
|
327
|
if ($_[0]->{+DIRECTIVE}) { |
19
|
11
|
100
|
|
|
|
37
|
$_[0]->{+DIRECTIVE} = 'SKIP' if $_[0]->{+DIRECTIVE} eq 'skip_all'; |
20
|
11
|
100
|
|
|
|
26
|
$_[0]->{+DIRECTIVE} = 'NO PLAN' if $_[0]->{+DIRECTIVE} eq 'no_plan'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
confess "'" . $_[0]->{+DIRECTIVE} . "' is not a valid plan directive" |
23
|
11
|
100
|
|
|
|
247
|
unless $ALLOWED{$_[0]->{+DIRECTIVE}}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
|
|
|
|
|
|
confess "Cannot have a reason without a directive!" |
27
|
96
|
100
|
|
|
|
332
|
if defined $_[0]->{+REASON}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
confess "No number of tests specified" |
30
|
95
|
100
|
|
|
|
283
|
unless defined $_[0]->{+MAX}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
confess "Plan test count '" . $_[0]->{+MAX} . "' does not appear to be a valid positive integer" |
33
|
94
|
100
|
|
|
|
611
|
unless $_[0]->{+MAX} =~ m/^\d+$/; |
34
|
|
|
|
|
|
|
|
35
|
93
|
|
|
|
|
233
|
$_[0]->{+DIRECTIVE} = ''; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub sets_plan { |
40
|
3
|
|
|
3
|
1
|
3
|
my $self = shift; |
41
|
|
|
|
|
|
|
return ( |
42
|
|
|
|
|
|
|
$self->{+MAX}, |
43
|
|
|
|
|
|
|
$self->{+DIRECTIVE}, |
44
|
3
|
|
|
|
|
17
|
$self->{+REASON}, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub callback { |
49
|
100
|
|
|
100
|
1
|
221
|
my $self = shift; |
50
|
100
|
|
|
|
|
121
|
my ($hub) = @_; |
51
|
|
|
|
|
|
|
|
52
|
100
|
|
66
|
|
|
495
|
$hub->plan($self->{+DIRECTIVE} || $self->{+MAX}); |
53
|
|
|
|
|
|
|
|
54
|
100
|
100
|
|
|
|
250
|
return unless $self->{+DIRECTIVE}; |
55
|
|
|
|
|
|
|
|
56
|
8
|
100
|
50
|
|
|
70
|
$hub->set_skip_reason($self->{+REASON} || 1) if $self->{+DIRECTIVE} eq 'SKIP'; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub terminate { |
60
|
99
|
|
|
99
|
1
|
149
|
my $self = shift; |
61
|
|
|
|
|
|
|
# On skip_all we want to terminate the hub |
62
|
99
|
100
|
100
|
|
|
301
|
return 0 if $self->{+DIRECTIVE} && $self->{+DIRECTIVE} eq 'SKIP'; |
63
|
93
|
|
|
|
|
157
|
return undef; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub summary { |
67
|
3
|
|
|
3
|
1
|
9
|
my $self = shift; |
68
|
3
|
|
|
|
|
6
|
my $max = $self->{+MAX}; |
69
|
3
|
|
|
|
|
5
|
my $directive = $self->{+DIRECTIVE}; |
70
|
3
|
|
|
|
|
5
|
my $reason = $self->{+REASON}; |
71
|
|
|
|
|
|
|
|
72
|
3
|
100
|
66
|
|
|
18
|
return "Plan is $max assertions" |
73
|
|
|
|
|
|
|
if $max || !$directive; |
74
|
|
|
|
|
|
|
|
75
|
2
|
100
|
|
|
|
8
|
return "Plan is '$directive', $reason" |
76
|
|
|
|
|
|
|
if $reason; |
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
5
|
return "Plan is '$directive'"; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |