line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Unit::Result; |
2
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
77
|
|
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
696
|
use Test::Unit::Debug qw(debug); |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
140
|
|
5
|
2
|
|
|
2
|
|
1361
|
use Test::Unit::Error; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
19
|
|
6
|
2
|
|
|
2
|
|
1971
|
use Test::Unit::Failure; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
16
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
93
|
use Error qw/:try/; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
143
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
37
|
|
|
37
|
0
|
128
|
my $class = shift; |
12
|
37
|
|
|
|
|
360
|
bless { |
13
|
|
|
|
|
|
|
_Failures => [], |
14
|
|
|
|
|
|
|
_Errors => [], |
15
|
|
|
|
|
|
|
_Listeners => [], |
16
|
|
|
|
|
|
|
_Run_tests => 0, |
17
|
|
|
|
|
|
|
_Stop => 0, |
18
|
|
|
|
|
|
|
}, $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub tell_listeners { |
22
|
423
|
|
|
423
|
0
|
573
|
my $self = shift; |
23
|
423
|
|
|
|
|
495
|
my $method = shift; |
24
|
423
|
|
|
|
|
468
|
foreach (@{$self->listeners}) { |
|
423
|
|
|
|
|
906
|
|
25
|
327
|
|
|
|
|
1663
|
$_->$method(@_); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub add_error { |
30
|
18
|
|
|
18
|
0
|
191
|
my $self = shift; |
31
|
18
|
|
|
|
|
78
|
debug($self . "::add_error() called\n"); |
32
|
18
|
|
|
|
|
36
|
my ($test, $exception) = @_; |
33
|
18
|
|
|
|
|
47
|
$exception->{-object} = $test; |
34
|
18
|
|
|
|
|
35
|
push @{$self->errors()}, $exception; |
|
18
|
|
|
|
|
58
|
|
35
|
18
|
|
|
|
|
84
|
$self->tell_listeners(add_error => @_); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub add_failure { |
39
|
9
|
|
|
9
|
0
|
25
|
my $self = shift; |
40
|
9
|
|
|
|
|
47
|
debug($self . "::add_failure() called\n"); |
41
|
9
|
|
|
|
|
20
|
my ($test, $exception) = @_; |
42
|
9
|
|
|
|
|
25
|
$exception->{-object} = $test; |
43
|
9
|
|
|
|
|
16
|
push @{$self->failures()}, $exception; |
|
9
|
|
|
|
|
32
|
|
44
|
9
|
|
|
|
|
35
|
$self->tell_listeners(add_failure => @_); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub add_pass { |
48
|
99
|
|
|
99
|
0
|
1773
|
my $self = shift; |
49
|
99
|
|
|
|
|
534
|
debug($self . "::add_pass() called\n"); |
50
|
99
|
|
|
|
|
172
|
my ($test) = @_; |
51
|
99
|
|
|
|
|
430
|
$self->tell_listeners(add_pass => @_); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub add_listener { |
55
|
10
|
|
|
10
|
0
|
25
|
my $self = shift; |
56
|
10
|
|
|
|
|
54
|
debug($self . "::add_listener() called\n"); |
57
|
10
|
|
|
|
|
21
|
my ($listener) = @_; |
58
|
10
|
|
|
|
|
17
|
push @{$self->listeners()}, $listener; |
|
10
|
|
|
|
|
27
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub listeners { |
62
|
433
|
|
|
433
|
0
|
532
|
my $self = shift; |
63
|
433
|
|
|
|
|
1279
|
return $self->{_Listeners}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub end_test { |
67
|
126
|
|
|
126
|
0
|
205
|
my $self = shift; |
68
|
126
|
|
|
|
|
511
|
my ($test) = @_; |
69
|
126
|
|
|
|
|
301
|
$self->tell_listeners(end_test => $test); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub error_count { |
73
|
65
|
|
|
65
|
0
|
165
|
my $self = shift; |
74
|
65
|
|
|
|
|
108
|
return scalar @{$self->{_Errors}}; |
|
65
|
|
|
|
|
557
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub errors { |
78
|
21
|
|
|
21
|
0
|
28
|
my $self = shift; |
79
|
21
|
|
|
|
|
65
|
return $self->{_Errors}; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub failure_count { |
83
|
72
|
|
|
72
|
0
|
162
|
my $self = shift; |
84
|
72
|
|
|
|
|
102
|
return scalar @{$self->{_Failures}}; |
|
72
|
|
|
|
|
845
|
|
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub failures { |
88
|
9
|
|
|
9
|
0
|
13
|
my $self = shift; |
89
|
9
|
|
|
|
|
63
|
return $self->{_Failures}; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub run { |
93
|
126
|
|
|
126
|
0
|
192
|
my $self = shift; |
94
|
126
|
|
|
|
|
174
|
my ($test) = @_; |
95
|
126
|
|
|
|
|
417
|
debug(sprintf "%s::run(%s) called\n", $self, $test->name()); |
96
|
126
|
|
|
|
|
527
|
$self->start_test($test); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# This closure may look convoluted, but it allows Test::Unit::Setup |
99
|
|
|
|
|
|
|
# to work cleanly. |
100
|
|
|
|
|
|
|
$self->run_protected( |
101
|
|
|
|
|
|
|
$test, |
102
|
|
|
|
|
|
|
sub { |
103
|
126
|
50
|
|
126
|
|
737
|
$test->run_bare() ? |
104
|
|
|
|
|
|
|
$self->add_pass($test) |
105
|
|
|
|
|
|
|
: $self->add_failure($test); |
106
|
|
|
|
|
|
|
} |
107
|
126
|
|
|
|
|
896
|
); |
108
|
|
|
|
|
|
|
|
109
|
126
|
|
|
|
|
7617
|
$self->end_test($test); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub run_protected { |
113
|
126
|
|
|
126
|
0
|
212
|
my $self = shift; |
114
|
126
|
|
|
|
|
172
|
my $test = shift; |
115
|
126
|
|
|
|
|
160
|
my $protectable = shift; |
116
|
126
|
|
|
|
|
642
|
debug("$self\::run_protected($test, $protectable) called\n"); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
try { |
119
|
126
|
|
|
126
|
|
5057
|
&$protectable(); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
catch Test::Unit::Failure with { |
122
|
9
|
|
|
9
|
|
392
|
$self->add_failure($test, shift); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
catch Error with { |
125
|
|
|
|
|
|
|
# *Any* exception which isn't a failure or |
126
|
|
|
|
|
|
|
# Test::Unit::Exception should get rebuilt and added to the |
127
|
|
|
|
|
|
|
# result as a Test::Unit::Error, so that the stringify() |
128
|
|
|
|
|
|
|
# method can be called on it for nice reporting. |
129
|
18
|
|
|
18
|
|
1343
|
my $error = shift; |
130
|
18
|
100
|
|
|
|
150
|
$error = Test::Unit::Error->make_new_from_error($error) |
131
|
|
|
|
|
|
|
unless $error->isa('Test::Unit::Exception'); |
132
|
18
|
|
|
|
|
393
|
$self->add_error($test, $error); |
133
|
126
|
|
|
|
|
2837
|
}; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub run_count { |
137
|
38
|
|
|
38
|
0
|
281
|
my $self = shift; |
138
|
38
|
|
|
|
|
226
|
return $self->{_Run_tests}; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub run_count_inc { |
142
|
126
|
|
|
126
|
0
|
162
|
my $self = shift; |
143
|
126
|
|
|
|
|
220
|
++$self->{_Run_tests}; |
144
|
126
|
|
|
|
|
290
|
return $self->{_Run_tests}; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub should_stop { |
148
|
114
|
|
|
114
|
0
|
233
|
my $self = shift; |
149
|
114
|
|
|
|
|
396
|
return $self->{_Stop}; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub start_test { |
153
|
126
|
|
|
126
|
0
|
170
|
my $self = shift; |
154
|
126
|
|
|
|
|
182
|
my ($test) = @_; |
155
|
126
|
|
|
|
|
307
|
$self->run_count_inc(); |
156
|
126
|
|
|
|
|
414
|
$self->tell_listeners(start_test => $test); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub stop { |
160
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
161
|
0
|
|
|
|
|
0
|
$self->{_Stop} = 1; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub was_successful { |
165
|
38
|
|
|
38
|
0
|
144
|
my $self = shift; |
166
|
38
|
|
100
|
|
|
131
|
return ($self->failure_count() == 0) && ($self->error_count() == 0); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub to_string { |
170
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
171
|
0
|
|
|
|
|
|
my $class = ref($self); |
172
|
0
|
|
|
|
|
|
debug($class . "::to_string() called\n"); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
1; |
176
|
|
|
|
|
|
|
__END__ |