[Catalyst-commits] r12655 - in Catalyst-Runtime/5.80/trunk/t: aggregate lib/TestAppEncoding/Controller

dandv at dev.catalyst.perl.org dandv at dev.catalyst.perl.org
Thu Jan 14 23:52:44 GMT 2010


Author: dandv
Date: 2010-01-14 23:52:44 +0000 (Thu, 14 Jan 2010)
New Revision: 12655

Added:
   Catalyst-Runtime/5.80/trunk/t/aggregate/catalyst_test_utf8.t
Modified:
   Catalyst-Runtime/5.80/trunk/t/lib/TestAppEncoding/Controller/Root.pm
Log:
Passing test case for RT #53678 - Catalyst::Test::get currently doesn't decode the response body octets


Added: Catalyst-Runtime/5.80/trunk/t/aggregate/catalyst_test_utf8.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/catalyst_test_utf8.t	                        (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/catalyst_test_utf8.t	2010-01-14 23:52:44 UTC (rev 12655)
@@ -0,0 +1,27 @@
+use strict;
+use warnings;
+use FindBin qw/$Bin/;
+use lib "$Bin/../lib";
+
+use Test::More;
+# "binmode STDOUT, ':utf8'" is insufficient, see http://code.google.com/p/test-more/issues/detail?id=46#c1
+binmode Test::More->builder->output, ":utf8";
+binmode Test::More->builder->failure_output, ":utf8";
+
+use Catalyst::Test 'TestAppEncoding';
+
+plan skip_all => 'This test does not run live'
+    if $ENV{CATALYST_SERVER};
+
+{   
+    # Test for https://rt.cpan.org/Ticket/Display.html?id=53678
+    # Catalyst::Test::get currently returns the raw octets, but it
+    # would be more useful if it decoded the content based on the
+    # Content-Type charset, as Test::WWW::Mechanize::Catalyst does
+    use utf8;
+    my $body = get('/utf8_non_ascii_content');
+    utf8::decode($body);
+    is $body, 'ʇsʎlɐʇɐɔ', 'Catalyst::Test::get returned content correctly UTF-8 encoded';
+}
+
+done_testing;

Modified: Catalyst-Runtime/5.80/trunk/t/lib/TestAppEncoding/Controller/Root.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestAppEncoding/Controller/Root.pm	2010-01-14 22:24:09 UTC (rev 12654)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestAppEncoding/Controller/Root.pm	2010-01-14 23:52:44 UTC (rev 12655)
@@ -24,6 +24,23 @@
     $c->res->body($str);
 }
 
+# called by t/aggregate/catalyst_test_utf8.t
+sub utf8_non_ascii_content : Local {
+    use utf8;
+    my ($self, $c) = @_;
+    
+    my $str = 'ʇsʎlɐʇɐɔ';  # 'catalyst' flipped at http://www.revfad.com/flip.html
+    ok utf8::is_utf8($str), '$str is in UTF8 internally';
+    
+    # encode $str into a sequence of octets and turn off the UTF-8 flag, so that
+    # we don't get the 'Wide character in syswrite' error in Catalyst::Engine
+    utf8::encode($str);
+    ok !utf8::is_utf8($str), '$str is a sequence of octets (byte string)';
+    
+    $c->res->body($str);
+}
+
+
 sub end : Private {
     my ($self,$c) = @_;
 }




More information about the Catalyst-commits mailing list