summaryrefslogtreecommitdiff
path: root/lib/CGI/t
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-06-02 16:41:37 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-06-02 16:41:37 +0000
commit8f3ccfa25e524ac7012f7d988353f2de4c217ccb (patch)
treea877391c6b5e4df12e9c608cfa6ac5d58f5685fd /lib/CGI/t
parent13e345655fd69fad07c7c1d3f491abb9523bfcbd (diff)
downloadperl-8f3ccfa25e524ac7012f7d988353f2de4c217ccb.tar.gz
Upgrade to the CGI.pm 2.93.
(Lincoln keeps ripping out the BEGIN/PERL_CORE blocks. Sigh.) p4raw-id: //depot/perl@19664
Diffstat (limited to 'lib/CGI/t')
-rw-r--r--lib/CGI/t/apache.t15
-rw-r--r--lib/CGI/t/carp.t18
-rw-r--r--lib/CGI/t/cookie.t15
-rw-r--r--lib/CGI/t/fast.t15
-rwxr-xr-xlib/CGI/t/form.t16
-rwxr-xr-xlib/CGI/t/function.t23
-rwxr-xr-xlib/CGI/t/html.t29
-rw-r--r--lib/CGI/t/push.t15
-rwxr-xr-xlib/CGI/t/request.t10
-rw-r--r--lib/CGI/t/switch.t15
-rw-r--r--lib/CGI/t/util-58.t16
-rw-r--r--lib/CGI/t/util.t11
12 files changed, 82 insertions, 116 deletions
diff --git a/lib/CGI/t/apache.t b/lib/CGI/t/apache.t
index 637ac88132..7f92155c3f 100644
--- a/lib/CGI/t/apache.t
+++ b/lib/CGI/t/apache.t
@@ -1,15 +1,10 @@
#!/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 lib qw(t/lib);
+
+# 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
+use lib qw(blib/lib blib/arch);
use strict;
use Test::More tests => 1;
diff --git a/lib/CGI/t/carp.t b/lib/CGI/t/carp.t
index 0de6a101ce..dcdf732410 100644
--- a/lib/CGI/t/carp.t
+++ b/lib/CGI/t/carp.t
@@ -1,18 +1,12 @@
# -*- Mode: cperl; coding: utf-8; cperl-indent-level: 2 -*-
#!/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 strict;
+use lib qw(t/lib);
+
+# 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
+use lib qw(blib/lib blib/arch);
use Test::More tests => 47;
use IO::Handle;
@@ -199,7 +193,7 @@ untie *STDOUT;
open(STDOUT, ">&REAL_STDOUT");
my $fname = $0;
$fname =~ tr/<>-/\253\273\255/; # _warn does this so we have to also
-is( $fake_out, "<!-- warning: There is a problem at $fname line 106. -->\n",
+is( $fake_out, "<!-- warning: There is a problem at $fname line 100. -->\n",
'warningsToBrowser() on' );
is($CGI::Carp::EMIT_WARNINGS, 1, "Warnings turned off");
diff --git a/lib/CGI/t/cookie.t b/lib/CGI/t/cookie.t
index c523d7aecd..f02d11302c 100644
--- a/lib/CGI/t/cookie.t
+++ b/lib/CGI/t/cookie.t
@@ -1,17 +1,12 @@
#!/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 lib qw(t/lib);
use strict;
+# 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
+use lib qw(blib/lib blib/arch);
+
use Test::More tests => 86;
use CGI::Util qw(escape unescape);
use POSIX qw(strftime);
diff --git a/lib/CGI/t/fast.t b/lib/CGI/t/fast.t
index d8ad97333f..45f8e1271c 100644
--- a/lib/CGI/t/fast.t
+++ b/lib/CGI/t/fast.t
@@ -1,15 +1,10 @@
#!./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 lib qw(t/lib);
+
+# 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
+use lib qw(blib/lib blib/arch);
my $fcgi;
BEGIN {
diff --git a/lib/CGI/t/form.t b/lib/CGI/t/form.t
index a6a90a6058..5b26a3d885 100755
--- a/lib/CGI/t/form.t
+++ b/lib/CGI/t/form.t
@@ -1,16 +1,10 @@
#!/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 lib qw(t/lib ./lib ../blib/lib);
+
+# 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
+use lib qw(blib/lib blib/arch);
use Test::More tests => 17;
diff --git a/lib/CGI/t/function.t b/lib/CGI/t/function.t
index 26fc32af82..1cde4ac5b0 100755
--- a/lib/CGI/t/function.t
+++ b/lib/CGI/t/function.t
@@ -1,15 +1,12 @@
#!/usr/local/bin/perl -w
-BEGIN {
- chdir 't' if -d 't';
- if ($ENV{PERL_CORE}) {
- @INC = '../lib';
- } else {
- unshift @INC, qw( ../blib/lib ../blib/arch lib );
- }
-}
+use lib qw(t/lib);
+
+# Test ability to retrieve HTTP request info
+######################### We start with some black magic to print on failure.
+use lib '../blib/lib','../blib/arch';
-BEGIN {$| = 1; print "1..28\n"; }
+BEGIN {$| = 1; print "1..31\n"; }
END {print "not ok 1\n" unless $loaded;}
use Config;
use CGI (':standard','keywords');
@@ -41,6 +38,9 @@ if ($^O eq 'VMS') { $CRLF = "\n"; }
if (ord("\t") != 9) { $CRLF = "\r\n"; }
+# Web servers on EBCDIC hosts are typically set up to do an EBCDIC -> ASCII
+# translation hence CRLF is used as \r\n within CGI.pm on such machines.
+
if (ord("\t") != 9) { $CRLF = "\r\n"; }
# Set up a CGI environment
@@ -108,3 +108,8 @@ test(26,$h eq "Status: 302 Moved${CRLF}Location: http://somewhere.else${CRLF}Con
test(27,redirect(-Location=>'http://somewhere.else/bin/foo&bar',-Type=>'text/html') eq "Status: 302 Moved${CRLF}Location: http://somewhere.else/bin/foo&bar${CRLF}Content-Type: text/html; charset=ISO-8859-1${CRLF}${CRLF}","CGI::redirect() 2");
test(28,escapeHTML('CGI') eq 'CGI','escapeHTML(CGI) failing again');
+
+test(29, charset("UTF-8") && header() eq "Content-Type: text/html; charset=UTF-8${CRLF}${CRLF}", "UTF-8 charset");
+test(30, !charset("") && header() eq "Content-Type: text/html${CRLF}${CRLF}", "Empty charset");
+
+test(31, header(-foo=>'bar') eq "Foo: bar${CRLF}Content-Type: text/html${CRLF}${CRLF}", "Custom header");
diff --git a/lib/CGI/t/html.t b/lib/CGI/t/html.t
index 1af6754b33..b3c462c079 100755
--- a/lib/CGI/t/html.t
+++ b/lib/CGI/t/html.t
@@ -1,30 +1,21 @@
#!/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 );
- }
-}
# Test ability to retrieve HTTP request info
######################### We start with some black magic to print on failure.
+use lib '../blib/lib','../blib/arch';
-BEGIN {$| = 1; print "1..24\n"; }
END {print "not ok 1\n" unless $loaded;}
use CGI (':standard','-no_debug','*h3','start_table');
$loaded = 1;
print "ok 1\n";
BEGIN {
- if ($] >= 5.006) {
- require utf8; # we contain Latin-1 in subtest #22,
- utf8->unimport; # possible "use utf8" must be undone
- }
+ $| = 1; print "1..27\n";
+ if( $] > 5.006 ) {
+ # no utf8
+ require utf8; # we contain Latin-1
+ utf8->unimport;
+ }
}
######################### End of black magic.
@@ -105,3 +96,9 @@ test(22,h1(escapeHTML("this is <not> \x8bright\x9b")) eq '<h1>this is &lt;not&gt
test(23,i(p('hello there')) eq '<i><p>hello there</p></i>');
my $q = new CGI;
test(24,$q->h1('hi') eq '<h1>hi</h1>');
+
+$q->autoEscape(1);
+test(25,$q->p({title=>"hello world&egrave;"},'hello &aacute;') eq '<p title="hello world&amp;egrave;">hello &aacute;</p>');
+$q->autoEscape(0);
+test(26,$q->p({title=>"hello world&egrave;"},'hello &aacute;') eq '<p title="hello world&egrave;">hello &aacute;</p>');
+test(27,p({title=>"hello world&egrave;"},'hello &aacute;') eq '<p title="hello world&amp;egrave;">hello &aacute;</p>');
diff --git a/lib/CGI/t/push.t b/lib/CGI/t/push.t
index dbe4551cc5..2c48d60ba3 100644
--- a/lib/CGI/t/push.t
+++ b/lib/CGI/t/push.t
@@ -1,15 +1,10 @@
#!./perl -wT
-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 lib qw(t/lib);
+
+# 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
+use lib qw(blib/lib blib/arch);
use Test::More tests => 12;
diff --git a/lib/CGI/t/request.t b/lib/CGI/t/request.t
index 5c79050f49..96775a9279 100755
--- a/lib/CGI/t/request.t
+++ b/lib/CGI/t/request.t
@@ -1,16 +1,8 @@
#!/usr/local/bin/perl -w
-BEGIN {
- chdir 't' if -d 't';
- if ($ENV{PERL_CORE}) {
- @INC = '../lib';
- } else {
- unshift @INC, qw( ../blib/lib ../blib/arch lib );
- }
-}
-
# Test ability to retrieve HTTP request info
######################### We start with some black magic to print on failure.
+use lib '../blib/lib','../blib/arch';
BEGIN {$| = 1; print "1..33\n"; }
END {print "not ok 1\n" unless $loaded;}
diff --git a/lib/CGI/t/switch.t b/lib/CGI/t/switch.t
index eda3e8264e..ac58618a7f 100644
--- a/lib/CGI/t/switch.t
+++ b/lib/CGI/t/switch.t
@@ -1,15 +1,10 @@
#!/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 lib qw(t/lib);
+
+# 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
+use lib qw(blib/lib blib/arch);
use strict;
use Test::More tests => 1;
diff --git a/lib/CGI/t/util-58.t b/lib/CGI/t/util-58.t
new file mode 100644
index 0000000000..70a618917c
--- /dev/null
+++ b/lib/CGI/t/util-58.t
@@ -0,0 +1,16 @@
+#
+# This tests CGI::Util::escape() when fed with UTF-8-flagged string
+# -- dankogai
+BEGIN {
+ if ($] < 5.008) {
+ print "1..0 # \$] == $] < 5.008\n";
+ exit(0);
+ }
+}
+
+use Test::More tests => 2;
+use_ok("CGI::Util");
+my $uri = "\x{5c0f}\x{98fc} \x{5f3e}.txt"; # KOGAI, Dan, in Kanji
+is(CGI::Util::escape($uri), "%E5%B0%8F%E9%A3%BC%20%E5%BC%BE.txt",
+ "# Escape string with UTF-8 flag");
+__END__
diff --git a/lib/CGI/t/util.t b/lib/CGI/t/util.t
index c5ec617a5d..8f9da3ba94 100644
--- a/lib/CGI/t/util.t
+++ b/lib/CGI/t/util.t
@@ -1,17 +1,10 @@
#!/usr/local/bin/perl -w
-BEGIN {
- chdir 't' if -d 't';
- if ($ENV{PERL_CORE}) {
- @INC = '../lib';
- } else {
- unshift @INC, qw( ../blib/lib ../blib/arch lib );
- }
-}
-
# Test ability to escape() and unescape() punctuation characters
# except for qw(- . _).
######################### We start with some black magic to print on failure.
+use lib '../blib/lib','../blib/arch';
+
BEGIN {$| = 1; print "1..59\n"; }
END {print "not ok 1\n" unless $loaded;}
use Config;