+is_deeply(
+ [ $form->select(foo => [1, 2], 3) ],
+ [
+ '<select id="foo" name="foo">',
+ '<option value="1">', '<option value="2">',
+ '</select>'
+ ],
+ 'select invalid default'
+);
+
+is_deeply(
+ [ $form->select(undef, [1, 2], 2) ],
+ [
+ '<select>',
+ '<option value="1">', '<option selected value="2">',
+ '</select>'
+ ],
+ 'select default'
+);
+
+is_deeply(
+ [
+ $form->select(foo => [
+ '<">', {value => 2, disabled => 1, selected => 0, class => 1}, {selected => 1}
+ ], '2', {id => '', class => 'a <b', value => 1})
+ ],
+ [
+ '<select class="a <b" name="foo">',
+ '<option value="<">">',
+ '<option selected disabled class="1" value="2">',
+ '<option selected>',
+ '</select>'
+ ],
+ 'complex select'
+);
+
+is(
+ scalar $form->select(foo => [1, 2]),
+ '<select id="foo" name="foo"><option value="1"><option value="2"></select>',
+ 'select scalar'
+);
+
+# radio
+
+is_deeply(
+ [ $form->select(foo => [1], {type => 'radio'}) ],
+ [ '<input id="foo_1" name="foo" type="radio" value="1">' ],
+ 'input select'
+);
+
+is_deeply(
+ [
+ $form->select(foo => [
+ 1, {value => 2, name => '', label => ''}, {value => 3, id => '', type => ''}
+ ], {type => 'checkbox', label => {3 => 'test', 2 => 'ignore'}, value => '1'})
+ ],
+ [
+ '<input checked id="foo_1" name="foo" type="checkbox" value="1">',
+ '<input id="foo_2" name="" type="checkbox" value="2">',
+ '<label><input name="foo" value="3"> test</label>',
+ ],
+ 'input selects'
+);
+
+is(
+ $form->radio(foo => 'test'),
+ '<input id="foo_test" name="foo" type="radio" value="test">',
+ 'radio method'
+);
+
+is(
+ $form->radio(foo => undef, 'test'),
+ '<label><input id="foo_1" name="foo" type="radio" value="1"> test</label>',
+ 'labeled radio'
+);
+
+is(
+ $form->radio(undef, {checked => 1}),
+ '<input checked type="radio">',
+ 'simple radio button'
+);
+
+is_deeply(
+ [ $form->radio(undef, ['', '<">']) ],
+ [
+ '<input type="radio" value="">',
+ '<input type="radio" value="<">">',
+ ],
+ 'multiple radios'
+);
+
+is_deeply(
+ [ $form->radio(undef, undef, ['', '<">']) ],
+ [
+ '<input type="radio" value="1">',
+ '<label><input type="radio" value="2"> <"></label>',
+ ],
+ 'multiple radio labels'
+);
+
+is_deeply(
+ [ $form->radio(foo => ['foo', ''], 'test', {value => '', id => ''}) ],
+ [
+ '<label><input name="foo" type="radio" value="foo"> test</label>',
+ '<label><input checked name="foo" type="radio" value=""> test</label>',
+ ],
+ 'multiple radios with custom value'
+);
+
+is_deeply(
+ [ $form->radio(foo => [0, 1, ''], ['', 0]) ],
+ [
+ '<input id="foo_0" name="foo" type="radio" value="0">',
+ '<label><input id="foo_1" name="foo" type="radio" value="1"> 0</label>',
+ '<input id="foo_" name="foo" type="radio" value="">',
+ ],
+ 'multiple radios with custom values'
+);
+
+{
+ # make sure arguments aren't modified
+ my @args = (foo => [0, {value => 1}], [0, 1], {name => 0, value => 1});
+ my @orgs = (foo => [0, {value => 1}], [0, 1], {name => 0, value => 1});
+ my @output = (
+ '<label><input id="foo_0" name="foo" type="radio" value="0"> 0</label>',
+ '<label><input checked id="foo_1" name="foo" type="radio" value="1"> 1</label>',
+ );
+
+ is_deeply(
+ [ $form->radio(@args) ],
+ \@output,
+ 'options var to radio'
+ );
+
+ is_deeply(
+ [ $form->check(@args) ],
+ [
+ '<label><input checked id="foo_1" name="foo" type="checkbox" value="1"> 0</label>',
+ '<input checked id="foo_1" name="foo" type="checkbox" value="1">',
+ ],
+ 'options var to check'
+ );
+
+ is(
+ scalar $form->radio(@args),
+ join('', @output),
+ 'options var again to radio'
+ );
+
+ is_deeply(\@args, \@orgs, 'options var unmodified');
+}
+
+# check
+
+is(
+ $form->check('foo'),
+ '<input id="foo_1" name="foo" type="checkbox" value="1">',
+ 'check method'
+);
+
+is(
+ $form->check(foo => '<">'),
+ '<label><input id="foo_1" name="foo" type="checkbox" value="1"> <"></label>',
+ 'labeled checkbox'
+);
+
+is(
+ $form->check(foo => {label => 'test', value => undef}, {disabled => 1}),
+ '<label><input disabled id="foo" name="foo" type="checkbox"> test</label>',
+ 'check parameters'
+);
+
+is_deeply(
+ [ $form->check(undef, '', 1) ],
+ [ '<input checked type="checkbox" value="1">' ],
+ 'anonymous checkbox'
+);
+
+is_deeply(
+ [ $form->check(undef, ['', '<">']) ],
+ [
+ '<input type="checkbox" value="1">',
+ '<label><input type="checkbox" value="2"> <"></label>',
+ ],
+ 'multiple checkboxes'
+);
+
+is_deeply(
+ [ $form->check(undef, [{}, undef], 1) ],
+ [
+ '<input checked type="checkbox" value="1">',
+ '<input checked type="checkbox" value="2">',
+ ],
+ 'multiple checked checkboxes'
+);
+
+{
+ local $, = ' | ';
+ is(
+ scalar $form->check(foo => [1, 0], {value => 0}),
+ join(' | ',
+ '<label><input id="foo_1" name="foo" type="checkbox" value="1"> 1</label>',
+ '<label><input id="foo_2" name="foo" type="checkbox" value="2"> 0</label>',
+ ),
+ 'merged checkboxes'
+ );
+}
+
+is_deeply(
+ [ $form->check(undef, [{value => 4, type => 'radio'}], [1, 0, 0], {value => 3}) ],
+ [
+ '<input checked type="radio" value="4">',
+ '<input type="checkbox" value="2">',
+ '<input checked type="checkbox" value="3">',
+ ],
+ 'various checkboxes'
+);
+
+# defaults
+
+my $defform = HTML::Form::Simple->new({foo => '<">', '' => 'empty', 0 => 0});
+ok($defform, 'form with defaults');
+
+is(
+ $defform->hidden(''),
+ '<input name="" type="hidden" value="empty">',
+ 'hidden with default'
+);
+
+is(
+ $defform->hidden(undef),
+ '<input type="hidden">',
+ 'nameless hidden'
+);
+
+is(
+ $defform->text('foo'),
+ '<input id="foo" name="foo" type="text" value="<">">',
+ 'input with default'
+);
+
+is(
+ $defform->text('foo', {value => 'custom'}),
+ '<input id="foo" name="foo" type="text" value="custom">',
+ 'input with value and default'
+);
+
+is_deeply(
+ [ $defform->radio(0 => [1, 0]) ],
+ [
+ '<input id="0_1" name="0" type="radio" value="1">',
+ '<input checked id="0_0" name="0" type="radio" value="0">',
+ ],
+ 'select with default'
+);
+