]> iEval git - html-element-library.git/blame - t/dual_iter.t
Fix tests
[html-element-library.git] / t / dual_iter.t
CommitLineData
67e78ff2 1# This might look like shell script, but it's actually -*- perl -*-
2use strict;
67e78ff2 3
4use File::Slurp;
5use Test::More qw(no_plan);
6
67e78ff2 7use HTML::TreeBuilder;
8use HTML::Element::Library;
d4b9a41a 9use Test::XML;
67e78ff2 10
11# this is a simpler call to iter2()
12
13my $root = 't/html/dual_iter';
14
15my $tree = HTML::TreeBuilder->new_from_file("$root.html");
16
17my $dl = $tree->look_down(id => 'service_plan');
18
19
20my @items = (
21 ['the pros' => 'never have to worry about service again'],
22 ['the cons' => 'upfront extra charge on purchase'],
23 ['our choice' => 'go with the extended service plan']
24 );
25
26
27$tree->iter2(
28
29 wrapper_data => \@items,
30
31 wrapper_proc => sub {
32 my ($container) = @_;
33
34 # only keep the last 2 dts and dds
35 my @content_list = $container->content_list;
36 $container->splice_content(0, @content_list - 2);
37 },
38
39
40 splice => sub {
41 my ($container, @item_elems) = @_;
42 $container->unshift_content(@item_elems);
43 },
44
45 debug => 1,
46
47 );
48
67e78ff2 49
d4b9a41a
MG
50 is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"),
51 "XML for generated li");
This page took 0.030296 seconds and 4 git commands to generate.