]> Dogcows Code - chaz/p5-CGI-Ex/blobdiff - t/2_fill_12_mult.t
CGI::Ex 2.00
[chaz/p5-CGI-Ex] / t / 2_fill_12_mult.t
index 91755f5665de96ee81e45a94f5226ff432b7c21a..620b1b76215aa0013ef417306b3fe2ecaabb3943 100644 (file)
@@ -1,37 +1,37 @@
 # -*- Mode: Perl; -*-
 
-use strict;
+=head1 NAME
 
-$^W = 1;
+2_fill_12_mult.t - Test CGI::Ex::Fill's ability to fill multiple instances of the same field name
 
-print "1..3\n";
+=cut
 
-use CGI::Ex;
+use strict;
+use Test::More tests => 4;
 
-print "ok 1\n";
+use_ok('CGI::Ex::Fill');
 
 my $hidden_form_in = qq{<INPUT TYPE="TEXT" NAME="foo1" value="cat1">
 <input type="text" name="foo1" value="cat2"/>};
 
 my %fdat = (foo1 => ['bar1','bar2']);
 
-my $fif = new CGI::Ex;
-my $output = $fif->fill(scalarref => \$hidden_form_in,
-                       fdat => \%fdat);
-if ($output =~ m/^<input( (type="TEXT"|name="foo1"|value="bar1")){3}>\s*<input( (type="text"|name="foo1"|value="bar2")){3}\s*\/>$/i){
-       print "ok 2\n";
-} else {
-       print "Got unexpected out for $hidden_form_in:\n$output\n";
-       print "not ok 2\n";
-}
+my $output = CGI::Ex::Fill::form_fill($hidden_form_in,
+                                      \%fdat);
+ok($output =~ m/^<input( (type="TEXT"|name="foo1"|value="bar1")){3}>\s*<input( (type="text"|name="foo1"|value="bar2")){3}\s*\/>$/i,
+   "Should match ($output)");
+
 
 %fdat = (foo1 => ['bar1']);
 
-$output = $fif->fill(scalarref => \$hidden_form_in,
-                       fdat => \%fdat);
-if ($output =~ m/^<input( (type="TEXT"|name="foo1"|value="bar1")){3}>\s*<input( (type="text"|name="foo1"|value="")){3}\s*\/>$/i){
-       print "ok 3\n";
-} else {
-       print "Got unexpected out for $hidden_form_in:\n$output\n";
-       print "not ok 3\n";
-}
+$output = CGI::Ex::Fill::form_fill($hidden_form_in,
+                                   \%fdat);
+ok($output =~ m/^<input( (type="TEXT"|name="foo1"|value="bar1")){3}>\s*<input( (type="text"|name="foo1"|value="")){3}\s*\/>$/i,
+   "Should match ($output)");
+
+%fdat = (foo1 => 'bar1');
+
+$output = CGI::Ex::Fill::form_fill($hidden_form_in,
+                                   \%fdat);
+ok($output =~ m/^<input( (type="TEXT"|name="foo1"|value="bar1")){3}>\s*<input( (type="text"|name="foo1"|value="bar1")){3}\s*\/>$/i,
+   "Should match ($output)");
This page took 0.020496 seconds and 4 git commands to generate.