line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Event::Plan; |
2
|
246
|
|
|
246
|
|
2090
|
use strict; |
|
246
|
|
|
|
|
512
|
|
|
246
|
|
|
|
|
7410
|
|
3
|
246
|
|
|
246
|
|
1280
|
use warnings; |
|
246
|
|
|
|
|
526
|
|
|
246
|
|
|
|
|
14764
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.302180'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
246
|
|
|
246
|
|
1574
|
BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } |
|
246
|
|
|
|
|
11031
|
|
9
|
246
|
|
|
246
|
|
1615
|
use Test2::Util::HashBase qw{max directive reason}; |
|
246
|
|
|
|
|
554
|
|
|
246
|
|
|
|
|
1751
|
|
10
|
|
|
|
|
|
|
|
11
|
246
|
|
|
246
|
|
1648
|
use Carp qw/confess/; |
|
246
|
|
|
|
|
566
|
|
|
246
|
|
|
|
|
157820
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my %ALLOWED = ( |
14
|
|
|
|
|
|
|
'SKIP' => 1, |
15
|
|
|
|
|
|
|
'NO PLAN' => 1, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub init { |
19
|
553
|
100
|
|
553
|
0
|
2856
|
if ($_[0]->{+DIRECTIVE}) { |
20
|
30
|
100
|
|
|
|
127
|
$_[0]->{+DIRECTIVE} = 'SKIP' if $_[0]->{+DIRECTIVE} eq 'skip_all'; |
21
|
30
|
100
|
|
|
|
102
|
$_[0]->{+DIRECTIVE} = 'NO PLAN' if $_[0]->{+DIRECTIVE} eq 'no_plan'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
confess "'" . $_[0]->{+DIRECTIVE} . "' is not a valid plan directive" |
24
|
30
|
100
|
|
|
|
382
|
unless $ALLOWED{$_[0]->{+DIRECTIVE}}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
else { |
27
|
|
|
|
|
|
|
confess "Cannot have a reason without a directive!" |
28
|
523
|
100
|
|
|
|
2108
|
if defined $_[0]->{+REASON}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
confess "No number of tests specified" |
31
|
522
|
100
|
|
|
|
1965
|
unless defined $_[0]->{+MAX}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
confess "Plan test count '" . $_[0]->{+MAX} . "' does not appear to be a valid positive integer" |
34
|
521
|
100
|
|
|
|
4176
|
unless $_[0]->{+MAX} =~ m/^\d+$/; |
35
|
|
|
|
|
|
|
|
36
|
520
|
|
|
|
|
1756
|
$_[0]->{+DIRECTIVE} = ''; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub sets_plan { |
41
|
3
|
|
|
3
|
1
|
7
|
my $self = shift; |
42
|
|
|
|
|
|
|
return ( |
43
|
|
|
|
|
|
|
$self->{+MAX}, |
44
|
|
|
|
|
|
|
$self->{+DIRECTIVE}, |
45
|
3
|
|
|
|
|
21
|
$self->{+REASON}, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub terminate { |
50
|
193
|
|
|
193
|
1
|
531
|
my $self = shift; |
51
|
|
|
|
|
|
|
# On skip_all we want to terminate the hub |
52
|
193
|
100
|
100
|
|
|
833
|
return 0 if $self->{+DIRECTIVE} && $self->{+DIRECTIVE} eq 'SKIP'; |
53
|
192
|
|
|
|
|
1749
|
return undef; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub summary { |
57
|
3
|
|
|
3
|
1
|
12
|
my $self = shift; |
58
|
3
|
|
|
|
|
6
|
my $max = $self->{+MAX}; |
59
|
3
|
|
|
|
|
6
|
my $directive = $self->{+DIRECTIVE}; |
60
|
3
|
|
|
|
|
5
|
my $reason = $self->{+REASON}; |
61
|
|
|
|
|
|
|
|
62
|
3
|
100
|
66
|
|
|
21
|
return "Plan is $max assertions" |
63
|
|
|
|
|
|
|
if $max || !$directive; |
64
|
|
|
|
|
|
|
|
65
|
2
|
100
|
|
|
|
9
|
return "Plan is '$directive', $reason" |
66
|
|
|
|
|
|
|
if $reason; |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
6
|
return "Plan is '$directive'"; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub facet_data { |
72
|
1270
|
|
|
1270
|
1
|
2361
|
my $self = shift; |
73
|
|
|
|
|
|
|
|
74
|
1270
|
|
|
|
|
4289
|
my $out = $self->common_facet_data; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$out->{control}->{terminate} = $self->{+DIRECTIVE} eq 'SKIP' ? 0 : undef |
77
|
1270
|
100
|
|
|
|
6825
|
unless defined $out->{control}->{terminate}; |
|
|
50
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
1270
|
|
|
|
|
3779
|
$out->{plan} = {count => $self->{+MAX}}; |
80
|
1270
|
100
|
|
|
|
3390
|
$out->{plan}->{details} = $self->{+REASON} if defined $self->{+REASON}; |
81
|
|
|
|
|
|
|
|
82
|
1270
|
100
|
|
|
|
3408
|
if (my $dir = $self->{+DIRECTIVE}) { |
83
|
51
|
100
|
|
|
|
238
|
$out->{plan}->{skip} = 1 if $dir eq 'SKIP'; |
84
|
51
|
100
|
|
|
|
162
|
$out->{plan}->{none} = 1 if $dir eq 'NO PLAN'; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
1270
|
|
|
|
|
3936
|
return $out; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |