line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
19
|
|
|
19
|
|
45923
|
use strict; |
|
19
|
|
|
|
|
41
|
|
|
19
|
|
|
|
|
821
|
|
2
|
19
|
|
|
19
|
|
108
|
use warnings FATAL => 'all'; |
|
19
|
|
|
|
|
88
|
|
|
19
|
|
|
|
|
1159
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package HTML::Tested::List; |
5
|
19
|
|
|
19
|
|
22397
|
use HTML::Tested::List::Renderer; |
|
19
|
|
|
|
|
49
|
|
|
19
|
|
|
|
|
780
|
|
6
|
19
|
|
|
19
|
|
13195
|
use HTML::Tested::List::Table; |
|
19
|
|
|
|
|
63
|
|
|
19
|
|
|
|
|
1488
|
|
7
|
19
|
|
|
19
|
|
124
|
use Carp; |
|
19
|
|
|
|
|
39
|
|
|
19
|
|
|
|
|
4579
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
22
|
|
|
22
|
0
|
75
|
my ($class, $parent, $name, $c, %args) = @_; |
11
|
22
|
|
33
|
|
|
215
|
$args{name} ||= $name; |
12
|
|
|
|
|
|
|
|
13
|
22
|
|
|
|
|
54
|
my @renderers = ('HTML::Tested::List::Renderer'); |
14
|
22
|
100
|
|
|
|
98
|
push @renderers, HTML::Tested::List::Table->new if $args{render_table}; |
15
|
|
|
|
|
|
|
|
16
|
22
|
|
100
|
|
|
200
|
$args{renderers} ||= \@renderers; |
17
|
|
|
|
|
|
|
{ |
18
|
19
|
|
|
19
|
|
103
|
no strict 'refs'; |
|
19
|
|
|
|
|
37
|
|
|
19
|
|
|
|
|
25302
|
|
|
22
|
|
|
|
|
37
|
|
19
|
22
|
100
|
|
|
|
95
|
if (!$c) { |
20
|
5
|
|
|
|
|
14
|
$c = "$parent\::Item$name"; |
21
|
5
|
|
100
|
|
|
10
|
push @{ "$c\::ISA" }, ($args{cbase} || "HTML::Tested"); |
|
5
|
|
|
|
|
117
|
|
22
|
|
|
|
|
|
|
} |
23
|
22
|
|
|
1
|
|
118
|
*{ "$parent\::$name\_containee" } = sub { return $c; }; |
|
22
|
|
|
|
|
141
|
|
|
1
|
|
|
|
|
1425
|
|
24
|
22
|
|
|
|
|
199
|
*{ "$parent\::$name\_containee_do" } = sub { |
25
|
1
|
|
|
1
|
|
26
|
my ($self, $func, @args) = @_; |
26
|
1
|
|
|
|
|
6
|
return $self->$name($c->$func(@args)); |
27
|
22
|
|
|
|
|
129
|
}; |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
22
|
|
33
|
|
|
143
|
$args{containee} ||= $c; |
31
|
22
|
|
|
|
|
62
|
my $self = bless(\%args, $class); |
32
|
22
|
|
|
|
|
39
|
for my $r (@{ $self->renderers }) { |
|
22
|
|
|
|
|
82
|
|
33
|
26
|
|
|
|
|
152
|
$r->init($self, $parent); |
34
|
|
|
|
|
|
|
} |
35
|
21
|
|
|
|
|
88
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
405
|
|
|
405
|
0
|
2290
|
sub name { return shift()->{name}; } |
39
|
58
|
|
|
58
|
0
|
545
|
sub renderers { return shift()->{renderers}; } |
40
|
0
|
|
|
0
|
0
|
0
|
sub options { return {}; } |
41
|
2
|
|
|
2
|
|
11
|
sub _get_option { return undef; } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub render { |
44
|
36
|
|
|
36
|
0
|
81
|
my ($self, $caller, $stash, $id) = @_; |
45
|
36
|
|
|
|
|
65
|
for my $r (@{ $self->renderers }) { |
|
36
|
|
|
|
|
102
|
|
46
|
40
|
|
|
|
|
213
|
$r->render($self, $caller, $stash, $id); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub containee { |
51
|
147
|
50
|
|
147
|
0
|
386
|
my $res = shift()->{containee} or confess "No containee argument given"; |
52
|
147
|
|
|
|
|
591
|
return $res; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub bless_from_tree { |
56
|
3
|
|
|
3
|
0
|
6
|
my ($self, $p) = @_; |
57
|
3
|
|
|
|
|
7
|
my $target = $self->containee; |
58
|
3
|
|
|
|
|
6
|
return [ map { $target->ht_bless_from_tree($_) } @$p ]; |
|
6
|
|
|
|
|
26
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
1
|
0
|
7
|
sub merge_one_value { shift()->_do_one_value("merge_one_value", @_); } |
62
|
119
|
|
|
119
|
0
|
255
|
sub absorb_one_value { shift()->_do_one_value("absorb_one_value", @_); } |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub _do_one_value { |
65
|
120
|
|
|
120
|
|
653
|
my ($self, $func, $root, $val, @path) = @_; |
66
|
120
|
|
100
|
|
|
311
|
my $arr = $root->{ $self->name } || []; |
67
|
120
|
50
|
|
|
|
385
|
my $id = shift(@path) or return; |
68
|
120
|
|
100
|
|
|
551
|
$arr->[--$id] ||= bless({}, $self->containee); |
69
|
120
|
|
|
|
|
1402
|
$arr->[$id]->_ht_set_one($func, $val, @path); |
70
|
120
|
|
|
|
|
284
|
$root->{ $self->name } = $arr; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub finish_load { |
74
|
13
|
|
|
13
|
0
|
23
|
my ($self, $root) = @_; |
75
|
13
|
|
|
|
|
25
|
my @arr = grep { $_ } @{ $root->{ $self->name } }; |
|
119
|
|
|
|
|
199
|
|
|
13
|
|
|
|
|
38
|
|
76
|
13
|
100
|
|
|
|
78
|
$root->{ $self->name } = \@arr unless $self->{keep_holes}; |
77
|
13
|
|
|
|
|
121
|
$_->_call_finish_load for @arr; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub validate { |
81
|
5
|
|
|
5
|
0
|
11
|
my ($self, $caller) = @_; |
82
|
5
|
|
|
|
|
10
|
my $n = $self->name; |
83
|
5
|
|
100
|
|
|
16
|
my $arr = $caller->$n || []; |
84
|
5
|
|
|
|
|
74
|
my @res; |
85
|
5
|
|
|
|
|
16
|
for (my $i = 0; $i < @$arr; $i++) { |
86
|
6
|
|
|
|
|
23
|
push @res, map { [ |
|
2
|
|
|
|
|
19
|
|
87
|
|
|
|
|
|
|
sprintf('%s__%d__%s', $n, $i + 1, shift @$_), @$_ |
88
|
|
|
|
|
|
|
] } $arr->[$i]->ht_validate; |
89
|
|
|
|
|
|
|
} |
90
|
5
|
|
|
|
|
27
|
return @res; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|