line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Event::Ok; |
2
|
246
|
|
|
246
|
|
2068
|
use strict; |
|
246
|
|
|
|
|
507
|
|
|
246
|
|
|
|
|
7363
|
|
3
|
246
|
|
|
246
|
|
1376
|
use warnings; |
|
246
|
|
|
|
|
505
|
|
|
246
|
|
|
|
|
14234
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.302182'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
246
|
|
|
246
|
|
113485
|
BEGIN { require Test2::Event; our @ISA = qw(Test2::Event) } |
|
246
|
|
|
|
|
12126
|
|
9
|
246
|
|
|
|
|
1176
|
use Test2::Util::HashBase qw{ |
10
|
|
|
|
|
|
|
pass effective_pass name todo |
11
|
246
|
|
|
246
|
|
1772
|
}; |
|
246
|
|
|
|
|
519
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub init { |
14
|
200
|
|
|
200
|
0
|
414
|
my $self = shift; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Do not store objects here, only true or false |
17
|
200
|
100
|
|
|
|
857
|
$self->{+PASS} = $self->{+PASS} ? 1 : 0; |
18
|
200
|
|
100
|
|
|
1122
|
$self->{+EFFECTIVE_PASS} = $self->{+PASS} || (defined($self->{+TODO}) ? 1 : 0); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
{ |
22
|
246
|
|
|
246
|
|
1897
|
no warnings 'redefine'; |
|
246
|
|
|
|
|
542
|
|
|
246
|
|
|
|
|
110595
|
|
23
|
|
|
|
|
|
|
sub set_todo { |
24
|
317
|
|
|
317
|
|
559
|
my $self = shift; |
25
|
317
|
|
|
|
|
547
|
my ($todo) = @_; |
26
|
317
|
|
|
|
|
859
|
$self->{+TODO} = $todo; |
27
|
317
|
100
|
|
|
|
883
|
$self->{+EFFECTIVE_PASS} = defined($todo) ? 1 : $self->{+PASS}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
3
|
|
|
3
|
1
|
22
|
sub increments_count { 1 }; |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
2
|
1
|
10
|
sub causes_fail { !$_[0]->{+EFFECTIVE_PASS} } |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub summary { |
36
|
7
|
|
|
7
|
1
|
17
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
7
|
|
100
|
|
|
21
|
my $name = $self->{+NAME} || "Nameless Assertion"; |
39
|
|
|
|
|
|
|
|
40
|
7
|
|
|
|
|
15
|
my $todo = $self->{+TODO}; |
41
|
7
|
100
|
|
|
|
23
|
if ($todo) { |
|
|
100
|
|
|
|
|
|
42
|
1
|
|
|
|
|
4
|
$name .= " (TODO: $todo)"; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
elsif (defined $todo) { |
45
|
1
|
|
|
|
|
2
|
$name .= " (TODO)" |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
7
|
|
|
|
|
29
|
return $name; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub extra_amnesty { |
52
|
1158
|
|
|
1158
|
0
|
1745
|
my $self = shift; |
53
|
1158
|
100
|
100
|
|
|
5623
|
return unless defined($self->{+TODO}) || ($self->{+EFFECTIVE_PASS} && !$self->{+PASS}); |
|
|
|
100
|
|
|
|
|
54
|
|
|
|
|
|
|
return { |
55
|
|
|
|
|
|
|
tag => 'TODO', |
56
|
462
|
|
|
|
|
1776
|
details => $self->{+TODO}, |
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub facet_data { |
61
|
1184
|
|
|
1184
|
1
|
1991
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
1184
|
|
|
|
|
3459
|
my $out = $self->common_facet_data; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$out->{assert} = { |
66
|
|
|
|
|
|
|
no_debug => 1, # Legacy behavior |
67
|
|
|
|
|
|
|
pass => $self->{+PASS}, |
68
|
1184
|
|
|
|
|
4204
|
details => $self->{+NAME}, |
69
|
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
|
71
|
1184
|
100
|
|
|
|
3075
|
if (my @exra_amnesty = $self->extra_amnesty) { |
72
|
488
|
|
|
|
|
725
|
my %seen; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# It is possible the extra amnesty can be a duplicate, so filter it. |
75
|
|
|
|
|
|
|
$out->{amnesty} = [ |
76
|
767
|
100
|
|
|
|
4264
|
grep { !$seen{defined($_->{tag}) ? $_->{tag} : ''}->{defined($_->{details}) ? $_->{details} : ''}++ } |
|
|
50
|
|
|
|
|
|
77
|
|
|
|
|
|
|
@exra_amnesty, |
78
|
488
|
|
|
|
|
752
|
@{$out->{amnesty}}, |
|
488
|
|
|
|
|
1055
|
|
79
|
|
|
|
|
|
|
]; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
1184
|
|
|
|
|
3655
|
return $out; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=pod |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=encoding UTF-8 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 NAME |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Test2::Event::Ok - Ok event type |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 DESCRIPTION |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Ok events are generated whenever you run a test that produces a result. |
100
|
|
|
|
|
|
|
Examples are C<ok()>, and C<is()>. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 SYNOPSIS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
use Test2::API qw/context/; |
105
|
|
|
|
|
|
|
use Test2::Event::Ok; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my $ctx = context(); |
108
|
|
|
|
|
|
|
my $event = $ctx->ok($bool, $name, \@diag); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
or: |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my $ctx = context(); |
113
|
|
|
|
|
|
|
my $event = $ctx->send_event( |
114
|
|
|
|
|
|
|
'Ok', |
115
|
|
|
|
|
|
|
pass => $bool, |
116
|
|
|
|
|
|
|
name => $name, |
117
|
|
|
|
|
|
|
); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 ACCESSORS |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=over 4 |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item $rb = $e->pass |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
The original true/false value of whatever was passed into the event (but |
126
|
|
|
|
|
|
|
reduced down to 1 or 0). |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item $name = $e->name |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Name of the test. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item $b = $e->effective_pass |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This is the true/false value of the test after TODO and similar modifiers are |
135
|
|
|
|
|
|
|
taken into account. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=back |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SOURCE |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
The source code repository for Test2 can be found at |
142
|
|
|
|
|
|
|
F<http://github.com/Test-More/test-more/>. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 MAINTAINERS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=over 4 |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item Chad Granum E<lt>exodist@cpan.orgE<gt> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=back |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 AUTHORS |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=over 4 |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item Chad Granum E<lt>exodist@cpan.orgE<gt> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 COPYRIGHT |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Copyright 2020 Chad Granum E<lt>exodist@cpan.orgE<gt>. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
165
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
See F<http://dev.perl.org/licenses/> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |