-# This might look like shell script, but it's actually -*- perl -*-
-use strict;
+#!/usr/bin/perl
+use t::lib tests => 3;
-use File::Slurp;
-use Test::More qw(no_plan);
-
-use HTML::TreeBuilder;
-use HTML::Element::Library;
-use Test::XML;
-
-sub replace_age {
- my $branch = shift;
- my $age = shift;
- $branch->look_down(id => 'age')->replace_content($age);
+sub replace_age {
+ my ($branch, $age) = @_;
+ $branch->look_down(id => 'age')->replace_content($age);
}
-
-sub tage {
- my $age = shift;
- my $tree = HTML::TreeBuilder->new_from_file('t/html/highlander2.html');
- my $if_then = $tree->look_down(id => 'age_dialog');
-
- $if_then->highlander2(
- cond => [
- under10 => [
- sub { $_[0] < 10} ,
- \&replace_age
- ],
- under18 => [
- sub { $_[0] < 18} ,
- \&replace_age
- ],
- welcome => [
- sub { 1 },
- \&replace_age
- ]
- ],
- cond_arg => [ $age ]
- );
-
- my $root = "t/html/highlander2-$age";
-
- local $_; # XML::Parser does not like read-only $_ (RT #101129)
- is_xml ($tree->as_XML, scalar File::Slurp::read_file("$root.exp"), "HTML for $age");
+sub test {
+ my $age = shift;
+ my $tree = mktree 't/html/highlander2.html';
+ my $if_then = $tree->look_down(id => 'age_dialog')->highlander2(
+ cond => [
+ under10 => [
+ sub { $_[0] < 10 },
+ \&replace_age
+ ],
+ under18 => [
+ sub { $_[0] < 18 },
+ \&replace_age
+ ],
+ welcome => [
+ sub { 1 },
+ \&replace_age
+ ]
+ ],
+ cond_arg => [ $age ]
+ );
+
+ local $_; # XML::Parser does not like read-only $_ (RT #101129)
+ isxml ($tree, "t/html/highlander2-$age.exp", "highlander2 for age $age");
}
-
-tage($_) for qw(5 15 27);
+test $_ for qw(5 15 27);