use strict; use HTML::Tiny; use Test::More tests => 18; ok my $h = HTML::Tiny->new, 'Create succeeded'; ok my $h_html = HTML::Tiny->new( mode => 'html' ), 'Create succeeded (mode HTML)'; common_checks( $h ); common_checks( $h_html, ' (mode HTML)' ); is $h->br, '
', 'br OK'; is $h->input( { name => 'myfield', type => 'text' } ), '', 'input OK'; is $h->img( { src => 'pic.jpg' } ), '', 'img OK'; is $h_html->br, '
', 'br OK (mode HTML)'; is $h_html->input( { name => 'myfield', type => 'text' } ), '', 'input OK (mode HTML)'; is $h_html->img( { src => 'pic.jpg' } ), '', 'img OK (mode HTML)'; sub common_checks { my $h = shift; my $mode = shift || ''; is $h->p( 'hello, world' ), "

hello, world

\n", 'p OK' . $mode; is $h->a( { href => 'http://hexten.net', title => 'Hexten' }, 'Hexten' ), 'Hexten', 'a OK' . $mode; is $h->textarea(), '', 'empty tag OK' . $mode; is $h->html( [ $h->head( $h->title( 'Sample page' ) ), $h->body( [ $h->h1( { class => 'main' }, 'Sample page' ), $h->p( 'Hello, World', { class => 'detail' }, 'Second para' ) ] ) ] ), "Sample page" . "\n

Sample page

" . "

Hello, World

\n

Second para

\n" . "\n\n", 'complex HTML OK' . $mode; is $h->table( [ $h->tr( [ $h->th( 'Name', 'Score', 'Position' ) ], [ $h->td( 'Therese', 90, 1 ) ], [ $h->td( 'Chrissie', 85, 2 ) ], [ $h->td( 'Andy', 50, 3 ) ] ) ] ), "\n" . "\n" . "\n" . "\n" . "
NameScorePosition
Therese901
Chrissie852
Andy503
\n", 'table OK' . $mode; }