X-Git-Url: http://git.shiar.net/gitweb.cgi/perl/html-form-simple.git/blobdiff_plain/80de26e2b6b53f54ffb5232472e56c3225a101e1..bb5bd81e03c47ff9cc779c5109bd6e042219a1f8:/t/html.t?ds=inline
diff --git a/t/html.t b/t/html.t
index e5abb9a..2fea804 100644
--- a/t/html.t
+++ b/t/html.t
@@ -5,7 +5,7 @@ use warnings;
use Test::More;
-plan tests => 51;
+plan tests => 55;
use_ok('HTML::Form::Simple');
@@ -58,6 +58,37 @@ is(
'hidden options'
);
+is_deeply(
+ [ $form->hidden(foo => [1, 0], {class => 'test'}) ],
+ [
+ '',
+ '',
+ ],
+ 'hidden array'
+);
+
+is_deeply(
+ [ $form->hidden({2 => 0, 10 => 1}, {class => 'test'}) ],
+ [
+ '',
+ '',
+ ],
+ 'hidden hash'
+);
+
+{
+ local $, = "\n";
+ is(
+ scalar $form->hidden({2 => [1, 0], 10 => 2}, {class => 'test'}),
+ join("\n",
+ '',
+ '',
+ '',
+ ),
+ 'scalar hiddens'
+ );
+}
+
# submit
is(
@@ -87,43 +118,43 @@ is(
# input
is(
- $form->input,
+ $form->text,
'',
'empty input'
);
is(
- $form->input(undef, undef, undef),
+ $form->text(undef, undef, undef),
'',
'explicit empty input'
);
is(
- $form->input('test'),
+ $form->text('test'),
'',
'input with name'
);
is(
- $form->input(undef, 'test'),
+ $form->text(undef, 'test'),
'',
'input with value'
);
is(
- $form->input(undef, {value => 'test'}),
+ $form->text(undef, {value => 'test'}),
'',
'input with attribute value'
);
is(
- $form->input({name => 'test', value => ''}),
+ $form->text({name => 'test', value => ''}),
'',
'input with only attributes'
);
is(
- $form->input('', '', {
+ $form->text('', '', {
disabled => 0,
something => undef,
class => undef,
@@ -136,31 +167,31 @@ is(
);
is(
- $form->input(undef, undef, {name => '0', value => '0'}),
+ $form->text(undef, undef, {name => '0', value => '0'}),
'',
'input overrides'
);
is(
- $form->input('name', {id => ''}),
+ $form->text('name', {id => ''}),
'',
'input with id override'
);
is(
- $form->input('<">', '<">', {id => '>"<'}),
+ $form->text('<">', '<">', {id => '>"<'}),
'',
'input quoting'
);
is(
- $form->input(undef, {disabled => 'something'}),
+ $form->text(undef, {disabled => 'something'}),
'',
'disabled input'
);
is(
- $form->input({type => 'password'}),
+ $form->text({type => 'password'}),
'',
'password'
);
@@ -168,19 +199,19 @@ is(
# textarea
is(
- $form->input({rows => 0}),
+ $form->text({rows => 0}),
'',
'minimal textarea'
);
is(
- $form->input(foo => 'bar', {cols => 42, rows => 1, disabled => 1}),
+ $form->text(foo => 'bar', {cols => 42, rows => 1, disabled => 1}),
'',
'textarea'
);
is(
- $form->input(undef, qq{&bl'a"\n .}, {cols => undef, rows => '<">'}),
+ $form->text(undef, qq{&bl'a"\n .}, {cols => undef, rows => '<">'}),
qq{},
'textarea quoting'
);
@@ -286,7 +317,7 @@ is(
);
is(
- $form->radio(foo => undef, [2]), #TODO
+ $form->radio(foo => undef, 2),
'',
'labelless radio'
);
@@ -369,6 +400,18 @@ is_deeply(
'multiple checked checkboxes'
);
+{
+ local $, = ' | ';
+ is(
+ scalar $form->check(foo => [1, 0], {value => 0}),
+ join(' | ',
+ '',
+ '',
+ ),
+ 'merged checkboxes'
+ );
+}
+
is_deeply(
[ $form->check(undef, [{value => 4, type => 'radio'}], [1, 0, 0], {value => 3}) ],
[