9 use File::Spec::Functions;
15 plan skip_all => "JSON::Any is required for this test" if $@;
17 use_ok('MooseX::Storage');
30 has 'number' => (is => 'ro', isa => 'Int');
31 has 'string' => (is => 'ro', isa => 'Str');
32 has 'float' => (is => 'ro', isa => 'Num');
33 has 'array' => (is => 'ro', isa => 'ArrayRef');
34 has 'hash' => (is => 'ro', isa => 'HashRef');
35 has 'object' => (is => 'ro', isa => 'Object');
38 my $file = catfile($dir, 'temp.json');
46 hash => { map { $_ => undef } (1 .. 10) },
47 object => Foo->new( number => 2 ),
55 my $foo = Foo->load($file);
58 is($foo->number, 10, '... got the right number');
59 is($foo->string, 'foo', '... got the right string');
60 is($foo->float, 10.5, '... got the right float');
61 is_deeply($foo->array, [ 1 .. 10], '... got the right array');
62 is_deeply($foo->hash, { map { $_ => undef } (1 .. 10) }, '... got the right hash');
64 isa_ok($foo->object, 'Foo');
65 is($foo->object->number, 2, '... got the right number (in the embedded object)');