6 use Test::More tests => 11;
11 use_ok('MooseX::Storage');
20 with Storage( 'format' => 'Storable' );
22 has 'number' => ( is => 'ro', isa => 'Int' );
23 has 'string' => ( is => 'ro', isa => 'Str' );
24 has 'float' => ( is => 'ro', isa => 'Num' );
25 has 'array' => ( is => 'ro', isa => 'ArrayRef' );
26 has 'hash' => ( is => 'ro', isa => 'HashRef' );
27 has 'object' => ( is => 'ro', isa => 'Object' );
36 hash => { map { $_ => undef } ( 1 .. 10 ) },
37 object => Foo->new( number => 2 ),
39 isa_ok( $foo, 'Foo' );
41 my $stored = $foo->freeze;
43 my $struct = Storable::thaw($stored);
51 'array' => [ 1 .. 10],
52 'hash' => { map { $_ => undef } 1 .. 10 },
58 '... got the data struct we expected'
63 my $stored = Storable::nfreeze({
68 'array' => [ 1 .. 10],
69 'hash' => { map { $_ => undef } 1 .. 10 },
76 my $foo = Foo->thaw($stored);
77 isa_ok( $foo, 'Foo' );
79 is( $foo->number, 10, '... got the right number' );
80 is( $foo->string, 'foo', '... got the right string' );
81 is( $foo->float, 10.5, '... got the right float' );
82 cmp_deeply( $foo->array, [ 1 .. 10 ], '... got the right array' );
85 { map { $_ => undef } ( 1 .. 10 ) },
86 '... got the right hash'
89 isa_ok( $foo->object, 'Foo' );
90 is( $foo->object->number, 2,
91 '... got the right number (in the embedded object)' );