5 use Test::More tests => 11;
10 use_ok('MooseX::Storage');
19 with Storage( 'format' => 'Storable' );
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' );
35 hash => { map { $_ => undef } ( 1 .. 10 ) },
36 object => Foo->new( number => 2 ),
38 isa_ok( $foo, 'Foo' );
40 my $stored = $foo->freeze;
42 my $struct = Storable::thaw($stored);
50 'array' => [ 1 .. 10],
51 'hash' => { map { $_ => undef } 1 .. 10 },
57 '... got the data struct we expected'
62 my $stored = Storable::nfreeze({
67 'array' => [ 1 .. 10],
68 'hash' => { map { $_ => undef } 1 .. 10 },
75 my $foo = Foo->thaw($stored);
76 isa_ok( $foo, 'Foo' );
78 is( $foo->number, 10, '... got the right number' );
79 is( $foo->string, 'foo', '... got the right string' );
80 is( $foo->float, 10.5, '... got the right float' );
81 cmp_deeply( $foo->array, [ 1 .. 10 ], '... got the right array' );
84 { map { $_ => undef } ( 1 .. 10 ) },
85 '... got the right hash'
88 isa_ok( $foo->object, 'Foo' );
89 is( $foo->object->number, 2,
90 '... got the right number (in the embedded object)' );