]> iEval git - html-element-library.git/blame - t/iter2.t
fixed test suite
[html-element-library.git] / t / iter2.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;
7use Test::More qw(no_plan);
8
9use TestUtils;
10use HTML::TreeBuilder;
11use HTML::Element::Library;
12
13my $root = 't/html/iter2';
14
15my $tree = HTML::TreeBuilder->new_from_file("$root.html");
16
17my @items = (
18 [ Programmer => 'one who likes Perl and Seamstress', ],
19 [ DBA => 'one who does business as', ],
20 [ Admin => 'one who plays Tetris all day' ]
21 );
22
23$tree->iter2(
24 # default wrapper_ld ok
25 wrapper_data => \@items,
26 wrapper_proc => sub {
27 my ($container) = @_;
28
29 # only keep the last 2 dts and dds
30 my @content_list = $container->content_list;
31 $container->splice_content(0, @content_list - 2);
32 },
33 # default item_ld is k00l
34 # default item_data is phrEsh
35 # default item_proc will do w0rk
36 splice => sub {
37 my ($container, @item_elems) = @_;
38 $container->unshift_content(@item_elems);
39 },
40
41 debug => 1,
42 );
43
44
45 my $generated_html = ptree($tree, "$root.gen");
46
47 is ($generated_html, File::Slurp::read_file("$root.exp"),
48 "HTML for generated li");
This page took 0.020091 seconds and 4 git commands to generate.