#!perl use strict; use warnings; use Test::More tests => 15; BEGIN{ use_ok('HTML::FillInForm::Lite') } my %q = ( foo => 'bar', ); my $o = HTML::FillInForm::Lite->new(); my $x = qr{}xmsi; my $output; like $o->fill(\ qq{}, \%q), $x, "select an option (no white-space)"; like $o->fill(\ qq{}, \%q), $x, "select an option (single-quoted name)"; like $o->fill(\ qq{}, \%q), $x, "select an option (unquoted name)"; like $o->fill(\ qq{}, \%q), $x, "select an option (including many white spaces)"; is $o->fill(\ qq{}, {foo => undef}), qq{}, "nothing with undef data"; is $o->fill(\ qq{}, \%q), qq{}, "select an option with 'value=' attribute"; is $o->fill(\ qq{}, \%q), qq{}, "chenge the selected"; like $o->fill(\ qq{}, \%q), $x, "select an option (UPPER CASE)"; # select-one / select-multi $output = $o->fill(\ qq{}, { foo => [qw(bar baz)] }); my(@options) = grep{ /option/ } split /\n/, $output; like $options[0], qr/bar/; like $options[0], qr/selected/, "bar is selected"; like $options[1], qr/baz/; like $options[1], qr/selected/, "baz is selected"; #re-fill my $s = q{}; $output = $o->fill(\$s, { foo => 'bar' }); is $o->fill(\$output, { foo => 'bar' }), $output, "re-fill with the same data"; is $o->fill(\$output, { foo => 'baz' }), $s, "re-fill to the original";