]> Dogcows Code - chaz/p5-CGI-Ex/blobdiff - t/2_fill_18_coderef.t
CGI::Ex 2.00
[chaz/p5-CGI-Ex] / t / 2_fill_18_coderef.t
index f09b3b05432eb44d6b423798fed1e87b0a7f7e67..46556fe68da1949de4992dda2b7e46b671a5ebc5 100644 (file)
@@ -1,14 +1,15 @@
 # -*- Mode: Perl; -*-
 
-use strict;
+=head1 NAME
 
-$^W = 1;
+2_fill_18_coderef.t - Test CGI::Ex::Fill's ability to use coderef callbacks
 
-print "1..4\n";
+=cut
 
-use CGI::Ex;
+use strict;
+use Test::More tests => 4;
 
-print "ok 1\n";
+use_ok('CGI::Ex::Fill');
 
 my $ok2 = 0;
 my $ok3 = 0;
@@ -24,16 +25,12 @@ my $cdat = sub {
   return ($key eq 'foo2') ? 'bar2' : '';
 };
 
-my $fif = new CGI::Ex;
-my $output = $fif->fill(scalarref => \$hidden_form_in,
-                       fdat => [\%fdat, $cdat]);
+my $output = CGI::Ex::Fill::form_fill($hidden_form_in,
+                                      [\%fdat, $cdat]);
+
+ok($ok2);
+ok($ok3);
 
-print "" . ($ok2 ? "" : "not ") . "ok 2\n";
-print "" . ($ok3 ? "" : "not ") . "ok 3\n";
+ok($output =~ m/^<input( (type="hidden"|name="foo1"|value="bar1")){3}>\s*<input( (type="hidden"|name="foo2"|value="bar2")){3}>$/,
+   "Should match ($output)");
 
-if ($output =~ m/^<input( (type="hidden"|name="foo1"|value="bar1")){3}>\s*<input( (type="hidden"|name="foo2"|value="bar2")){3}>$/){
-  print "ok 4\n";
-} else {
-  print "Got unexpected out for hidden form:\n$output\n";
-  print "not ok 4\n";
-}
This page took 0.018287 seconds and 4 git commands to generate.