diff --git a/t/html/hashmap.exp b/t/html/hashmap.exp
new file mode 100644
index 0000000..22486ba
--- /dev/null
+++ b/t/html/hashmap.exp
@@ -0,0 +1,15 @@
+
+
+ HO HO HA HA HA
+
+
+
+
+
diff --git a/t/html/hashmap.html b/t/html/hashmap.html
new file mode 100644
index 0000000..6d818cd
--- /dev/null
+++ b/t/html/hashmap.html
@@ -0,0 +1,16 @@
+
+
+ HO HO HA HA HA
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/t/html/highlander-15.exp b/t/html/highlander-15.exp
index 48fe062..dbd4acf 100644
--- a/t/html/highlander-15.exp
+++ b/t/html/highlander-15.exp
@@ -1,6 +1,3 @@
-
-
- Sorry,
+ Sorry,
you're not old enough to enter (and too dumb to lie about your age)
-
-
+
diff --git a/t/html/highlander-5.exp b/t/html/highlander-5.exp
index 96df6fc..5baaa1d 100644
--- a/t/html/highlander-5.exp
+++ b/t/html/highlander-5.exp
@@ -1,6 +1,3 @@
-
-
- Hello,
+ Hello,
does your mother know you're using her AOL account?
-
-
+
diff --git a/t/html/highlander-50.exp b/t/html/highlander-50.exp
index 1f03edd..8511ff2 100644
--- a/t/html/highlander-50.exp
+++ b/t/html/highlander-50.exp
@@ -1,5 +1,2 @@
-
-
- Welcome
-
-
+ Welcome
+
diff --git a/t/html/highlander2-15.exp b/t/html/highlander2-15.exp
index 20be935..56bd431 100644
--- a/t/html/highlander2-15.exp
+++ b/t/html/highlander2-15.exp
@@ -1,6 +1,3 @@
-
-
- Sorry,
+ Sorry,
you're only 15 (and too dumb to lie about your
- age)
-
+ age)
diff --git a/t/html/highlander2-27.exp b/t/html/highlander2-27.exp
index dd7b2fa..3671bbe 100644
--- a/t/html/highlander2-27.exp
+++ b/t/html/highlander2-27.exp
@@ -1,6 +1,3 @@
-
-
- Welcome,
+ Welcome,
isn't it good to be 27 years old?
-
-
+
diff --git a/t/html/highlander2-5.exp b/t/html/highlander2-5.exp
index b62e6e0..ecc6e88 100644
--- a/t/html/highlander2-5.exp
+++ b/t/html/highlander2-5.exp
@@ -1,6 +1,3 @@
-
-
- Hello,
+ Hello,
little 5-year old, does your mother know you're
- using her AOL account?
-
+ using her AOL account?
diff --git a/t/html/highlander2-passover.exp b/t/html/highlander2-passover.exp
index 8de5305..8bfaa65 100644
--- a/t/html/highlander2-passover.exp
+++ b/t/html/highlander2-passover.exp
@@ -1,6 +1,3 @@
-
-
- Sorry,
+ Sorry,
you're only AGE (and too dumb to lie about your
- age)
-
+ age)
diff --git a/t/html/iter.exp b/t/html/iter.exp
index 746633e..013b019 100644
--- a/t/html/iter.exp
+++ b/t/html/iter.exp
@@ -1,10 +1,8 @@
-
-
- Here are the things I need from the store:
+
+Here are the things I need from the store:
bread
butter
vodka
-
-
+
diff --git a/t/html/iter.html b/t/html/iter.html
index 289809f..3f609f1 100644
--- a/t/html/iter.html
+++ b/t/html/iter.html
@@ -1,4 +1,6 @@
+
Here are the things I need from the store:
Sample item
-
\ No newline at end of file
+
+
diff --git a/t/html/iter2.exp b/t/html/iter2.exp
index 17148cf..992ffa3 100644
--- a/t/html/iter2.exp
+++ b/t/html/iter2.exp
@@ -1,6 +1,5 @@
-
-
- Here are the type of people you meet at XYZ, inc:
+
+Here are the type of people you meet at XYZ, inc:
@@ -25,3 +26,4 @@ Here are the type of people you meet at XYZ, inc:
+
diff --git a/t/html/same_as.html b/t/html/same_as.html
deleted file mode 100644
index f70d378..0000000
--- a/t/html/same_as.html
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
- HO HO HA HA HA
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/t/html/same_as/same_as.exp b/t/html/same_as/same_as.exp
deleted file mode 100644
index 22486ba..0000000
--- a/t/html/same_as/same_as.exp
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- HO HO HA HA HA
-
-
-
usually can be found as the first child of the parent
-
- gi_tr => ['iterate1', 'iterate2'],
-
- # the model data to be pushed into the table
-
- table_data => $o->load_data,
-
- # the way to take the model data and obtain one row
- # if the table data were a hashref, we would do:
- # my $key = (keys %$data)[0]; my $val = $data->{$key}; delete $data->{$key}
-
- tr_data => sub { my ($self, $data) = @_;
- shift(@{$data}) ;
- },
-
- # the way to take a row of data and fill the
tags
-
- td_data => sub { my ($tr_node, $tr_data) = @_;
- $tr_node->content_handler($_ => $tr_data->{$_})
- for qw(name age weight) }
-
- );
-
- is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"),
- "HTML for non-alternating table");
+my $tree = mktree 't/html/table-alt.html';
+
+$tree->table(
+ gi_table => 'load_data',
+ gi_tr => ['iterate1', 'iterate2'],
+ table_data => $o->load_data,
+ tr_data => sub {
+ my ($self, $data) = @_;
+ shift @{$data};
+ },
+ td_data => sub {
+ my ($tr_node, $tr_data) = @_;
+ $tr_node->content_handler($_ => $tr_data->{$_}) for qw(name age weight)
+ });
+
+isxml $tree, 't/html/table-alt.exp', 'table (alternating)';
diff --git a/t/table.t b/t/table.t
index 2351038..fe9fbf4 100644
--- a/t/table.t
+++ b/t/table.t
@@ -1,54 +1,22 @@
-# 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 HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
+#!/usr/bin/perl
+use t::lib tests => 1;
+use lib 't';
use SimpleClass;
-my $root = 't/html/table';
my $o = SimpleClass->new;
-my $tree = HTML::TreeBuilder->new_from_file("$root.html");
-
-
-$tree->table
- (
- # tell seamstress where to find the table, via the method call
- # ->look_down('id', $gi_table). Seamstress detaches the table from the
- # HTML tree automatically if no table rows can be built
-
- gi_table => 'load_data',
-
- # tell seamstress where to find the tr. This is a bit useless as
- # the
usually can be found as the first child of the parent
-
- gi_tr => 'data_row',
-
- # the model data to be pushed into the table
-
- table_data => $o->load_data,
-
- # the way to take the model data and obtain one row
- # if the table data were a hashref, we would do:
- # my $key = (keys %$data)[0]; my $val = $data->{$key}; delete $data->{$key}
-
- tr_data => sub { my ($self, $data) = @_;
- shift(@{$data}) ;
- },
-
- # the way to take a row of data and fill the
tags
-
- td_data => sub { my ($tr_node, $tr_data) = @_;
- $tr_node->content_handler($_ => $tr_data->{$_})
- for qw(name age weight) }
-
- );
-
- is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"),
- "HTML for non-alternating table");
+my $tree = mktree 't/html/table.html';
+
+$tree->table(
+ gi_table => 'load_data',
+ gi_tr => 'data_row',
+ table_data => $o->load_data,
+ tr_data => sub {
+ my ($self, $data) = @_;
+ shift(@{$data}) ;
+ },
+ td_data => sub {
+ my ($tr_node, $tr_data) = @_;
+ $tr_node->content_handler($_ => $tr_data->{$_}) for qw(name age weight)
+ });
+
+isxml $tree, 't/html/table.exp', 'table';
diff --git a/t/table2-table_ld.t b/t/table2-table_ld.t
index c53735a..1a359da 100644
--- a/t/table2-table_ld.t
+++ b/t/table2-table_ld.t
@@ -1,65 +1,43 @@
-# This might look like shell script, but it's actually -*- perl -*-
+#!/usr/bin/perl
# Test the 3 possible look_down calls to table2()
# a = default
# b = supplied array ref
# c = supplied code ref
-
-use strict;
+use t::lib tests => 3;
use lib qw(t/ t/m/);
-
-
-use File::Slurp;
-use Test::More;
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
use data::table2;
-
my $o = data::table2->new;
# a - default table_ld
-my $root = 't/html/table2';
-my $tree = HTML::TreeBuilder->new_from_file("$root.html");
-
+my $tree = mktree 't/html/table2.html';
my $table = HTML::Element::Library::ref_or_ld(
- $tree,
- ['_tag' => 'table']
- );
+ $tree,
+ ['_tag' => 'table']
+);
-is_xml ($table->as_XML, scalar File::Slurp::read_file("$root-table_ld.exp"), $root);
+isxml $table, 't/html/table2-table_ld.exp', 'table2 look_down default';
# b - arrayref table_ld
-$tree = HTML::TreeBuilder->new_from_file("$root.html");
-
-
$table = HTML::Element::Library::ref_or_ld(
- $tree,
- [frame => 'hsides', rules => 'groups']
+ $tree,
+ [frame => 'hsides', rules => 'groups']
);
-is_xml ($table->as_XML, scalar File::Slurp::read_file("$root-table_ld.exp"), $root);
+isxml $table, 't/html/table2-table_ld.exp', 'table2 look_down arrayref';
# c - coderef table_ld
-$tree = HTML::TreeBuilder->new_from_file("$root.html");
-
-
$table = HTML::Element::Library::ref_or_ld(
- $tree,
- sub {
- my ($t) = @_;
- my $caption = $t->look_down('_tag' => 'caption');
- $caption->parent;
- }
- );
-
-is_xml ($table->as_XML, scalar File::Slurp::read_file("$root-table_ld.exp"), $root);
-
-
-done_testing;
+ $tree,
+ sub {
+ my ($t) = @_;
+ my $caption = $t->look_down('_tag' => 'caption');
+ $caption->parent;
+ }
+);
+
+isxml $table, 't/html/table2-table_ld.exp', 'table2 look_down coderef';
diff --git a/t/table2-tr_ld.t b/t/table2-tr_ld.t
index 6e01c51..c685205 100644
--- a/t/table2-tr_ld.t
+++ b/t/table2-tr_ld.t
@@ -1,82 +1,54 @@
-# This might look like shell script, but it's actually -*- perl -*-
-# Test the 3 possible look_down calls to table2()
-# a = default
-# b = supplied array ref
-# c = supplied code ref
-
-use strict;
-use lib qw(t/ t/m/);
-
-
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Scalar::Listify;
-use Test::XML;
-
-use data::table2;
-
-
-my $o = data::table2->new;
+#!/usr/bin/perl
+use t::lib tests => 3;
# a - default table_ld
-my $root = 't/html/table2';
-my $tree = HTML::TreeBuilder->new_from_file("$root.html");
-
+my $tree = mktree 't/html/table2.html';
my @tr = HTML::Element::Library::ref_or_ld(
- $tree,
- ['_tag' => 'tr']
- );
+ $tree,
+ ['_tag' => 'tr']
+);
-is (scalar @tr, 16, 'default ld_tr');
+is (scalar @tr, 16, 'table2 tr look_down (default)');
# b - arrayref tr_ld
-$root = 't/html/table2-tr_ld-arrayref';
-$tree = HTML::TreeBuilder->new_from_file("$root.html");
-
+$tree = mktree 't/html/table2-tr_ld-arrayref.html';
my $tr = HTML::Element::Library::ref_or_ld(
- $tree,
- [class => 'findMe']
- );
+ $tree,
+ [class => 'findMe']
+);
-is_xml ($tr->as_XML, scalar File::Slurp::read_file("$root.exp"), $root);
+isxml $tr, 't/html/table2-tr_ld-arrayref.exp', 'table2 tr look_down (arrayref)';
# c - coderef tr_ld
# removes windows listings before returning @tr
-$root = 't/html/table2';
-$tree = HTML::TreeBuilder->new_from_file("$root.html");
-
+$tree = mktree 't/html/table2.html';
@tr = HTML::Element::Library::ref_or_ld(
- $tree,
- sub {
- my ($t) = @_;
- my @tr = $t->look_down('_tag' => 'tr');
- my @keep;
- for my $tr (@tr) {
-
- my @td = $tr->look_down ('_tag' => 'td') ;
- my $detached;
- for my $td (@td) {
- if (grep { $_ =~ /Windows/ } $td->content_list) {
- $tr->detach();
- ++$detached;
- last;
+ $tree,
+ sub {
+ my ($t) = @_;
+ my @tr = $t->look_down('_tag' => 'tr');
+ my @keep;
+ for my $tr (@tr) {
+
+ my @td = $tr->look_down ('_tag' => 'td') ;
+ my $detached;
+ for my $td (@td) {
+ if (grep { $_ =~ /Windows/ } $td->content_list) {
+ $tr->detach;
+ ++$detached;
+ last;
+ }
+ }
+ push @keep, $tr unless $detached;
+ }
+ @keep;
}
- }
- push @keep, $tr unless $detached;
- }
- @keep;
- }
- );
-
-#warn $_->as_HTML, $/ for @tr;
+);
-is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root-tr_ld-coderef.exp"), $root);
+isxml $tree, 't/html/table2-tr_ld-coderef.exp', 'table2 tr look_down (coderef)';
diff --git a/t/table2.t b/t/table2.t
index f72096e..3566c63 100644
--- a/t/table2.t
+++ b/t/table2.t
@@ -1,52 +1,34 @@
-# 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;
-use Test::XML;
-
-use Data::Dumper;
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
+#!/usr/bin/perl
+use t::lib tests => 1;
+use lib 't';
use data::table2;
my $root = 't/html/table2';
-my $o = data::table2->new;
my $d = data::table2->load_data;
-my $tree = HTML::TreeBuilder->new_from_file("$root.html");
-
-#warn 'D:', Dumper $d;
+my $tree = mktree 't/html/table2.html';
for my $dataset (keys %$d) {
- my %tbody = ('4dig' => 0, '3dig' => 1);
- $tree->table2 (
-# debug => 1,
- table_data => $d->{$dataset},
- tr_base_id => $dataset,
- tr_ld => sub {
- my $t = shift;
- my $tbody = ($t->look_down('_tag' => 'tbody'))[$tbody{$dataset}];
- my @tbody_child = $tbody->content_list;
- $tbody_child[$_]->detach for (1 .. $#tbody_child) ;
- $tbody->content_list;
- },
- td_proc => sub {
- my ($tr, $data) = @_;
- my @td = $tr->look_down('_tag' => 'td');
- for my $i (0..$#td) {
-# warn $i;
- $td[$i]->splice_content(0, 1, $data->[$i]);
- }
- }
- );
+ my %tbody = ('4dig' => 0, '3dig' => 1);
+ $tree->table2 (
+ debug => $ENV{TEST_VERBOSE},
+ table_data => $d->{$dataset},
+ tr_base_id => $dataset,
+ tr_ld => sub {
+ my $t = shift;
+ my $tbody = ($t->look_down('_tag' => 'tbody'))[$tbody{$dataset}];
+ my @tbody_child = $tbody->content_list;
+ $tbody_child[$_]->detach for (1 .. $#tbody_child) ;
+ $tbody->content_list;
+ },
+ td_proc => sub {
+ my ($tr, $data) = @_;
+ my @td = $tr->look_down('_tag' => 'td');
+ for my $i (0..$#td) {
+ # warn $i;
+ $td[$i]->splice_content(0, 1, $data->[$i]);
+ }
+ }
+ );
}
-
-is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), 'genhtml');
-
-
-done_testing;
+isxml $tree, 't/html/table2.exp', 'table2';
diff --git a/t/unroll_select.t b/t/unroll_select.t
index a21c712..d29870a 100644
--- a/t/unroll_select.t
+++ b/t/unroll_select.t
@@ -1,31 +1,17 @@
-# 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 HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
+#!/usr/bin/perl
+use t::lib tests => 1;
+use lib 't';
use SelectData;
-my $root = 't/html/unroll_select';
-
-my $tree = HTML::TreeBuilder->new_from_file("$root.html");
-
+my $tree = mktree 't/html/unroll_select.html';
-$tree->unroll_select
- (
- select_label => 'clan_list',
- option_value => sub { my $row = shift; $row->{clan_id} },
- option_content => sub { my $row = shift; $row->{clan_name} },
- option_selected => sub { my $row = shift; $row->{selected} },
- data => SelectData->load_data,
- data_iter => sub { my $data = shift; shift @$data }
- );
+$tree->unroll_select(
+ select_label => 'clan_list',
+ option_value => sub { my $row = shift; $row->{clan_id} },
+ option_content => sub { my $row = shift; $row->{clan_name} },
+ option_selected => sub { my $row = shift; $row->{selected} },
+ data => SelectData->load_data,
+ data_iter => sub { my $data = shift; shift @$data });
-is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"),
- "HTML for non-alternating table");
+isxml ($tree, 't/html/unroll_select.exp', 'unroll_select');
diff --git a/t/wrap_content.t b/t/wrap_content.t
index 976420e..7c766bc 100644
--- a/t/wrap_content.t
+++ b/t/wrap_content.t
@@ -1,38 +1,18 @@
-use strict;
-use Test::More qw(no_plan);
+#!/usr/bin/perl
+use t::lib tests => 1;
-use HTML::Element::Library;
-
-
-my $t1;
-my $lol;
-$t1 = HTML::Element->new_from_lol
- (
- $lol =
- ['html',
- ['head',
- [ 'title', 'I like stuff!' ],
- ],
- ['body',
- {
- 'lang', 'en-JP'},
- 'stuff',
- ['p',
- ['span', {id => 'wrapme'},
- 'um, p < 4!',
- ],
- {'class' => 'par123'}],
- ['div', {foo => 'bar'}, '123'], # at 0.1.2
- ['div', {jack => 'olantern'}, '456'], # at 0.1.2
- ]
- ]
- )
- ;
+my $t1 = HTML::Element->new_from_lol(
+ ['html',
+ ['head',
+ [ 'title', 'I like stuff!' ]],
+ ['body', {id => 'corpus'}, {'lang', 'en-JP'},
+ 'stuff',
+ ['p', ['span', {id => 'wrapme'}, 'um, p < 4!'], {'class' => 'par123'}],
+ ['div', {foo => 'bar'}, '123'], # at 0.1.2
+ ['div', {jack => 'olantern'}, '456']]]); # at 0.1.2
my $bold = HTML::Element->new('b', id => 'wrapper');
-my $W = $t1->look_down('id' => 'wrapme');
-$W->wrap_content($bold);
-is( $W->as_HTML, 'um, p < 4!', "wrapped text");
-
-
+my $w = $t1->look_down('id' => 'wrapme');
+$w->wrap_content($bold);
+isxml $w, \'um, p < 4!', 'wrap_content';