| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Unit::TestCase; |
|
2
|
|
|
|
|
|
|
BEGIN { |
|
3
|
2
|
|
|
2
|
|
51
|
$Test::Unit::TestCase::VERSION = '0.25_1325'; # added by dist-tools/SetVersion.pl |
|
4
|
|
|
|
|
|
|
} |
|
5
|
2
|
|
|
2
|
|
11
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
2200
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
23
|
use base qw(Test::Unit::Test); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
206
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
10
|
use Test::Unit::Debug qw(debug); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
98
|
|
|
10
|
2
|
|
|
2
|
|
14
|
use Test::Unit::Failure; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
28
|
|
|
11
|
2
|
|
|
2
|
|
104
|
use Test::Unit::Error; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
13
|
|
|
12
|
2
|
|
|
2
|
|
160
|
use Test::Unit::Result; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
52
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
10
|
use Devel::Symdump; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
70
|
|
|
15
|
2
|
|
|
2
|
|
2538
|
use Class::Inner; |
|
|
2
|
|
|
|
|
2178
|
|
|
|
2
|
|
|
|
|
66
|
|
|
16
|
2
|
|
|
2
|
|
15
|
use Error qw/:try/; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
14
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
|
19
|
144
|
|
|
144
|
0
|
5532
|
my $class = shift; |
|
20
|
144
|
|
|
|
|
191
|
my ($name) = @_; |
|
21
|
144
|
|
|
|
|
1033
|
bless { |
|
22
|
|
|
|
|
|
|
__PACKAGE__ . '_name' => $name, |
|
23
|
|
|
|
|
|
|
__PACKAGE__ . '_annotations' => '', |
|
24
|
|
|
|
|
|
|
}, $class; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub annotate { |
|
28
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
29
|
0
|
|
|
|
|
0
|
$self->{__PACKAGE__ . '_annotations'} .= join '', @_; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
6
|
|
|
6
|
0
|
66
|
sub annotations { $_[0]->{__PACKAGE__ . '_annotations'} } |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub count_test_cases { |
|
35
|
90
|
|
|
90
|
0
|
128
|
my $self = shift; |
|
36
|
90
|
|
|
|
|
434
|
return 1; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub create_result { |
|
40
|
18
|
|
|
18
|
0
|
44
|
my $self = shift; |
|
41
|
18
|
|
|
|
|
82
|
return Test::Unit::Result->new(); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub name { |
|
45
|
872
|
|
|
872
|
0
|
1015
|
my $self = shift; |
|
46
|
872
|
|
|
|
|
4005
|
return $self->{__PACKAGE__ . '_name'}; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub run { |
|
50
|
131
|
|
|
131
|
0
|
517
|
my $self = shift; |
|
51
|
131
|
|
|
|
|
445
|
debug(ref($self), "::run() called on ", $self->name, "\n"); |
|
52
|
131
|
|
|
|
|
231
|
my ($result, $runner) = @_; |
|
53
|
131
|
|
66
|
|
|
344
|
$result ||= create_result(); |
|
54
|
131
|
|
|
|
|
583
|
$result->run($self); |
|
55
|
131
|
|
|
|
|
579
|
return $result; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub run_bare { |
|
59
|
131
|
|
|
131
|
0
|
230
|
my $self = shift; |
|
60
|
131
|
|
|
|
|
355
|
debug(" ", ref($self), "::run_bare() called on ", $self->name, "\n"); |
|
61
|
131
|
|
|
|
|
662
|
$self->set_up(); |
|
62
|
|
|
|
|
|
|
# Make sure tear_down happens if and only if set_up() succeeds. |
|
63
|
|
|
|
|
|
|
try { |
|
64
|
128
|
|
|
128
|
|
2257
|
$self->run_test(); |
|
65
|
107
|
|
|
|
|
6920
|
1; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
finally { |
|
68
|
128
|
|
|
128
|
|
3686
|
$self->tear_down; |
|
69
|
128
|
|
|
|
|
857
|
}; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub run_test { |
|
73
|
64
|
|
|
64
|
0
|
101
|
my $self = shift; |
|
74
|
64
|
|
|
|
|
211
|
debug(" ", ref($self) . "::run_test() called on ", $self->name, "\n"); |
|
75
|
64
|
|
|
|
|
148
|
my $method = $self->name(); |
|
76
|
64
|
100
|
|
|
|
432
|
if ($self->can($method)) { |
|
77
|
63
|
|
|
|
|
283
|
debug(" running `$method'\n"); |
|
78
|
63
|
|
|
|
|
286
|
$self->$method(); |
|
79
|
|
|
|
|
|
|
} else { |
|
80
|
1
|
|
|
|
|
11
|
$self->fail(" Method `$method' not found"); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
111
|
|
|
111
|
1
|
139
|
sub set_up { 1 } |
|
85
|
|
|
|
|
|
|
|
|
86
|
118
|
|
|
118
|
1
|
283
|
sub tear_down { 1 } |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub to_string { |
|
89
|
17
|
|
|
17
|
0
|
37
|
my $self = shift; |
|
90
|
17
|
|
|
|
|
28
|
my $class = ref($self); |
|
91
|
17
|
|
50
|
|
|
39
|
return ($self->name() || "ANON") . "(" . $class . ")"; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub make_test_from_coderef { |
|
95
|
45
|
|
|
45
|
1
|
305
|
my ($self, $coderef, @args) = @_; |
|
96
|
45
|
50
|
|
|
|
86
|
die "Need a coderef argument" unless $coderef; |
|
97
|
45
|
|
33
|
|
|
225
|
return Class::Inner->new(parent => ($self || ref $self), |
|
98
|
|
|
|
|
|
|
methods => {run_test => $coderef}, |
|
99
|
|
|
|
|
|
|
args => [ @args ]); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# Returns a list of the tests run by this class and its superclasses. |
|
104
|
|
|
|
|
|
|
# DO NOT OVERRIDE THIS UNLESS YOU KNOW WHAT YOU ARE DOING! |
|
105
|
|
|
|
|
|
|
sub list_tests { |
|
106
|
49
|
|
33
|
49
|
1
|
230
|
my $class = ref($_[0]) || $_[0]; |
|
107
|
49
|
|
|
|
|
77
|
my @tests = (); |
|
108
|
2
|
|
|
2
|
|
2618
|
no strict 'refs'; |
|
|
2
|
|
|
|
|
12
|
|
|
|
2
|
|
|
|
|
1240
|
|
|
109
|
49
|
50
|
|
|
|
63
|
if (defined(@{"$class\::TESTS"})) { |
|
|
49
|
|
|
|
|
302
|
|
|
110
|
0
|
|
|
|
|
0
|
push @tests, @{"$class\::TESTS"}; |
|
|
0
|
|
|
|
|
0
|
|
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
else { |
|
113
|
49
|
|
|
|
|
330
|
push @tests, $class->get_matching_methods(qr/::(test[^:]*)$/); |
|
114
|
|
|
|
|
|
|
} |
|
115
|
49
|
100
|
|
|
|
187
|
push @tests, map {$_->can('list_tests') ? $_->list_tests : () } @{"$class\::ISA"}; |
|
|
52
|
|
|
|
|
565
|
|
|
|
49
|
|
|
|
|
182
|
|
|
116
|
49
|
|
|
|
|
102
|
my %tests = map {$_ => ''} @tests; |
|
|
100
|
|
|
|
|
228
|
|
|
117
|
49
|
|
|
|
|
212
|
return keys %tests; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub get_matching_methods { |
|
121
|
49
|
|
33
|
49
|
1
|
136
|
my $class = ref($_[0]) || $_[0]; |
|
122
|
49
|
|
|
|
|
63
|
my $re = $_[1]; |
|
123
|
49
|
|
|
|
|
40752
|
my $st = Devel::Symdump->new($class); |
|
124
|
49
|
100
|
|
|
|
2033
|
return map { /$re/ ? $1 : () } $st->functions(); |
|
|
625
|
|
|
|
|
2465
|
|
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub list { |
|
128
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
129
|
0
|
|
|
|
|
|
my $show_testcases = shift; |
|
130
|
0
|
0
|
0
|
|
|
|
return $show_testcases ? |
|
131
|
|
|
|
|
|
|
[ ($self->name() || 'anonymous testcase') . "\n" ] |
|
132
|
|
|
|
|
|
|
: []; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
|
136
|
|
|
|
|
|
|
__END__ |