]>
Commit | Line | Data |
---|---|---|
67e78ff2 | 1 | # This might look like shell script, but it's actually -*- perl -*- |
2 | use strict; | |
3 | use lib qw(t/ t/m/); | |
4 | ||
5 | ||
6 | use File::Slurp; | |
271d5078 TB |
7 | use Test::More; |
8 | use Test::XML; | |
67e78ff2 | 9 | |
67e78ff2 | 10 | use Data::Dumper; |
11 | use HTML::TreeBuilder; | |
12 | use HTML::Element::Library; | |
d4b9a41a | 13 | use Test::XML; |
67e78ff2 | 14 | |
15 | use data::table2; | |
16 | ||
17 | my $root = 't/html/table2'; | |
18 | my $o = data::table2->new; | |
19 | my $d = data::table2->load_data; | |
20 | my $tree = HTML::TreeBuilder->new_from_file("$root.html"); | |
21 | ||
22 | #warn 'D:', Dumper $d; | |
23 | ||
24 | for my $dataset (keys %$d) { | |
25 | my %tbody = ('4dig' => 0, '3dig' => 1); | |
26 | $tree->table2 ( | |
27 | # debug => 1, | |
28 | table_data => $d->{$dataset}, | |
29 | tr_base_id => $dataset, | |
30 | tr_ld => sub { | |
31 | my $t = shift; | |
32 | my $tbody = ($t->look_down('_tag' => 'tbody'))[$tbody{$dataset}]; | |
33 | my @tbody_child = $tbody->content_list; | |
34 | $tbody_child[$_]->detach for (1 .. $#tbody_child) ; | |
35 | $tbody->content_list; | |
36 | }, | |
37 | td_proc => sub { | |
38 | my ($tr, $data) = @_; | |
39 | my @td = $tr->look_down('_tag' => 'td'); | |
40 | for my $i (0..$#td) { | |
41 | # warn $i; | |
42 | $td[$i]->splice_content(0, 1, $data->[$i]); | |
43 | } | |
44 | } | |
45 | ); | |
46 | } | |
47 | ||
48 | ||
d4b9a41a | 49 | is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), 'genhtml'); |
271d5078 TB |
50 | |
51 | ||
52 | done_testing; |