3 # Test ability to retrieve HTTP request info
4 ######################### We start with some black magic to print on failure.
8 @INC = '../lib' if -d '../lib';
11 BEGIN {$| = 1; print "1..17\n"; }
12 END {print "not ok 1\n" unless $loaded;}
13 use CGI (':standard','-no_debug');
17 ######################### End of black magic.
22 my($num, $true,$msg) = @_;
23 print($true ? "ok $num\n" : "not ok $num $msg\n");
26 # all the automatic tags
27 test(2,h1() eq '<H1>',"single tag");
28 test(3,h1('fred') eq '<H1>fred</H1>',"open/close tag");
29 test(4,h1('fred','agnes','maura') eq '<H1>fred agnes maura</H1>',"open/close tag multiple");
30 test(5,h1({-align=>'CENTER'},'fred') eq '<H1 ALIGN="CENTER">fred</H1>',"open/close tag with attribute");
31 test(6,h1({-align=>undef},'fred') eq '<H1 ALIGN>fred</H1>',"open/close tag with orphan attribute");
32 test(7,h1({-align=>'CENTER'},['fred','agnes']) eq
33 '<H1 ALIGN="CENTER">fred</H1> <H1 ALIGN="CENTER">agnes</H1>',
34 "distributive tag with attribute");
37 test(8,h1('fred','agnes','maura') eq '<H1>fred-agnes-maura</H1>',"open/close tag \$\" interpolation");
39 test(9,header() eq "Content-Type: text/html\r\n\r\n","header()");
40 test(10,header(-type=>'image/gif') eq "Content-Type: image/gif\r\n\r\n","header()");
41 test(11,header(-type=>'image/gif',-status=>'500 Sucks') eq "Status: 500 Sucks\r\nContent-Type: image/gif\r\n\r\n","header()");
42 test(12,header(-nph=>1) eq "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n","header()");
43 test(13,start_html() ."\n" eq <<END,"start_html()");
44 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
45 <HTML><HEAD><TITLE>Untitled Document</TITLE>
49 test(14,start_html(-dtd=>"-//IETF//DTD HTML 3.2//FR") ."\n" eq <<END,"start_html()");
50 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.2//FR">
51 <HTML><HEAD><TITLE>Untitled Document</TITLE>
55 test(15,start_html(-Title=>'The world of foo') ."\n" eq <<END,"start_html()");
56 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
57 <HTML><HEAD><TITLE>The world of foo</TITLE>
61 test(16,($cookie=cookie(-name=>'fred',-value=>['chocolate','chip'],-path=>'/')) eq
62 'fred=chocolate&chip; path=/',"cookie()");
63 test(17,header(-Cookie=>$cookie) =~ m!^Set-Cookie: fred=chocolate&chip\; path=/\r\nDate:.*\r\nContent-Type: text/html\r\n\r\n!s,