10 plan skip_all => "Encode is required for this test" if $@;
12 # this is because JSON::XS is
13 # the only one which really gets
17 $ENV{JSON_ANY_ORDER} = qw(XS);
18 $ENV{JSON_ANY_CONFIG} = "utf8=1";
21 use_ok('MooseX::Storage');
29 with Storage( 'format' => 'JSON' );
31 has 'utf8_string' => (
34 default => sub { "ネットスーパー (Internet Shopping)" }
40 isa_ok( $foo, 'Foo' );
42 my $json = $foo->freeze;
45 '{"__CLASS__":"Foo","utf8_string":"ネットスーパー (Internet Shopping)"}',
46 '... got the right JSON');
48 my $foo2 = Foo->thaw($json);
49 isa_ok( $foo, 'Foo' );
51 is($foo2->utf8_string,
52 "ネットスーパー (Internet Shopping)",
53 '... got the string we expected');
56 '{"__CLASS__":"Foo","utf8_string":"ネットスーパー (Internet Shopping)"}',
57 '... got the right JSON');
64 $test_string = "ネットスーパー (Internet Shopping)";
68 ok(utf8::is_utf8($test_string), '... got a utf8 string');
69 ok(utf8::valid($test_string), '... got a valid utf8 string');
71 Encode::_utf8_off($test_string);
73 ok(!utf8::is_utf8($test_string), '... no longer is utf8 string');
74 ok(utf8::valid($test_string), '... got a valid utf8 string');
77 utf8_string => $test_string
79 isa_ok( $foo, 'Foo' );
81 ok(!utf8::is_utf8($foo->utf8_string), '... not a utf8 string');
82 ok(utf8::valid($foo->utf8_string), '... but is a valid utf8 string');
84 my $json = $foo->freeze;
86 ok(utf8::is_utf8($json), '... is a utf8 string now');
87 ok(utf8::valid($json), '... got a valid utf8 string');
90 '{"__CLASS__":"Foo","utf8_string":"ネットスーパー (Internet Shopping)"}',
91 '... got the right JSON');