line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
16683
|
use 5.006; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
23
|
|
3
|
1
|
|
|
1
|
|
2
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Test::Lives; |
6
|
|
|
|
|
|
|
$Test::Lives::VERSION = '1.001'; |
7
|
|
|
|
|
|
|
# ABSTRACT: the 1UP approach to testing exceptional code |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
738
|
use Exporter::Tidy default => [ qw( lives_and ) ]; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
4
|
|
10
|
1
|
|
|
1
|
|
35
|
use Test::Builder (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
131
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $Tester = Test::Builder->new; |
13
|
|
|
|
|
|
|
*Level = \$Test::Builder::Level; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub lives_and (&;$) { |
16
|
3
|
|
|
3
|
0
|
270
|
my ( $code, $name ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
3
|
|
|
|
|
4
|
local our $Level = $Level + 1; # this function |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
3
|
my $ok; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
eval { |
23
|
3
|
|
|
|
|
4
|
local $Level = $Level + 2; # eval block + callback |
24
|
3
|
|
|
|
|
5
|
$ok = $code->() for $name; |
25
|
2
|
|
|
|
|
837
|
1; |
26
|
3
|
100
|
|
|
|
3
|
} or do { |
27
|
1
|
|
|
|
|
9
|
my $e = "$@"; |
28
|
1
|
|
|
|
|
3
|
$ok = $Tester->ok( 0, $name ); |
29
|
1
|
|
|
|
|
290
|
$Tester->diag( $e ); |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
|
|
43
|
return $ok; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |