line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Event::Generic; |
2
|
2
|
|
|
2
|
|
643
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
64
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
75
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
11
|
use Carp qw/croak/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
129
|
|
6
|
2
|
|
|
2
|
|
15
|
use Scalar::Util qw/reftype/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
175
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.302180'; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
14
|
BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } |
|
2
|
|
|
|
|
98
|
|
11
|
2
|
|
|
2
|
|
15
|
use Test2::Util::HashBase; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
14
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my @FIELDS = qw{ |
14
|
|
|
|
|
|
|
causes_fail increments_count diagnostics no_display callback terminate |
15
|
|
|
|
|
|
|
global sets_plan summary facet_data |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
my %DEFAULTS = ( |
18
|
|
|
|
|
|
|
causes_fail => 0, |
19
|
|
|
|
|
|
|
increments_count => 0, |
20
|
|
|
|
|
|
|
diagnostics => 0, |
21
|
|
|
|
|
|
|
no_display => 0, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub init { |
25
|
6
|
|
|
6
|
0
|
33
|
my $self = shift; |
26
|
|
|
|
|
|
|
|
27
|
6
|
|
|
|
|
19
|
for my $field (@FIELDS) { |
28
|
60
|
100
|
|
|
|
138
|
my $val = defined $self->{$field} ? delete $self->{$field} : $DEFAULTS{$field}; |
29
|
60
|
100
|
|
|
|
122
|
next unless defined $val; |
30
|
|
|
|
|
|
|
|
31
|
25
|
|
|
|
|
44
|
my $set = "set_$field"; |
32
|
25
|
|
|
|
|
71
|
$self->$set($val); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
for my $field (@FIELDS) { |
37
|
2
|
|
|
2
|
|
17
|
no strict 'refs'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1612
|
|
38
|
|
|
|
|
|
|
|
39
|
146
|
100
|
|
146
|
|
803
|
*$field = sub { exists $_[0]->{$field} ? $_[0]->{$field} : () } |
40
|
|
|
|
|
|
|
unless exists &{$field}; |
41
|
|
|
|
|
|
|
|
42
|
36
|
|
|
36
|
|
90
|
*{"set_$field"} = sub { $_[0]->{$field} = $_[1] } |
43
|
|
|
|
|
|
|
unless exists &{"set_$field"}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub can { |
47
|
26
|
|
|
26
|
0
|
58
|
my $self = shift; |
48
|
26
|
|
|
|
|
54
|
my ($name) = @_; |
49
|
26
|
100
|
|
|
|
215
|
return $self->SUPER::can($name) unless $name eq 'callback'; |
50
|
19
|
|
100
|
|
|
137
|
return $self->{callback} || \&Test2::Event::callback; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub facet_data { |
54
|
22
|
|
|
22
|
1
|
45
|
my $self = shift; |
55
|
22
|
|
66
|
|
|
120
|
return $self->{facet_data} || $self->SUPER::facet_data(); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub summary { |
59
|
34
|
|
|
34
|
1
|
63
|
my $self = shift; |
60
|
34
|
100
|
|
|
|
82
|
return $self->{summary} if defined $self->{summary}; |
61
|
32
|
|
|
|
|
96
|
$self->SUPER::summary(); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub sets_plan { |
65
|
23
|
|
|
23
|
1
|
43
|
my $self = shift; |
66
|
23
|
100
|
|
|
|
86
|
return unless $self->{sets_plan}; |
67
|
5
|
|
|
|
|
8
|
return @{$self->{sets_plan}}; |
|
5
|
|
|
|
|
25
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub callback { |
71
|
4
|
|
|
4
|
1
|
22
|
my $self = shift; |
72
|
4
|
|
100
|
|
|
27
|
my $cb = $self->{callback} || return; |
73
|
1
|
|
|
|
|
5
|
$self->$cb(@_); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub set_global { |
77
|
5
|
|
|
5
|
1
|
14
|
my $self = shift; |
78
|
5
|
|
|
|
|
12
|
my ($bool) = @_; |
79
|
|
|
|
|
|
|
|
80
|
5
|
100
|
|
|
|
15
|
if(!defined $bool) { |
81
|
1
|
|
|
|
|
3
|
delete $self->{global}; |
82
|
1
|
|
|
|
|
3
|
return undef; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
4
|
|
|
|
|
11
|
$self->{global} = $bool; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub set_callback { |
89
|
4
|
|
|
4
|
1
|
15
|
my $self = shift; |
90
|
4
|
|
|
|
|
27
|
my ($cb) = @_; |
91
|
|
|
|
|
|
|
|
92
|
4
|
100
|
|
|
|
16
|
if(!defined $cb) { |
93
|
1
|
|
|
|
|
7
|
delete $self->{callback}; |
94
|
1
|
|
|
|
|
4
|
return undef; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
3
|
100
|
66
|
|
|
140
|
croak "callback must be a code reference" |
98
|
|
|
|
|
|
|
unless ref($cb) && reftype($cb) eq 'CODE'; |
99
|
|
|
|
|
|
|
|
100
|
2
|
|
|
|
|
29
|
$self->{callback} = $cb; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub set_terminate { |
104
|
10
|
|
|
10
|
1
|
30
|
my $self = shift; |
105
|
10
|
|
|
|
|
23
|
my ($exit) = @_; |
106
|
|
|
|
|
|
|
|
107
|
10
|
100
|
|
|
|
28
|
if(!defined $exit) { |
108
|
2
|
|
|
|
|
4
|
delete $self->{terminate}; |
109
|
2
|
|
|
|
|
7
|
return undef; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
8
|
100
|
|
|
|
279
|
croak "terminate must be a positive integer" |
113
|
|
|
|
|
|
|
unless $exit =~ m/^\d+$/; |
114
|
|
|
|
|
|
|
|
115
|
5
|
|
|
|
|
26
|
$self->{terminate} = $exit; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub set_sets_plan { |
119
|
6
|
|
|
6
|
1
|
17
|
my $self = shift; |
120
|
6
|
|
|
|
|
16
|
my ($plan) = @_; |
121
|
|
|
|
|
|
|
|
122
|
6
|
100
|
|
|
|
17
|
if(!defined $plan) { |
123
|
1
|
|
|
|
|
3
|
delete $self->{sets_plan}; |
124
|
1
|
|
|
|
|
3
|
return undef; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
5
|
100
|
66
|
|
|
218
|
croak "'sets_plan' must be an array reference" |
128
|
|
|
|
|
|
|
unless ref($plan) && reftype($plan) eq 'ARRAY'; |
129
|
|
|
|
|
|
|
|
130
|
4
|
|
|
|
|
14
|
$self->{sets_plan} = $plan; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
__END__ |