# -*- Mode: Perl; -*- =head1 NAME 2_fill_04_select.t - Test CGI::Ex::Fill's ability to fill select fields =cut use strict; use Test::More tests => 5; use_ok('CGI::Ex::Fill'); my $hidden_form_in = qq{ }; my $q = { foo1 => '0', foo2 => ['bar1', 'bar2',], foo3 => '', }; my $output = CGI::Ex::Fill::form_fill($hidden_form_in, $q); my $is_selected = join(" ",map { m/selected/ ? "yes" : "no" } grep /option/, split ("\n",$output)); ok($is_selected eq "yes no no yes yes no no no no no yes no", "Selected should match ($is_selected)"); $hidden_form_in = qq{ }; $q = { foo1 => 'bar1', foo2 => ['bar1', 'bar2',], foo3 => '', }; $output = CGI::Ex::Fill::form_fill($hidden_form_in, $q); $is_selected = join(" ",map { m/selected/ ? "yes" : "no" } grep /option/, split ("\n",$output)); ok($is_selected eq "yes no no yes yes no no no no no yes no", "Selected should match ($is_selected)"); # test empty option tag $hidden_form_in = qq{}; $output = CGI::Ex::Fill::form_fill($hidden_form_in, $q); ok($output eq qq{}, "Should match ($output)"); $hidden_form_in = qq{}; $output = CGI::Ex::Fill::form_fill($hidden_form_in, $q); ok($output =~ m!^$!, "Should match ($output)");