8 use File::Temp qw(tempdir);
10 use File::Spec::Functions;
15 'JSON::Any' => 0.01, # skip all if not installed
20 use_ok('MooseX::Storage');
33 has 'number' => (is => 'ro', isa => 'Int');
34 has 'string' => (is => 'ro', isa => 'Str');
35 has 'float' => (is => 'ro', isa => 'Num');
36 has 'array' => (is => 'ro', isa => 'ArrayRef');
37 has 'hash' => (is => 'ro', isa => 'HashRef');
38 has 'object' => (is => 'ro', isa => 'Object');
41 my $file = catfile($dir, 'temp.json');
49 hash => { map { $_ => undef } (1 .. 10) },
50 object => Foo->new( number => 2 ),
58 my $foo = Foo->load($file);
61 is($foo->number, 10, '... got the right number');
62 is($foo->string, 'foo', '... got the right string');
63 is($foo->float, 10.5, '... got the right float');
64 cmp_deeply($foo->array, [ 1 .. 10], '... got the right array');
65 cmp_deeply($foo->hash, { map { $_ => undef } (1 .. 10) }, '... got the right hash');
67 isa_ok($foo->object, 'Foo');
68 is($foo->object->number, 2, '... got the right number (in the embedded object)');