6 use Test::More tests => 13;
10 use_ok('MooseX::Storage');
21 metaclass => 'DoNotSerialize',
23 default => sub { 'BAR' }
27 traits => [ 'DoNotSerialize' ],
29 default => sub { 'BAZ' }
34 default => sub { 'GORCH' }
43 is($foo->bar, 'BAR', '... got the value we expected');
44 is($foo->baz, 'BAZ', '... got the value we expected');
45 is($foo->gorch, 'GORCH', '... got the value we expected');
53 '... got the right packed class data'
57 ### more involved test; required attribute that's not serialized
65 metaclass => 'DoNotSerialize',
68 isa => 'Object', # type constraint is important
72 default => sub { $$ },
78 my $bar = Bar->new( foo => $obj );
80 ok( $bar, "New object created" );
81 is( $bar->foo, $obj, " ->foo => $obj" );
82 is( $bar->zot, $$, " ->zot => $$" );
84 my $bpack = $bar->pack;
89 }, " Packed correctly" );
91 eval { Bar->unpack( $bpack ) };
92 ok( $@, " Unpack without required attribute fails" );
93 like( $@, qr/foo/, " Proper error recorded" );
95 my $bar2 = Bar->unpack( $bpack, inject => { foo => bless {} } );
96 ok( $bar2, " Unpacked correctly with foo => Object");