X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F105_io_atomic_w_utf8.t;h=386e8e573a107fe82487e3d32f7055551248d595;hb=c2d52f94beb56939250944a12df15d7d90779866;hp=d14a865f82677979162d07eb4c62d4b059877436;hpb=5e5d4e282f78965168236c6631705cae8d5d01de;p=gitmo%2FMooseX-Storage.git diff --git a/t/105_io_atomic_w_utf8.t b/t/105_io_atomic_w_utf8.t index d14a865..386e8e5 100644 --- a/t/105_io_atomic_w_utf8.t +++ b/t/105_io_atomic_w_utf8.t @@ -1,31 +1,28 @@ -#!/usr/bin/perl - use strict; use warnings; use Test::More; use File::Temp qw(tempdir); use File::Spec::Functions; -my $dir = tempdir( CLEANUP => 1 ); - -BEGIN { - eval "use IO::AtomicFile"; - plan skip_all => "IO::AtomicFile is required for this test" if $@; - eval "use JSON::Any"; - plan skip_all => "JSON::Any is required for this test" if $@; - # 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'); +my $dir = tempdir; + +# 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, +}; + +plan tests => 8; +use_ok('MooseX::Storage'); + use utf8; { @@ -34,7 +31,7 @@ use utf8; use MooseX::Storage; with Storage( 'format' => 'JSON', 'io' => 'AtomicFile' ); - + has 'utf8_string' => ( is => 'rw', isa => 'Str', @@ -47,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'); } @@ -69,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'); }