line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Unit::Result; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
2
|
|
|
2
|
|
41
|
$Test::Unit::Result::VERSION = '0.25_1325'; # added by dist-tools/SetVersion.pl |
4
|
|
|
|
|
|
|
} |
5
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
57
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
1629
|
use Test::Unit::Debug qw(debug); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
120
|
|
8
|
2
|
|
|
2
|
|
1038
|
use Test::Unit::Error; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
23
|
|
9
|
2
|
|
|
2
|
|
1518
|
use Test::Unit::Failure; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
18
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
98
|
use Error qw/:try/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
37
|
|
|
37
|
0
|
135
|
my $class = shift; |
15
|
37
|
|
|
|
|
963
|
bless { |
16
|
|
|
|
|
|
|
_Failures => [], |
17
|
|
|
|
|
|
|
_Errors => [], |
18
|
|
|
|
|
|
|
_Listeners => [], |
19
|
|
|
|
|
|
|
_Run_tests => 0, |
20
|
|
|
|
|
|
|
_Stop => 0, |
21
|
|
|
|
|
|
|
}, $class; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub tell_listeners { |
25
|
438
|
|
|
438
|
0
|
569
|
my $self = shift; |
26
|
438
|
|
|
|
|
649
|
my $method = shift; |
27
|
438
|
|
|
|
|
511
|
foreach (@{$self->listeners}) { |
|
438
|
|
|
|
|
885
|
|
28
|
342
|
|
|
|
|
1489
|
$_->$method(@_); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub add_error { |
33
|
18
|
|
|
18
|
0
|
183
|
my $self = shift; |
34
|
18
|
|
|
|
|
90
|
debug($self . "::add_error() called\n"); |
35
|
18
|
|
|
|
|
43
|
my ($test, $exception) = @_; |
36
|
18
|
|
|
|
|
40
|
$exception->{-object} = $test; |
37
|
18
|
|
|
|
|
23
|
push @{$self->errors()}, $exception; |
|
18
|
|
|
|
|
51
|
|
38
|
18
|
|
|
|
|
51
|
$self->tell_listeners(add_error => @_); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub add_failure { |
42
|
6
|
|
|
6
|
0
|
9
|
my $self = shift; |
43
|
6
|
|
|
|
|
33
|
debug($self . "::add_failure() called\n"); |
44
|
6
|
|
|
|
|
11
|
my ($test, $exception) = @_; |
45
|
6
|
|
|
|
|
17
|
$exception->{-object} = $test; |
46
|
6
|
|
|
|
|
10
|
push @{$self->failures()}, $exception; |
|
6
|
|
|
|
|
18
|
|
47
|
6
|
|
|
|
|
17
|
$self->tell_listeners(add_failure => @_); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub add_pass { |
51
|
107
|
|
|
107
|
0
|
1378
|
my $self = shift; |
52
|
107
|
|
|
|
|
544
|
debug($self . "::add_pass() called\n"); |
53
|
107
|
|
|
|
|
215
|
my ($test) = @_; |
54
|
107
|
|
|
|
|
499
|
$self->tell_listeners(add_pass => @_); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub add_listener { |
58
|
10
|
|
|
10
|
0
|
28
|
my $self = shift; |
59
|
10
|
|
|
|
|
52
|
debug($self . "::add_listener() called\n"); |
60
|
10
|
|
|
|
|
15
|
my ($listener) = @_; |
61
|
10
|
|
|
|
|
16
|
push @{$self->listeners()}, $listener; |
|
10
|
|
|
|
|
23
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub listeners { |
65
|
448
|
|
|
448
|
0
|
523
|
my $self = shift; |
66
|
448
|
|
|
|
|
1393
|
return $self->{_Listeners}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub end_test { |
70
|
131
|
|
|
131
|
0
|
207
|
my $self = shift; |
71
|
131
|
|
|
|
|
194
|
my ($test) = @_; |
72
|
131
|
|
|
|
|
280
|
$self->tell_listeners(end_test => $test); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub error_count { |
76
|
65
|
|
|
65
|
0
|
137
|
my $self = shift; |
77
|
65
|
|
|
|
|
112
|
return scalar @{$self->{_Errors}}; |
|
65
|
|
|
|
|
586
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub errors { |
81
|
21
|
|
|
21
|
0
|
25
|
my $self = shift; |
82
|
21
|
|
|
|
|
67
|
return $self->{_Errors}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub failure_count { |
86
|
72
|
|
|
72
|
0
|
159
|
my $self = shift; |
87
|
72
|
|
|
|
|
100
|
return scalar @{$self->{_Failures}}; |
|
72
|
|
|
|
|
473
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub failures { |
91
|
6
|
|
|
6
|
0
|
13
|
my $self = shift; |
92
|
6
|
|
|
|
|
18
|
return $self->{_Failures}; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub run { |
96
|
131
|
|
|
131
|
0
|
181
|
my $self = shift; |
97
|
131
|
|
|
|
|
200
|
my ($test) = @_; |
98
|
131
|
|
|
|
|
362
|
debug(sprintf "%s::run(%s) called\n", $self, $test->name()); |
99
|
131
|
|
|
|
|
421
|
$self->start_test($test); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# This closure may look convoluted, but it allows Test::Unit::Setup |
102
|
|
|
|
|
|
|
# to work cleanly. |
103
|
|
|
|
|
|
|
$self->run_protected( |
104
|
|
|
|
|
|
|
$test, |
105
|
|
|
|
|
|
|
sub { |
106
|
131
|
50
|
|
131
|
|
781
|
$test->run_bare() ? |
107
|
|
|
|
|
|
|
$self->add_pass($test) |
108
|
|
|
|
|
|
|
: $self->add_failure($test); |
109
|
|
|
|
|
|
|
} |
110
|
131
|
|
|
|
|
928
|
); |
111
|
|
|
|
|
|
|
|
112
|
131
|
|
|
|
|
10124
|
$self->end_test($test); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub run_protected { |
116
|
131
|
|
|
131
|
0
|
188
|
my $self = shift; |
117
|
131
|
|
|
|
|
167
|
my $test = shift; |
118
|
131
|
|
|
|
|
181
|
my $protectable = shift; |
119
|
131
|
|
|
|
|
685
|
debug("$self\::run_protected($test, $protectable) called\n"); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
try { |
122
|
131
|
|
|
131
|
|
4002
|
&$protectable(); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
catch Test::Unit::Failure with { |
125
|
6
|
|
|
6
|
|
264
|
$self->add_failure($test, shift); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
catch Error with { |
128
|
|
|
|
|
|
|
# *Any* exception which isn't a failure or |
129
|
|
|
|
|
|
|
# Test::Unit::Exception should get rebuilt and added to the |
130
|
|
|
|
|
|
|
# result as a Test::Unit::Error, so that the stringify() |
131
|
|
|
|
|
|
|
# method can be called on it for nice reporting. |
132
|
18
|
|
|
18
|
|
1454
|
my $error = shift; |
133
|
18
|
100
|
|
|
|
252
|
$error = Test::Unit::Error->make_new_from_error($error) |
134
|
|
|
|
|
|
|
unless $error->isa('Test::Unit::Exception'); |
135
|
18
|
|
|
|
|
336
|
$self->add_error($test, $error); |
136
|
131
|
|
|
|
|
1058
|
}; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub run_count { |
140
|
38
|
|
|
38
|
0
|
345
|
my $self = shift; |
141
|
38
|
|
|
|
|
255
|
return $self->{_Run_tests}; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub run_count_inc { |
145
|
131
|
|
|
131
|
0
|
153
|
my $self = shift; |
146
|
131
|
|
|
|
|
195
|
++$self->{_Run_tests}; |
147
|
131
|
|
|
|
|
253
|
return $self->{_Run_tests}; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub should_stop { |
151
|
119
|
|
|
119
|
0
|
164
|
my $self = shift; |
152
|
119
|
|
|
|
|
432
|
return $self->{_Stop}; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub start_test { |
156
|
131
|
|
|
131
|
0
|
179
|
my $self = shift; |
157
|
131
|
|
|
|
|
163
|
my ($test) = @_; |
158
|
131
|
|
|
|
|
305
|
$self->run_count_inc(); |
159
|
131
|
|
|
|
|
269
|
$self->tell_listeners(start_test => $test); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub stop { |
163
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
164
|
0
|
|
|
|
|
0
|
$self->{_Stop} = 1; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub was_successful { |
168
|
38
|
|
|
38
|
0
|
182
|
my $self = shift; |
169
|
38
|
|
100
|
|
|
141
|
return ($self->failure_count() == 0) && ($self->error_count() == 0); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub to_string { |
173
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
174
|
0
|
|
|
|
|
|
my $class = ref($self); |
175
|
0
|
|
|
|
|
|
debug($class . "::to_string() called\n"); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; |
179
|
|
|
|
|
|
|
__END__ |