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