line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
2
|
|
|
2
|
|
31781
|
package Test::Exception::LessClever; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
88
|
|
3
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
80
|
|
4
|
|
|
|
|
|
|
use warnings; |
5
|
2
|
|
|
2
|
|
13
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
305
|
|
6
|
2
|
|
|
2
|
|
1970
|
use base 'Exporter'; |
|
2
|
|
|
|
|
29699
|
|
|
2
|
|
|
|
|
99
|
|
7
|
2
|
|
|
2
|
|
21
|
use Test::Builder; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1778
|
|
8
|
|
|
|
|
|
|
use Carp qw/carp/; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#{{{ POD |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#line 52 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#}}} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT_OK = qw/live_or_die/; |
17
|
|
|
|
|
|
|
our @EXPORT = qw/lives_ok dies_ok throws_ok lives_and/; |
18
|
|
|
|
|
|
|
our @CARP_NOT = ( __PACKAGE__ ); |
19
|
|
|
|
|
|
|
our $TB = Test::Builder->new; |
20
|
|
|
|
|
|
|
our $VERSION = "0.006"; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#line 77 |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub live_or_die { |
25
|
|
|
|
|
|
|
my ( $code ) = @_; |
26
|
|
|
|
|
|
|
my $return = eval { $code->(); 'did not die' } || "died"; |
27
|
|
|
|
|
|
|
my $msg = $@; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
if ( $return eq 'did not die' ) { |
30
|
|
|
|
|
|
|
return ( 1, $return ) if wantarray; |
31
|
|
|
|
|
|
|
return 1; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
|
|
|
|
|
|
return 0 unless wantarray; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
if ( !$msg ) { |
37
|
|
|
|
|
|
|
carp "code died as expected, however the error is masked. This" |
38
|
|
|
|
|
|
|
. " can occur when an object's DESTROY() method calls eval"; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
return ( 0, $msg ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#line 104 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub lives_ok(&;$) { |
48
|
|
|
|
|
|
|
my ( $code, $name ) = @_; |
49
|
|
|
|
|
|
|
my $ok = live_or_die( $code ); |
50
|
|
|
|
|
|
|
$TB->ok( $ok, $name ); |
51
|
|
|
|
|
|
|
return $ok; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#line 117 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub dies_ok(&;$) { |
57
|
|
|
|
|
|
|
my ( $code, $name ) = @_; |
58
|
|
|
|
|
|
|
my $ok = live_or_die( $code ); |
59
|
|
|
|
|
|
|
$TB->ok( !$ok, $name ); |
60
|
|
|
|
|
|
|
return !$ok; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#line 132 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub throws_ok(&$;$) { |
66
|
|
|
|
|
|
|
my ( $code, $reg, $name ) = @_; |
67
|
|
|
|
|
|
|
my ( $ok, $msg ) = live_or_die( $code ); |
68
|
|
|
|
|
|
|
my ( $pkg, $file, $number ) = caller; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# If we lived |
71
|
|
|
|
|
|
|
if ( $ok ) { |
72
|
|
|
|
|
|
|
$TB->diag( "Test did not die as expected at $file line $number." ); |
73
|
|
|
|
|
|
|
return $TB->ok( !$ok, $name ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $match = $msg =~ $reg ? 1 : 0; |
77
|
|
|
|
|
|
|
$TB->ok( $match, $name ); |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
0
|
1
|
|
$TB->diag( "$file line $number:\n Wanted: $reg\n Got: $msg" ) |
80
|
0
|
|
0
|
|
|
|
unless( $match ); |
81
|
0
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
return $match; |
83
|
0
|
0
|
|
|
|
|
} |
84
|
0
|
0
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
#line 160 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub lives_and(&;$) { |
88
|
0
|
0
|
|
|
|
|
my ( $code, $name ) = @_; |
89
|
|
|
|
|
|
|
my ( $ok, $msg )= live_or_die( $code ); |
90
|
0
|
0
|
|
|
|
|
my ( $pkg, $file, $number ) = caller; |
91
|
0
|
|
|
|
|
|
chomp( $msg ); |
92
|
|
|
|
|
|
|
$msg =~ s/\n/ /g; |
93
|
|
|
|
|
|
|
$TB->diag( "Test unexpectedly died: '$msg' at $file line $number." ) unless $ok; |
94
|
|
|
|
|
|
|
$TB->ok( $ok, $name ) if !$ok; |
95
|
0
|
|
|
|
|
|
return $ok; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |
101
|
|
|
|
|
|
|
|