#!/usr/local/bin/perl -w BEGIN { chdir 't' if -d 't'; if ($ENV{PERL_CORE}) { @INC = '../lib'; } else { # Due to a bug in older versions of MakeMaker & Test::Harness, # we must ensure the blib's are in @INC, else we might use # the core CGI.pm unshift @INC, qw( ../blib/lib ../blib/arch ../lib ); } } use Test::More tests => 17; BEGIN { use_ok('CGI'); }; use CGI (':standard','-no_debug'); my $CRLF = "\015\012"; if ($^O eq 'VMS') { $CRLF = "\n"; # via web server carriage is inserted automatically } if (ord("\t") != 9) { # EBCDIC? $CRLF = "\r\n"; } # Set up a CGI environment $ENV{REQUEST_METHOD} = 'GET'; $ENV{QUERY_STRING} = 'game=chess&game=checkers&weather=dull'; $ENV{PATH_INFO} = '/somewhere/else'; $ENV{PATH_TRANSLATED} = '/usr/local/somewhere/else'; $ENV{SCRIPT_NAME} ='/cgi-bin/foo.cgi'; $ENV{SERVER_PROTOCOL} = 'HTTP/1.0'; $ENV{SERVER_PORT} = 8080; $ENV{SERVER_NAME} = 'the.good.ship.lollypop.com'; is(start_form(-action=>'foobar',-method=>'get'), qq(
\n), "start_form()"); is(submit(), qq(), "submit()"); is(submit(-name => 'foo', -value => 'bar'), qq(), "submit(-name,-value)"); is(submit({-name => 'foo', -value => 'bar'}), qq(), "submit({-name,-value})"); is(textfield(-name => 'weather'), qq(), "textfield({-name})"); is(textfield(-name => 'weather', -value => 'nice'), qq(), "textfield({-name,-value})"); is(textfield(-name => 'weather', -value => 'nice', -override => 1), qq(), "textfield({-name,-value,-override})"); is(checkbox(-name => 'weather', -value => 'nice'), qq(weather), "checkbox()"); is(checkbox(-name => 'weather', -value => 'nice', -label => 'forecast'), qq(forecast), "checkbox()"); is(checkbox(-name => 'weather', -value => 'nice', -label => 'forecast', -checked => 1, -override => 1), qq(forecast), "checkbox()"); is(checkbox(-name => 'weather', -value => 'dull', -label => 'forecast'), qq(forecast), "checkbox()"); is(radio_group(-name => 'game'), qq(chess ). qq(checkers), 'radio_group()'); is(radio_group(-name => 'game', -labels => {'chess' => 'ping pong'}), qq(ping pong ). qq(checkers), 'radio_group()'); is(checkbox_group(-name => 'game', -Values => [qw/checkers chess cribbage/]), qq(checkers ). qq(chess ). qq(cribbage), 'checkbox_group()'); is(checkbox_group(-name => 'game', '-values' => [qw/checkers chess cribbage/], '-defaults' => ['cribbage'],-override=>1), qq(checkers ). qq(chess ). qq(cribbage), 'checkbox_group()'); is(popup_menu(-name => 'game', '-values' => [qw/checkers chess cribbage/], -default => 'cribbage', -override => 1)."\n", < END