]> iEval git - html-element-library.git/blame - t/table2.t
Fix tests
[html-element-library.git] / t / table2.t
CommitLineData
67e78ff2 1# This might look like shell script, but it's actually -*- perl -*-
2use strict;
3use lib qw(t/ t/m/);
4
5
6use File::Slurp;
271d5078
TB
7use Test::More;
8use Test::XML;
67e78ff2 9
67e78ff2 10use Data::Dumper;
11use HTML::TreeBuilder;
12use HTML::Element::Library;
d4b9a41a 13use Test::XML;
67e78ff2 14
15use data::table2;
16
17my $root = 't/html/table2';
18my $o = data::table2->new;
19my $d = data::table2->load_data;
20my $tree = HTML::TreeBuilder->new_from_file("$root.html");
21
22#warn 'D:', Dumper $d;
23
24for 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 49is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), 'genhtml');
271d5078
TB
50
51
52done_testing;
This page took 0.026983 seconds and 4 git commands to generate.