10 plan skip_all => "Encode is required for this test" if $@;
12 plan skip_all => "JSON::Any is required for this test" if $@;
14 # this is because JSON::XS is
15 # the only one which really gets
19 $ENV{JSON_ANY_ORDER} = qw(XS);
20 $ENV{JSON_ANY_CONFIG} = "utf8=1";
23 use_ok('MooseX::Storage');
31 with Storage( 'format' => 'JSON' );
33 has 'utf8_string' => (
36 default => sub { "ネットスーパー (Internet Shopping)" }
42 isa_ok( $foo, 'Foo' );
44 my $json = $foo->freeze;
47 '{"__CLASS__":"Foo","utf8_string":"ネットスーパー (Internet Shopping)"}',
48 '... got the right JSON');
50 my $foo2 = Foo->thaw($json);
51 isa_ok( $foo, 'Foo' );
53 is($foo2->utf8_string,
54 "ネットスーパー (Internet Shopping)",
55 '... got the string we expected');
58 '{"__CLASS__":"Foo","utf8_string":"ネットスーパー (Internet Shopping)"}',
59 '... got the right JSON');
66 $test_string = "ネットスーパー (Internet Shopping)";
70 ok(utf8::is_utf8($test_string), '... got a utf8 string');
71 ok(utf8::valid($test_string), '... got a valid utf8 string');
73 Encode::_utf8_off($test_string);
75 ok(!utf8::is_utf8($test_string), '... no longer is utf8 string');
76 ok(utf8::valid($test_string), '... got a valid utf8 string');
79 utf8_string => $test_string
81 isa_ok( $foo, 'Foo' );
83 ok(!utf8::is_utf8($foo->utf8_string), '... not a utf8 string');
84 ok(utf8::valid($foo->utf8_string), '... but is a valid utf8 string');
86 my $json = $foo->freeze;
88 ok(utf8::is_utf8($json), '... is a utf8 string now');
89 ok(utf8::valid($json), '... got a valid utf8 string');
92 '{"__CLASS__":"Foo","utf8_string":"ネットスーパー (Internet Shopping)"}',
93 '... got the right JSON');