5 2_fill_00_base.t - Test CGI::Ex::Fill's base ability.
10 use Test::More tests => 6;
12 use_ok qw(CGI::Ex::Fill);
14 ###----------------------------------------------------------------###
16 my $form = {foo => "FOO", bar => "BAR", baz => "BAZ"};
19 <input type=text name=foo>
20 <input type=text name=foo>
21 <input type=text name=bar value="">
22 <input type=text name=baz value="Something else">
23 <input type=text name=hem value="Another thing">
24 <input type=text name=haw>
27 CGI::Ex::Fill::form_fill(\$html, $form);
31 <input type=text name=foo value="FOO">
32 <input type=text name=foo value="FOO">
33 <input type=text name=bar value="BAR">
34 <input type=text name=baz value="BAZ">
35 <input type=text name=hem value="Another thing">
36 <input type=text name=haw value="">
37 ', "perldoc example 1 passed");
41 ###----------------------------------------------------------------###
43 $form = {foo => ['aaaa', 'bbbb', 'cccc']};
46 <input type=text name=foo>
47 <input type=text name=foo>
48 <input type=text name=foo>
49 <input type=text name=foo>
50 <input type=text name=foo>
53 form_fill(\$html, $form);
57 <input type=text name=foo value="aaaa">
58 <input type=text name=foo value="bbbb">
59 <input type=text name=foo value="cccc">
60 <input type=text name=foo value="">
61 <input type=text name=foo value="">
62 ', "Perldoc example 2 passed");
66 ###----------------------------------------------------------------###
68 $form = {foo => 'FOO', bar => ['aaaa', 'bbbb', 'cccc'], baz => 'on'};
71 <input type=checkbox name=foo value="123">
72 <input type=checkbox name=foo value="FOO">
73 <input type=checkbox name=bar value="aaaa">
74 <input type=checkbox name=bar value="cccc">
75 <input type=checkbox name=bar value="dddd" checked="checked">
76 <input type=checkbox name=baz>
79 form_fill(\$html, $form);
83 <input type=checkbox name=foo value="123">
84 <input type=checkbox name=foo value="FOO" checked="checked">
85 <input type=checkbox name=bar value="aaaa" checked="checked">
86 <input type=checkbox name=bar value="cccc" checked="checked">
87 <input type=checkbox name=bar value="dddd">
88 <input type=checkbox name=baz checked="checked">
89 ', "Perldoc example 3 passed");
93 ###----------------------------------------------------------------###
95 $form = {foo => 'FOO', bar => ['aaaa', 'bbbb', 'cccc']};
98 <select name=foo><option>FOO<option>123<br>
101 <option>aaaa</option>
102 <option value="cccc">cccc</option>
103 <option value="dddd" selected="selected">dddd</option>
107 form_fill(\$html, $form);
111 <select name=foo><option selected="selected">FOO<option>123<br>
114 <option selected="selected">aaaa</option>
115 <option value="cccc" selected="selected">cccc</option>
116 <option value="dddd">dddd</option>
118 ', "Perldoc example 4 passed");
122 ###----------------------------------------------------------------###
124 $form = {foo => 'FOO', bar => ['aaaa', 'bbbb']};
127 <textarea name=foo></textarea>
128 <textarea name=foo></textarea>
131 <textarea name=bar></textarea><br>
132 <textarea name=bar>dddd</textarea><br>
133 <textarea name=bar><br><br>
136 form_fill(\$html, $form);
140 <textarea name=foo>FOO</textarea>
141 <textarea name=foo>FOO</textarea>
143 <textarea name=bar>aaaa<textarea name=bar>bbbb</textarea><br>
144 <textarea name=bar></textarea><br>
145 <textarea name=bar>', "Perldoc example 5 passed");
149 ###----------------------------------------------------------------###