#! perl -w use strict; use warnings; use Test::More; use Tripletail '/dev/null'; plan tests => +1 # 01. +1 # 02. +1 # 03. +1 # 04a. +1 # 04b. +1 # 04c. +1 # 04d. +1 # 05. ; &test01_text(); &test02_textarea(); &test03_checkbox(); &test04a_select_dropdown(); &test04b_select_dropdown_few(); &test04c_select_dropdown_empty(); &test04d_select_dropdown_none(); &test05_select_multisel(); sub test01_text { my $html = ""; $html .= qq{\n}; $html .= qq{
\n}; my $form = $TL->newForm({ txt => [1, 2], }); my $tmpl = $TL->newTemplate->setTemplate($html); $tmpl->setForm($form); my $exp = ""; $exp .= qq{\n}; $exp .= qq{\n}; is($tmpl->toStr(), $exp, 'text with multi values, set on each tags'); } sub test02_textarea { my $html = ""; $html .= qq{\n}; $html .= qq{\n}; my $form = $TL->newForm({ tea => [3, 4], }); my $tmpl = $TL->newTemplate->setTemplate($html); $tmpl->setForm($form); my $exp = ""; $exp .= qq{\n}; $exp .= qq{\n}; is($tmpl->toStr(), $exp, 'textarea with multi values, set on each tags'); } sub test03_checkbox { my $html = ""; $html .= qq{\n}; $html .= qq{\n}; my $form = $TL->newForm({ chk => [9, 10], }); my $tmpl = $TL->newTemplate->setTemplate($html); $tmpl->setForm($form); my $exp = ""; $exp .= qq{\n}; $exp .= qq{\n}; is($tmpl->toStr(), $exp, 'checkbox with multi values'); } sub test04a_select_dropdown { my $html = ""; $html .= qq{\n}; $html .= qq{\n}; my $form = $TL->newForm({ sel => [5, 6], }); my $tmpl = $TL->newTemplate->setTemplate($html); $tmpl->setForm($form); my $exp = ""; $exp .= qq{\n}; $exp .= qq{\n}; is($tmpl->toStr(), $exp, 'select as drodown form'); } sub test04b_select_dropdown_few { my $html = ""; $html .= qq{\n}; $html .= qq{\n}; my $form = $TL->newForm({ sel => [5], }); my $tmpl = $TL->newTemplate->setTemplate($html); $tmpl->setForm($form); my $exp = ""; $exp .= qq{\n}; $exp .= qq{\n}; is($tmpl->toStr(), $exp, 'select as drodown form with few set value'); } sub test04c_select_dropdown_empty { my $html = ""; $html .= qq{\n}; $html .= qq{\n}; my $form = $TL->newForm({ sel => [], }); my $tmpl = $TL->newTemplate->setTemplate($html); $tmpl->setForm($form); my $exp = ""; $exp .= qq{\n}; $exp .= qq{\n}; is($tmpl->toStr(), $exp, 'select as drodown form with empty set value'); } sub test04d_select_dropdown_none { my $html = ""; $html .= qq{\n}; $html .= qq{\n}; my $form = $TL->newForm({ }); my $tmpl = $TL->newTemplate->setTemplate($html); $tmpl->setForm($form); my $exp = ""; $exp .= qq{\n}; $exp .= qq{\n}; is($tmpl->toStr(), $exp, 'select as drodown form without value'); } sub test05_select_multisel { my $html = ""; $html .= qq{\n}; $html .= qq{\n}; my $form = $TL->newForm({ sel => [5, 6], }); my $tmpl = $TL->newTemplate->setTemplate($html); $tmpl->setForm($form); my $exp = ""; $exp .= qq{\n}; $exp .= qq{\n}; is($tmpl->toStr(), $exp, 'select as mutl-select list'); }