]> iEval git - html-element-library.git/blob - t/table2.t
hash_map method about to be public for real
[html-element-library.git] / t / table2.t
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;
7 use Test::More qw(no_plan);
8
9 use TestUtils;
10
11 use Data::Dumper;
12 use HTML::TreeBuilder;
13 use HTML::Element::Library;
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
49 my $generated_html = ptree($tree, "$root.gen");
50
51 is ($generated_html, File::Slurp::read_file("$root.exp"),
52 "HTML for non-alternating table");
This page took 0.050668 seconds and 4 git commands to generate.