# -*- Mode: Perl; -*-
use strict;
$^W = 1;
print "1..5\n";
use CGI::Ex;
use CGI;
print "ok 1\n";
my $hidden_form_in = qq{
};
my $q = new CGI( { foo1 => '0',
foo2 => ['bar1', 'bar2',],
foo3 => '' }
);
my $fif = new CGI::Ex;
my $output = $fif->fill(scalarref => \$hidden_form_in,
fobject => $q);
my $is_selected = join(" ",map { m/selected/ ? "yes" : "no" } grep /option/, split ("\n",$output));
if ($is_selected eq "yes no no yes yes no no no no no yes no"){
print "ok 2\n";
} else {
print "Got unexpected is_seleced for select menus:\n$is_selected\n$output\n";
print "not ok 2\n";
}
$hidden_form_in = qq{
};
$q = new CGI( { foo1 => 'bar1',
foo2 => ['bar1', 'bar2',],
foo3 => '' }
);
$fif = new CGI::Ex;
$output = $fif->fill(scalarref => \$hidden_form_in,
fobject => $q);
$is_selected = join(" ",map { m/selected/ ? "yes" : "no" } grep /option/, split ("\n",$output));
if ($is_selected eq "yes no no yes yes no no no no no yes no"){
print "ok 3\n";
} else {
print "Got unexpected is_seleced for select menus:\n$is_selected\n$output\n";
print "not ok 3\n";
}
# test empty option tag
$hidden_form_in = qq{};
$fif = new CGI::Ex;
$output = $fif->fill(scalarref => \$hidden_form_in,
fobject => $q);
if ($output eq qq{}){
print "ok 4\n";
} else {
print "Got unexpected output for empty option:\n$output\n";
print "not ok 4\n";
}
$hidden_form_in = qq{};
$fif = new CGI::Ex;
$output = $fif->fill(scalarref => \$hidden_form_in,
fobject => $q);
if ($output =~ m!^$!){
print "ok 5\n";
} else {
print "Got unexpected output for empty option:\n$output\n";
print "not ok 5\n";
}