9 'Encode' => 0.01, # skip all if not installed
15 # this is because JSON::XS is
16 # the only one which really gets
20 $ENV{JSON_ANY_ORDER} = qw(XS);
21 $ENV{JSON_ANY_CONFIG} = "utf8=1";
25 use_ok('MooseX::Storage');
33 with Storage( 'format' => 'JSON' );
35 has 'utf8_string' => (
38 default => sub { "ネットスーパー (Internet Shopping)" }
44 isa_ok( $foo, 'Foo' );
46 my $json = $foo->freeze;
49 '{"__CLASS__":"Foo","utf8_string":"ネットスーパー (Internet Shopping)"}',
50 '... got the right JSON');
52 my $foo2 = Foo->thaw($json);
53 isa_ok( $foo, 'Foo' );
55 is($foo2->utf8_string,
56 "ネットスーパー (Internet Shopping)",
57 '... got the string we expected');
60 '{"__CLASS__":"Foo","utf8_string":"ネットスーパー (Internet Shopping)"}',
61 '... got the right JSON');
68 $test_string = "ネットスーパー (Internet Shopping)";
72 ok(utf8::is_utf8($test_string), '... got a utf8 string');
73 ok(utf8::valid($test_string), '... got a valid utf8 string');
75 Encode::_utf8_off($test_string);
77 ok(!utf8::is_utf8($test_string), '... no longer is utf8 string');
78 ok(utf8::valid($test_string), '... got a valid utf8 string');
81 utf8_string => $test_string
83 isa_ok( $foo, 'Foo' );
85 ok(!utf8::is_utf8($foo->utf8_string), '... not a utf8 string');
86 ok(utf8::valid($foo->utf8_string), '... but is a valid utf8 string');
88 my $json = $foo->freeze;
90 ok(utf8::is_utf8($json), '... is a utf8 string now');
91 ok(utf8::valid($json), '... got a valid utf8 string');
94 '{"__CLASS__":"Foo","utf8_string":"ネットスーパー (Internet Shopping)"}',
95 '... got the right JSON');