BEGIN {
chdir 't' if -d 't';
- @INC = '../lib' if -d '../lib';
+ unshift @INC, '../lib' if -d '../lib';
}
BEGIN {$| = 1; print "1..31\n"; }
END {print "not ok 1\n" unless $loaded;}
+use Config;
use CGI ();
$loaded = 1;
print "ok 1\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{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';
-$ENV{HTTP_LOVE} = 'true';
+$ENV{SERVER_PORT} = 8080;
+$ENV{SERVER_NAME} = 'the.good.ship.lollypop.com';
+$ENV{REQUEST_URI} = "$ENV{SCRIPT_NAME}$ENV{PATH_INFO}?$ENV{QUERY_STRING}";
+$ENV{HTTP_LOVE} = 'true';
$q = new CGI;
test(2,$q,"CGI::new()");
test(27,$q=new CGI({'foo'=>'bar','bar'=>'froz'}),"CGI::new() redux 2");
test(28,$q->param('bar') eq 'froz',"CGI::param() redux 2");
-$q->_reset_globals;
-$test_string = 'game=soccer&game=baseball&weather=nice';
-$ENV{REQUEST_METHOD}='POST';
-$ENV{CONTENT_LENGTH}=length($test_string);
-$ENV{QUERY_STRING}='big_balls=basketball&small_balls=golf';
-if (open(CHILD,"|-")) { # cparent
- print CHILD $test_string;
- close CHILD;
- exit 0;
+if (!$Config{d_fork} or $^O eq 'MSWin32' or $^O eq 'VMS') {
+ for (29..31) { print "ok $_ # Skipped: fork n/a\n" }
+}
+else {
+ $q->_reset_globals;
+ $test_string = 'game=soccer&game=baseball&weather=nice';
+ $ENV{REQUEST_METHOD}='POST';
+ $ENV{CONTENT_LENGTH}=length($test_string);
+ $ENV{QUERY_STRING}='big_balls=basketball&small_balls=golf';
+ if (open(CHILD,"|-")) { # cparent
+ print CHILD $test_string;
+ close CHILD;
+ exit 0;
+ }
+ # at this point, we're in a new (child) process
+ test(29,$q=new CGI,"CGI::new() from POST");
+ test(30,$q->param('weather') eq 'nice',"CGI::param() from POST");
+ test(31,$q->url_param('big_balls') eq 'basketball',"CGI::url_param()");
}
-# at this point, we're in a new (child) process
-test(29,$q=new CGI,"CGI::new() from POST");
-test(30,$q->param('weather') eq 'nice',"CGI::param() from POST");
-test(31,$q->url_param('big_balls') eq 'basketball',"CGI::url_param()");