line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Section::Fixture; |
2
|
1
|
|
|
1
|
|
932
|
use 5.008005; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
43
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
19
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
1021
|
use Data::Section::Simple; |
|
1
|
|
|
|
|
535
|
|
|
1
|
|
|
|
|
58
|
|
6
|
1
|
|
|
1
|
|
830
|
use Scope::Guard; |
|
1
|
|
|
|
|
432
|
|
|
1
|
|
|
|
|
39
|
|
7
|
1
|
|
|
1
|
|
6
|
use base qw(Exporter); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
324
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw(with_fixture); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub with_fixture ($&) { |
14
|
0
|
|
|
0
|
1
|
|
my ($dbh, $code) = @_; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my ($pkg) = caller; |
17
|
0
|
|
|
|
|
|
my $reader = Data::Section::Simple->new($pkg); |
18
|
0
|
|
0
|
|
|
|
my $setup_sqls = $reader->get_data_section('setup') || ''; |
19
|
0
|
|
0
|
|
|
|
my $teardown_sqls = $reader->get_data_section('teardown') || ''; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $guard = Scope::Guard->new(sub { |
22
|
0
|
|
|
0
|
|
|
_exec_sqls($dbh, $teardown_sqls); |
23
|
0
|
|
|
|
|
|
}); |
24
|
0
|
|
|
|
|
|
_exec_sqls($dbh, $setup_sqls); |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$code->(); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _exec_sqls { |
30
|
0
|
|
|
0
|
|
|
my ($dbh, $sqls) = @_; |
31
|
0
|
|
|
|
|
|
for (split ';', $sqls) { |
32
|
0
|
0
|
|
|
|
|
$dbh->do($_) unless $_ =~ /^\s+$/; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
__END__ |