line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Event::Plan; |
2
|
57
|
|
|
57
|
|
481
|
use strict; |
|
57
|
|
|
|
|
75
|
|
|
57
|
|
|
|
|
1304
|
|
3
|
57
|
|
|
57
|
|
173
|
use warnings; |
|
57
|
|
|
|
|
62
|
|
|
57
|
|
|
|
|
1774
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000044'; |
6
|
|
|
|
|
|
|
|
7
|
57
|
|
|
57
|
|
198
|
use base 'Test2::Event'; |
|
57
|
|
|
|
|
40
|
|
|
57
|
|
|
|
|
3208
|
|
8
|
57
|
|
|
57
|
|
199
|
use Test2::Util::HashBase qw{max directive reason}; |
|
57
|
|
|
|
|
60
|
|
|
57
|
|
|
|
|
255
|
|
9
|
|
|
|
|
|
|
|
10
|
57
|
|
|
57
|
|
216
|
use Carp qw/confess/; |
|
57
|
|
|
|
|
65
|
|
|
57
|
|
|
|
|
22467
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %ALLOWED = ( |
13
|
|
|
|
|
|
|
'SKIP' => 1, |
14
|
|
|
|
|
|
|
'NO PLAN' => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
111
|
100
|
|
111
|
0
|
376
|
if ($_[0]->{+DIRECTIVE}) { |
19
|
11
|
100
|
|
|
|
35
|
$_[0]->{+DIRECTIVE} = 'SKIP' if $_[0]->{+DIRECTIVE} eq 'skip_all'; |
20
|
11
|
100
|
|
|
|
29
|
$_[0]->{+DIRECTIVE} = 'NO PLAN' if $_[0]->{+DIRECTIVE} eq 'no_plan'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
confess "'" . $_[0]->{+DIRECTIVE} . "' is not a valid plan directive" |
23
|
11
|
100
|
|
|
|
260
|
unless $ALLOWED{$_[0]->{+DIRECTIVE}}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
|
|
|
|
|
|
confess "Cannot have a reason without a directive!" |
27
|
100
|
100
|
|
|
|
342
|
if defined $_[0]->{+REASON}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
confess "No number of tests specified" |
30
|
99
|
100
|
|
|
|
289
|
unless defined $_[0]->{+MAX}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
confess "Plan test count '" . $_[0]->{+MAX} . "' does not appear to be a valid positive integer" |
33
|
98
|
100
|
|
|
|
722
|
unless $_[0]->{+MAX} =~ m/^\d+$/; |
34
|
|
|
|
|
|
|
|
35
|
97
|
|
|
|
|
240
|
$_[0]->{+DIRECTIVE} = ''; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub sets_plan { |
40
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
41
|
|
|
|
|
|
|
return ( |
42
|
|
|
|
|
|
|
$self->{+MAX}, |
43
|
|
|
|
|
|
|
$self->{+DIRECTIVE}, |
44
|
3
|
|
|
|
|
16
|
$self->{+REASON}, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub callback { |
49
|
104
|
|
|
104
|
1
|
121
|
my $self = shift; |
50
|
104
|
|
|
|
|
120
|
my ($hub) = @_; |
51
|
|
|
|
|
|
|
|
52
|
104
|
|
66
|
|
|
588
|
$hub->plan($self->{+DIRECTIVE} || $self->{+MAX}); |
53
|
|
|
|
|
|
|
|
54
|
104
|
100
|
|
|
|
279
|
return unless $self->{+DIRECTIVE}; |
55
|
|
|
|
|
|
|
|
56
|
8
|
100
|
50
|
|
|
60
|
$hub->set_skip_reason($self->{+REASON} || 1) if $self->{+DIRECTIVE} eq 'SKIP'; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub terminate { |
60
|
103
|
|
|
103
|
1
|
139
|
my $self = shift; |
61
|
|
|
|
|
|
|
# On skip_all we want to terminate the hub |
62
|
103
|
100
|
100
|
|
|
344
|
return 0 if $self->{+DIRECTIVE} && $self->{+DIRECTIVE} eq 'SKIP'; |
63
|
97
|
|
|
|
|
170
|
return undef; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub summary { |
67
|
3
|
|
|
3
|
1
|
8
|
my $self = shift; |
68
|
3
|
|
|
|
|
6
|
my $max = $self->{+MAX}; |
69
|
3
|
|
|
|
|
5
|
my $directive = $self->{+DIRECTIVE}; |
70
|
3
|
|
|
|
|
4
|
my $reason = $self->{+REASON}; |
71
|
|
|
|
|
|
|
|
72
|
3
|
100
|
66
|
|
|
17
|
return "Plan is $max assertions" |
73
|
|
|
|
|
|
|
if $max || !$directive; |
74
|
|
|
|
|
|
|
|
75
|
2
|
100
|
|
|
|
9
|
return "Plan is '$directive', $reason" |
76
|
|
|
|
|
|
|
if $reason; |
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
5
|
return "Plan is '$directive'"; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |