]> iEval git - html-element-library.git/blobdiff - t/dual_iter.t
Refactor tests (first pass)
[html-element-library.git] / t / dual_iter.t
index dbcfb28adf0f5159c44b17c1b98f1240634b979e..2c93fd4c754ea5ddaa5d4fa566dc00426670c762 100644 (file)
@@ -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';
This page took 0.024399 seconds and 4 git commands to generate.