6 use Test::More tests => 13;
11 use_ok('MooseX::Storage');
22 metaclass => 'DoNotSerialize',
24 default => sub { 'BAR' }
28 traits => [ 'DoNotSerialize' ],
30 default => sub { 'BAZ' }
35 default => sub { 'GORCH' }
44 is($foo->bar, 'BAR', '... got the value we expected');
45 is($foo->baz, 'BAZ', '... got the value we expected');
46 is($foo->gorch, 'GORCH', '... got the value we expected');
54 '... got the right packed class data'
58 ### more involved test; required attribute that's not serialized
66 metaclass => 'DoNotSerialize',
69 isa => 'Object', # type constraint is important
73 default => sub { $$ },
79 my $bar = Bar->new( foo => $obj );
81 ok( $bar, "New object created" );
82 is( $bar->foo, $obj, " ->foo => $obj" );
83 is( $bar->zot, $$, " ->zot => $$" );
85 my $bpack = $bar->pack;
90 }, " Packed correctly" );
92 eval { Bar->unpack( $bpack ) };
93 ok( $@, " Unpack without required attribute fails" );
94 like( $@, qr/foo/, " Proper error recorded" );
96 my $bar2 = Bar->unpack( $bpack, inject => { foo => bless {} } );
97 ok( $bar2, " Unpacked correctly with foo => Object");