Upgrade to CGI.pm-3.48
[perl.git] / cpan / CGI / t / no_tabindex.t
1 #!/usr/local/bin/perl -w
2
3 use Test::More tests => 18;
4
5 BEGIN { use_ok('CGI'); };
6 use CGI (':standard','-no_debug');
7
8 my $CRLF = "\015\012";
9 if ($^O eq 'VMS') {
10     $CRLF = "\n";  # via web server carriage is inserted automatically
11 }
12 if (ord("\t") != 9) { # EBCDIC?
13     $CRLF = "\r\n";
14 }
15
16
17 # Set up a CGI environment
18 $ENV{REQUEST_METHOD}  = 'GET';
19 $ENV{QUERY_STRING}    = 'game=chess&game=checkers&weather=dull';
20 $ENV{PATH_INFO}       = '/somewhere/else';
21 $ENV{PATH_TRANSLATED} = '/usr/local/somewhere/else';
22 $ENV{SCRIPT_NAME}     ='/cgi-bin/foo.cgi';
23 $ENV{SERVER_PROTOCOL} = 'HTTP/1.0';
24 $ENV{SERVER_PORT}     = 8080;
25 $ENV{SERVER_NAME}     = 'the.good.ship.lollypop.com';
26
27 ok( (not $CGI::TABINDEX), "Tab index turned off.");
28
29 is(submit(),
30    qq(<input type="submit" name=".submit" />),
31    "submit()");
32
33 is(submit(-name  => 'foo',
34           -value => 'bar'),
35    qq(<input type="submit" name="foo" value="bar" />),
36    "submit(-name,-value)");
37
38 is(submit({-name  => 'foo',
39            -value => 'bar'}),
40    qq(<input type="submit" name="foo" value="bar" />),
41    "submit({-name,-value})");
42
43 is(textfield(-name => 'weather'),
44    qq(<input type="text" name="weather" value="dull" />),
45    "textfield({-name})");
46
47 is(textfield(-name  => 'weather',
48              -value => 'nice'),
49    qq(<input type="text" name="weather" value="dull" />),
50    "textfield({-name,-value})");
51
52 is(textfield(-name     => 'weather',
53              -value    => 'nice',
54              -override => 1),
55    qq(<input type="text" name="weather" value="nice" />),
56    "textfield({-name,-value,-override})");
57
58 is(checkbox(-name  => 'weather',
59             -value => 'nice'),
60    qq(<label><input type="checkbox" name="weather" value="nice" />weather</label>),
61    "checkbox()");
62
63 is(checkbox(-name  => 'weather',
64             -value => 'nice',
65             -label => 'forecast'),
66    qq(<label><input type="checkbox" name="weather" value="nice" />forecast</label>),
67    "checkbox()");
68
69 is(checkbox(-name     => 'weather',
70             -value    => 'nice',
71             -label    => 'forecast',
72             -checked  => 1,
73             -override => 1),
74    qq(<label><input type="checkbox" name="weather" value="nice" checked="checked" />forecast</label>),
75    "checkbox()");
76
77 is(checkbox(-name  => 'weather',
78             -value => 'dull',
79             -label => 'forecast'),
80    qq(<label><input type="checkbox" name="weather" value="dull" checked="checked" />forecast</label>),
81    "checkbox()");
82
83 is(radio_group(-name => 'game'),
84    qq(<label><input type="radio" name="game" value="chess" checked="checked" />chess</label> <label><input type="radio" name="game" value="checkers" />checkers</label>),
85    'radio_group()');
86
87 is(radio_group(-name   => 'game',
88                -labels => {'chess' => 'ping pong'}),
89    qq(<label><input type="radio" name="game" value="chess" checked="checked" />ping pong</label> <label><input type="radio" name="game" value="checkers" />checkers</label>),
90    'radio_group()');
91
92 is(checkbox_group(-name   => 'game',
93                   -Values => [qw/checkers chess cribbage/]),
94    qq(<label><input type="checkbox" name="game" value="checkers" checked="checked" />checkers</label> <label><input type="checkbox" name="game" value="chess" checked="checked" />chess</label> <label><input type="checkbox" name="game" value="cribbage" />cribbage</label>),
95    'checkbox_group()');
96
97 is(checkbox_group(-name       => 'game',
98                   '-values'   => [qw/checkers chess cribbage/],
99                   '-defaults' => ['cribbage'],
100                   -override=>1),
101    qq(<label><input type="checkbox" name="game" value="checkers" />checkers</label> <label><input type="checkbox" name="game" value="chess" />chess</label> <label><input type="checkbox" name="game" value="cribbage" checked="checked" />cribbage</label>),
102    'checkbox_group()');
103
104 is(popup_menu(-name     => 'game',
105               '-values' => [qw/checkers chess cribbage/],
106               -default  => 'cribbage',
107               -override => 1),
108    '<select name="game" >
109 <option value="checkers">checkers</option>
110 <option value="chess">chess</option>
111 <option selected="selected" value="cribbage">cribbage</option>
112 </select>',
113    'popup_menu()');
114
115
116 is(textarea(-name=>'foo',
117             -default=>'starting value',
118             -rows=>10,
119             -columns=>50),
120    '<textarea name="foo"  rows="10" cols="50">starting value</textarea>',
121    'textarea()');
122