X-Git-Url: http://git.shiar.nl/perl/html-form-simple.git/blobdiff_plain/906dde920f0d0f551dda592916347b2555b4b378..47c6a0e47426e447523d4697b2fb596366f7f9d4:/t/html.t diff --git a/t/html.t b/t/html.t index 757b248..08f0e6b 100644 --- a/t/html.t +++ b/t/html.t @@ -5,13 +5,39 @@ use warnings; use Test::More; -plan tests => 66; +plan tests => 80; use_ok('HTML::Form::Simple'); my $form = HTML::Form::Simple->new; ok($form, 'new form'); +# basics + +is( + $form->quote('<"test">'), + '<"test">', + 'quote' +); + +is( + $form->quote(\'<"test">'), + '<"test">', + 'quote unquoted' +); + +is( + $form->tag('foo'), + '', + 'tag' +); + +is( + $form->tag('a "' => {'b"' => 'c"'}), + '', + 'tag attributes' +); + # form is( @@ -346,6 +372,15 @@ is_deeply( 'multiple radio labels' ); +is_deeply( + [ $form->radio(undef, [0, 1], undef, 0) ], + [ + '', + '', + ], + 'radio default' +); + is_deeply( [ $form->radio(foo => ['foo', ''], 'test', {value => '', id => ''}) ], [ @@ -402,13 +437,13 @@ is_deeply( is( $form->check('foo'), - '', + '', 'check method' ); is( $form->check(foo => '<">'), - '', + '', 'labeled checkbox' ); @@ -424,13 +459,57 @@ is_deeply( 'anonymous checkbox' ); +is( + $form->check(foo => [undef]), + '', + 'multipart check' +); + +is_deeply( + [ $form->check(foo => [{value => undef}, undef]) ], + [ + '', + '', + ], + 'multiple checkboxes' +); + +is( + $form->check(foo => [undef], {id => ''}), + '', + 'idless checks' +); + +is_deeply( + [ $form->check( + foo => [ {id => 'quux'}, {name => 'name'}, {value => 0}, {id => ''}, undef ], {id => 'bar'} + ) ], + [ + '', + '', + '', + '', + '', + ], + 'check overrides' +); + +is_deeply( + [ $form->check(foo => ['bar', {name => 'bar'}], {name => 'ignored'}) ], + [ + '', + '', + ], + 'checkbox names' +); + is_deeply( [ $form->check(undef, ['', '<">']) ], [ '', '', ], - 'multiple checkboxes' + 'anonymous checkboxes' ); is_deeply( @@ -464,6 +543,32 @@ is_deeply( 'various checkboxes' ); +# row + +is( + $form->row(undef), + ' ', + 'empty row' +); + +is( + $form->row('test'), + ' ', + 'standard row' +); + +is( + $form->row('test', {type => 'password'}, {for => '', label => '"blah"'}), + ' ', + 'row options' +); + +is( + $form->row('test', '"scalar"', {for => ''}), + ' "scalar"', + 'row scalar' +); + # defaults my $defform = HTML::Form::Simple->new({foo => '<">', '' => 'empty', 0 => 0});