]> iEval git - html-element-library.git/blobdiff - t/highlander2.t
Refactor tests (first pass)
[html-element-library.git] / t / highlander2.t
index c145b6859b8601f0153999a5ddd475d8890a4d2e..dd8252dd43c2f3a06bbe09918c99db2d8dbf3d22 100644 (file)
@@ -1,48 +1,34 @@
-# 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);
This page took 0.026175 seconds and 4 git commands to generate.