6 use File::Temp qw(tempdir);
8 use File::Spec::Functions;
13 'JSON::Any' => 0.01, # skip all if not installed
18 use_ok('MooseX::Storage');
31 has 'number' => (is => 'ro', isa => 'Int');
32 has 'string' => (is => 'ro', isa => 'Str');
33 has 'float' => (is => 'ro', isa => 'Num');
34 has 'array' => (is => 'ro', isa => 'ArrayRef');
35 has 'hash' => (is => 'ro', isa => 'HashRef');
36 has 'object' => (is => 'ro', isa => 'Object');
39 my $file = catfile($dir, 'temp.json');
47 hash => { map { $_ => undef } (1 .. 10) },
48 object => Foo->new( number => 2 ),
56 my $foo = Foo->load($file);
59 is($foo->number, 10, '... got the right number');
60 is($foo->string, 'foo', '... got the right string');
61 is($foo->float, 10.5, '... got the right float');
62 cmp_deeply($foo->array, [ 1 .. 10], '... got the right array');
63 cmp_deeply($foo->hash, { map { $_ => undef } (1 .. 10) }, '... got the right hash');
65 isa_ok($foo->object, 'Foo');
66 is($foo->object->number, 2, '... got the right number (in the embedded object)');