X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F104_io_w_utf8.t;h=bc05023e3caea64d8f0ab9b93829b53a2462e46a;hb=master;hp=5993f6d6b7ab091c77736f5827ef1fd13acf4161;hpb=0b1731882300cdb05aa9fe09716da7a9a03cd00d;p=gitmo%2FMooseX-Storage.git diff --git a/t/104_io_w_utf8.t b/t/104_io_w_utf8.t index 5993f6d..bc05023 100644 --- a/t/104_io_w_utf8.t +++ b/t/104_io_w_utf8.t @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings; @@ -8,24 +6,22 @@ use File::Temp qw(tempdir); use File::Spec::Functions; my $dir = tempdir( CLEANUP => 1 ); +# NOTE: +# this is because JSON::XS (and Cpanel::JSON::XS) is +# the only one which really gets utf8 correct +# - SL +BEGIN { + $ENV{JSON_ANY_ORDER} = 'XS CPANEL'; + $ENV{JSON_ANY_CONFIG} = "utf8=0,canonical=1"; +} + use Test::Requires { 'JSON::Any' => 0.01, # skip all if not installed 'IO::AtomicFile' => 0.01, }; -BEGIN { - # NOTE: - # this is because JSON::XS is - # the only one which really gets - # utf8 correct - # - SL - BEGIN { - $ENV{JSON_ANY_ORDER} = qw(XS); - $ENV{JSON_ANY_CONFIG} = "utf8=1"; - } - plan tests => 8; - use_ok('MooseX::Storage'); -} +plan tests => 8; +use_ok('MooseX::Storage'); use utf8; @@ -35,7 +31,7 @@ use utf8; use MooseX::Storage; with Storage( 'format' => 'JSON', 'io' => 'File' ); - + has 'utf8_string' => ( is => 'rw', isa => 'Str', @@ -48,16 +44,16 @@ my $file = catfile($dir,'temp.json'); { my $foo = Foo->new; isa_ok( $foo, 'Foo' ); - - $foo->store($file); + + $foo->store($file); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); - is($foo->utf8_string, - "ネットスーパー (Internet Shopping)", + is($foo->utf8_string, + "ネットスーパー (Internet Shopping)", '... got the string we expected'); } @@ -70,18 +66,18 @@ unlink $file; utf8_string => 'Escritório' ); isa_ok( $foo, 'Foo' ); - - $foo->store($file); + + $foo->store($file); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); - + ok(utf8::is_utf8($foo->utf8_string), '... the string is still utf8'); - is($foo->utf8_string, - "Escritório", + is($foo->utf8_string, + "Escritório", '... got the string we expected'); }