4 use Test::More tests => 10;
6 use File::Temp qw(tempdir);
7 use File::Spec::Functions;
8 my $dir = tempdir( CLEANUP => 1 );
11 use_ok('MooseX::Storage');
19 with Storage(io => 'StorableFile');
21 has 'number' => (is => 'ro', isa => 'Int');
22 has 'string' => (is => 'ro', isa => 'Str');
23 has 'float' => (is => 'ro', isa => 'Num');
24 has 'array' => (is => 'ro', isa => 'ArrayRef');
25 has 'hash' => (is => 'ro', isa => 'HashRef');
26 has 'object' => (is => 'ro', isa => 'Object');
29 my $file = catfile($dir,'temp.storable');
37 hash => { map { $_ => undef } (1 .. 10) },
38 object => Foo->new( number => 2 ),
46 my $foo = Foo->load($file);
49 is($foo->number, 10, '... got the right number');
50 is($foo->string, 'foo', '... got the right string');
51 is($foo->float, 10.5, '... got the right float');
52 cmp_deeply($foo->array, [ 1 .. 10], '... got the right array');
53 cmp_deeply($foo->hash, { map { $_ => undef } (1 .. 10) }, '... got the right hash');
55 isa_ok($foo->object, 'Foo');
56 is($foo->object->number, 2, '... got the right number (in the embedded object)');