do not modify parameters in radio/check
[perl/html-form-simple.git] / t / html.t
index 2fea804b2353d89b0eeb9d07dc09b83047150aef..b4420e1829588f788f4b6d6e1cfa4ccdf552258e 100644 (file)
--- a/t/html.t
+++ b/t/html.t
@@ -5,7 +5,7 @@ use warnings;
 
 use Test::More;
 
-plan tests => 55;
+plan tests => 59;
 
 use_ok('HTML::Form::Simple');
 
@@ -356,6 +356,39 @@ is_deeply(
        'multiple radios with custom values'
 );
 
+{
+       # make sure arguments aren't modified
+       my @args = (foo => [0, 1], [0, {value => 1}], {name => 0, value => 1});
+       my @orgs = (foo => [0, 1], [0, {value => 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>',
+                       '<label><input checked id="foo_2" name="foo" type="checkbox" value="2"> 1</label>',
+               ],
+               '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(