]> iEval git - html-element-library.git/blobdiff - t/dual_iter.t
Refactor tests (first pass)
[html-element-library.git] / t / dual_iter.t
index dfe5b2f54b8dd9264acb29c0bc1a0e9cbb93224c..2c93fd4c754ea5ddaa5d4fa566dc00426670c762 100644 (file)
@@ -1,53 +1,25 @@
-# This might look like shell script, but it's actually -*- perl -*-
-use strict;
-use lib qw(t/ t/m/);
-
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use TestUtils;
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-
-# 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,
-
- );
-
-  my $generated_html = ptree($tree, "$root.gen");
-
-  is ($generated_html, File::Slurp::read_file("$root.exp"), 
-      "HTML 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.024777 seconds and 4 git commands to generate.