X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=t%2Fdual_iter.t;fp=t%2Fdual_iter.t;h=2c93fd4c754ea5ddaa5d4fa566dc00426670c762;hb=aa0161264c67d7802e79492b05aff88533d79d20;hp=dbcfb28adf0f5159c44b17c1b98f1240634b979e;hpb=e87db89a1b545ced3beb0bcd80dda173ec7c1084;p=html-element-library.git diff --git a/t/dual_iter.t b/t/dual_iter.t index dbcfb28..2c93fd4 100644 --- a/t/dual_iter.t +++ b/t/dual_iter.t @@ -1,51 +1,25 @@ -# This might look like shell script, but it's actually -*- perl -*- -use strict; - -use File::Slurp; -use Test::More qw(no_plan); - -use HTML::TreeBuilder; -use HTML::Element::Library; -use Test::XML; - -# this is a simpler call to iter2() - -my $root = 't/html/dual_iter'; - -my $tree = HTML::TreeBuilder->new_from_file("$root.html"); - -my $dl = $tree->look_down(id => 'service_plan'); - - -my @items = ( - ['the pros' => 'never have to worry about service again'], - ['the cons' => 'upfront extra charge on purchase'], - ['our choice' => 'go with the extended service plan'] - ); +#!/usr/bin/perl +use t::lib tests => 1; +my $tree = mktree 't/html/dual_iter.html'; $tree->iter2( - - wrapper_data => \@items, - - wrapper_proc => sub { - my ($container) = @_; - - # only keep the last 2 dts and dds - my @content_list = $container->content_list; - $container->splice_content(0, @content_list - 2); - }, - - - splice => sub { - my ($container, @item_elems) = @_; - $container->unshift_content(@item_elems); - }, - - debug => 1, - - ); - - - is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), - "XML for generated li"); + wrapper_data => [ + ['the pros' => 'never have to worry about service again'], + ['the cons' => 'upfront extra charge on purchase'], + ['our choice' => 'go with the extended service plan'] + ], + wrapper_proc => sub { + my ($container) = @_; + # only keep the last 2 dts and dds + my @content_list = $container->content_list; + $container->splice_content(0, @content_list - 2); + }, + splice => sub { + my ($container, @item_elems) = @_; + $container->unshift_content(@item_elems); + }, + debug => $ENV{TEST_VERBOSE}, +); + +isxml $tree, 't/html/dual_iter.exp', 'dual_iter';