line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::More::Hooks; |
2
|
4
|
|
|
4
|
|
57019
|
use 5.008005; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
144
|
|
3
|
4
|
|
|
4
|
|
20
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
126
|
|
4
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
34
|
|
|
4
|
|
|
|
|
196
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.12"; |
7
|
4
|
|
|
4
|
|
27
|
use Carp qw(croak); |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
308
|
|
8
|
4
|
|
|
4
|
|
32
|
use Test::Builder::Module; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
29
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Test::Builder::Module); |
10
|
|
|
|
|
|
|
our @EXPORT = qw(subtest before after); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# $ LEVEL is controlled by the local variable. |
13
|
|
|
|
|
|
|
our $LEVEL = 0; |
14
|
|
|
|
|
|
|
my $BEFORE = {}; |
15
|
|
|
|
|
|
|
my $AFTER = {}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
BEGIN { |
18
|
4
|
100
|
|
4
|
|
1310
|
croak "Test::More::Hooks must be loaded after Test::More." |
19
|
|
|
|
|
|
|
unless exists $INC{'Test/More.pm'}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub subtest { |
23
|
16
|
|
|
16
|
0
|
1738
|
my ($name, $subtests) = @_; |
24
|
16
|
100
|
|
|
|
72
|
$BEFORE->{$LEVEL}->() if 'CODE' eq ref $BEFORE->{$LEVEL}; |
25
|
|
|
|
|
|
|
|
26
|
16
|
|
|
|
|
30
|
my $result; |
27
|
|
|
|
|
|
|
{ |
28
|
16
|
|
|
|
|
17
|
local $LEVEL = $LEVEL + 1; |
|
16
|
|
|
|
|
28
|
|
29
|
16
|
|
|
|
|
86
|
my $tb = Test::More::Hooks->builder; |
30
|
16
|
|
|
|
|
179
|
$result = $tb->subtest(@_); |
31
|
16
|
|
|
|
|
22195
|
_clean_hooks(); |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
16
|
100
|
|
|
|
77
|
$AFTER->{$LEVEL}->() if 'CODE' eq ref $AFTER->{$LEVEL}; |
35
|
16
|
|
|
|
|
50
|
return $result; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub before (&) { |
39
|
3
|
|
|
3
|
1
|
2636
|
my $block = shift; |
40
|
3
|
|
|
|
|
11
|
$BEFORE->{$LEVEL} = $block; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub after (&) { |
44
|
3
|
|
|
3
|
1
|
1910
|
my $block = shift; |
45
|
3
|
|
|
|
|
11
|
$AFTER->{$LEVEL} = $block; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub level { |
49
|
8
|
|
|
8
|
0
|
3128
|
return $LEVEL; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _clean_hooks { |
53
|
16
|
|
|
16
|
|
42
|
$BEFORE->{$LEVEL} = undef; |
54
|
16
|
|
|
|
|
49
|
$AFTER->{$LEVEL} = undef; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
__END__ |