line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Unit::Assertion::Exception; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
22
|
$Test::Unit::Assertion::Exception::VERSION = '0.25_1325'; # added by dist-tools/SetVersion.pl |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
7
|
1
|
|
|
1
|
|
5
|
use base qw/Test::Unit::Assertion/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
77
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
10
|
1
|
|
|
1
|
|
4
|
use Error qw/:try/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
11
|
1
|
|
|
1
|
|
138
|
use Test::Unit::Debug qw(debug); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
318
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $deparser; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
4
|
|
|
4
|
1
|
5
|
my $class = shift; |
17
|
4
|
|
|
|
|
7
|
my $exception_class = shift; |
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
|
|
4
|
my $prob; |
20
|
4
|
50
|
|
|
|
10
|
$prob = "none given" unless defined $exception_class; |
21
|
4
|
50
|
|
|
|
24
|
$prob = "$exception_class has no catch method" |
22
|
|
|
|
|
|
|
unless UNIVERSAL::can($exception_class, "catch"); |
23
|
4
|
50
|
|
|
|
9
|
croak "$class\::new needs an exception class - $prob" if $prob; |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
15
|
bless \$exception_class => $class; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub do_assertion { |
29
|
4
|
|
|
4
|
1
|
8
|
my $self = shift; |
30
|
4
|
|
|
|
|
6
|
my $coderef = shift; |
31
|
4
|
|
|
|
|
7
|
my $exception_class = $$self; |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
|
|
|
5
|
my $exception; |
34
|
|
|
|
|
|
|
try { |
35
|
4
|
|
|
4
|
|
80
|
&$coderef(); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
catch $exception_class with { |
38
|
2
|
|
|
2
|
|
241
|
$exception = shift; |
39
|
4
|
|
|
|
|
22
|
}; |
40
|
|
|
|
|
|
|
|
41
|
4
|
100
|
66
|
|
|
67
|
if (! $exception || ! $exception->isa($$self)) { |
42
|
2
|
100
|
|
|
|
16
|
$self->fail(@_ ? $_[0] : "No $exception_class was raised"); |
43
|
|
|
|
|
|
|
} |
44
|
2
|
|
|
|
|
22
|
return $exception; # so that it can be stored in the test for the |
45
|
|
|
|
|
|
|
# user to get at. |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub to_string { |
49
|
10
|
|
|
10
|
0
|
15
|
my $self = shift; |
50
|
10
|
|
|
|
|
60
|
return "$$self exception assertion"; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
__END__ |