line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
1399
|
#line 1 |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
100
|
|
2
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
83
|
|
3
|
|
|
|
|
|
|
use warnings; |
4
|
|
|
|
|
|
|
package Test::Fatal; |
5
|
2
|
|
|
2
|
|
29
|
BEGIN { |
6
|
|
|
|
|
|
|
$Test::Fatal::VERSION = '0.003'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
# ABSTRACT: incredibly simple helpers for testing code with exceptions |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
10
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
50
|
|
11
|
2
|
|
|
2
|
|
1144
|
use Carp (); |
|
2
|
|
|
|
|
73
|
|
|
2
|
|
|
|
|
135
|
|
12
|
|
|
|
|
|
|
use Try::Tiny 0.07; |
13
|
2
|
|
|
2
|
|
12
|
|
|
2
|
|
|
|
|
28
|
|
|
2
|
|
|
|
|
537
|
|
14
|
|
|
|
|
|
|
use Exporter 5.59 'import'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT = qw(exception); |
17
|
|
|
|
|
|
|
our @EXPORT_OK = qw(exception success); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
0
|
1
|
|
sub exception (&) { |
21
|
|
|
|
|
|
|
my ($code) = @_; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
0
|
|
|
return try { |
24
|
0
|
|
|
|
|
|
$code->(); |
25
|
|
|
|
|
|
|
return undef; |
26
|
0
|
0
|
|
0
|
|
|
} catch { |
27
|
|
|
|
|
|
|
return $_ if $_; |
28
|
0
|
0
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $problem = defined $_ ? 'false' : 'undef'; |
30
|
0
|
|
|
|
|
|
Carp::confess("$problem exception caught by Test::Fatal::exception"); |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
0
|
1
|
|
sub success (&) { |
36
|
|
|
|
|
|
|
my ($code) = @_; |
37
|
0
|
0
|
|
0
|
|
|
return finally { |
38
|
0
|
|
|
|
|
|
return if @_; # <-- only run on success |
39
|
|
|
|
|
|
|
$code->(); |
40
|
0
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |