line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::DatabaseRow::Result; |
2
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
32248
|
use strict; |
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
415
|
|
4
|
12
|
|
|
12
|
|
58
|
use warnings; |
|
12
|
|
|
|
|
21
|
|
|
12
|
|
|
|
|
567
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "2.01"; |
7
|
|
|
|
|
|
|
|
8
|
12
|
|
|
12
|
|
63
|
use Carp qw(croak); |
|
12
|
|
|
|
|
22
|
|
|
12
|
|
|
|
|
7894
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
## constructor ######################################################### |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# emulate moose somewhat by calling a _coerce_and_verify_XXX method |
13
|
|
|
|
|
|
|
# if one exists |
14
|
|
|
|
|
|
|
sub new { |
15
|
96
|
|
|
96
|
1
|
4636
|
my $class = shift; |
16
|
96
|
|
|
|
|
305
|
my $self = bless {}, $class; |
17
|
96
|
|
|
|
|
315
|
while (@_) { |
18
|
43
|
|
|
|
|
66
|
my $key = shift; |
19
|
43
|
|
|
|
|
57
|
my $value = shift; |
20
|
43
|
|
|
|
|
220
|
my $method = $self->can("_coerce_and_verify_$key"); |
21
|
43
|
100
|
|
|
|
194
|
$self->{ $key } = $method ? $method->($self,$value) : $value; |
22
|
|
|
|
|
|
|
} |
23
|
95
|
|
|
|
|
376
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
## accessors ############################################################ |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# has is_error => ( is => "ro", isa => "Bool", default => 0, |
29
|
|
|
|
|
|
|
# predicate => 'has_error' ) |
30
|
|
|
|
|
|
|
sub is_error { |
31
|
111
|
|
|
111
|
1
|
5485
|
my $self = shift; |
32
|
111
|
|
100
|
|
|
470
|
$self->{is_error} ||= 0; |
33
|
111
|
|
|
|
|
550
|
return $self->{is_error}; |
34
|
|
|
|
|
|
|
} |
35
|
2
|
|
|
2
|
0
|
22
|
sub has_is_error { my $self = shift; return exists $self->{is_error} } |
|
2
|
|
|
|
|
18
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# has diag => ( is => "rw", isa => "ArrayRef", default => sub {[]}, |
38
|
|
|
|
|
|
|
# predicate => "has_diag", |
39
|
|
|
|
|
|
|
# traits => ['Array'], handles => { add_diag => 'push' }) |
40
|
|
|
|
|
|
|
sub diag { |
41
|
43
|
|
|
43
|
1
|
76
|
my $self = shift; |
42
|
43
|
|
100
|
|
|
302
|
$self->{diag} ||= []; |
43
|
43
|
|
|
|
|
223
|
return $self->{diag}; |
44
|
|
|
|
|
|
|
} |
45
|
2
|
|
|
2
|
0
|
969
|
sub has_diag { my $self = shift; return exists $self->{diag} } |
|
2
|
|
|
|
|
15
|
|
46
|
|
|
|
|
|
|
sub _coerce_and_verify_diag { |
47
|
22
|
|
|
22
|
|
33
|
my $self = shift; |
48
|
22
|
|
|
|
|
40
|
my $diag = shift; |
49
|
22
|
100
|
|
|
|
216
|
croak "Invalid argument to diag" unless ref($diag) eq "ARRAY"; |
50
|
21
|
|
|
|
|
95
|
return $diag; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
sub add_diag { |
53
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
54
|
1
|
|
|
|
|
2
|
push @{ $self->diag }, @_; |
|
1
|
|
|
|
|
3
|
|
55
|
1
|
|
|
|
|
2
|
return; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
## methods ############################################################# |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub pass_to_test_builder { |
61
|
39
|
|
|
39
|
1
|
86
|
my $self = shift; |
62
|
39
|
|
|
|
|
75
|
my $description = shift; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# get the test builder singleton |
65
|
39
|
|
|
|
|
185
|
my $tester = Test::Builder->new(); |
66
|
|
|
|
|
|
|
|
67
|
39
|
|
|
|
|
301
|
my $result = $tester->ok($self->is_success, $description); |
68
|
39
|
|
|
|
|
49099
|
$tester->diag($_) foreach @{ $self->diag }; |
|
39
|
|
|
|
|
129
|
|
69
|
39
|
|
|
|
|
5556
|
return $result; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub is_success { |
73
|
41
|
|
|
41
|
1
|
66
|
my $self = shift; |
74
|
41
|
|
|
|
|
85
|
return !$self->is_error; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |