You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by st...@apache.org on 2003/09/23 01:50:10 UTC
cvs commit: modperl-2.0/t/response/TestModperl print_utf8.pm
stas 2003/09/22 16:50:10
Modified: t/modperl print_utf8.t
t/response/TestModperl print_utf8.pm
Log:
test cleanups and imrovements
Revision Changes Path
1.2 +9 -18 modperl-2.0/t/modperl/print_utf8.t
Index: print_utf8.t
===================================================================
RCS file: /home/cvs/modperl-2.0/t/modperl/print_utf8.t,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -u -r1.1 -r1.2
--- print_utf8.t 20 Aug 2003 23:20:14 -0000 1.1
+++ print_utf8.t 22 Sep 2003 23:50:10 -0000 1.2
@@ -6,29 +6,20 @@
use Apache::TestUtil;
# utf encode/decode was added only in 5.8.0
-# currently binmode is only available with perlio
+# XXX: currently binmode is only available with perlio (used on the
+# server side on the tied/perlio STDOUT)
plan tests => 1, have have_min_perl_version(5.008), have_perl('perlio');
-#use bytes;
-#use utf8;
-
my $location = "/TestModperl__print_utf8";
-
-my $received = GET_BODY_ASSERT $location;
-
-# the external stream already include wide-chars, but perl doesn't
-# know about it
-utf8::decode($received);
-
-binmode(STDOUT, ':utf8');
-
-
my $expected = "Hello Ayhan \x{263A} perlio rules!";
-print "$expected\n";
-print "$received\n";
+my $res = GET $location;
+my $received = $res->content;
-#ok $expected eq $received;
+# response body includes wide-chars, but perl doesn't know about it
+utf8::decode($received) if ($res->header('Content-Type')||'') =~ /utf-8/i;
-ok t_cmp($expected, $received, 'UTF8 encoding');
+# needed for debugging print out of utf8 strings
+binmode(STDOUT, ':utf8');
+ok t_cmp($expected, $received, 'UTF8 response via tied/perlio STDOUT');
1.2 +10 -5 modperl-2.0/t/response/TestModperl/print_utf8.pm
Index: print_utf8.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestModperl/print_utf8.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -u -r1.1 -r1.2
--- print_utf8.pm 20 Aug 2003 23:20:14 -0000 1.1
+++ print_utf8.pm 22 Sep 2003 23:50:10 -0000 1.2
@@ -1,5 +1,12 @@
package TestModperl::print_utf8;
+# testing the utf8-encoded response via a tied STDOUT/perlio STDOUT,
+# the latter if perl was built with perlio.
+# see Modperl/print_utf8_2.pm for $r->print
+
+# must test against a tied STDOUT/perlio STDOUT. $r->print does the
+# right thing without any extra provisions
+
use strict;
use warnings FATAL => 'all';
@@ -8,17 +15,16 @@
use Apache::Const -compile => 'OK';
-use utf8;
-
sub handler {
my $r = shift;
$r->content_type('text/plain; charset=UTF-8');
- #Apache::RequestRec::BINMODE
- binmode(STDOUT, ':utf8');
+ # prevent warning: "Wide character in print"
+ binmode(STDOUT, ':utf8'); # Apache::RequestRec::BINMODE()
# must be non-$r->print(), so we go through the tied STDOUT
+ # \x{263A} == :-)
print "Hello Ayhan \x{263A} perlio rules!";
Apache::OK;
@@ -26,5 +32,4 @@
1;
__DATA__
-# must test against a tied STDOUT
SetHandler perl-script