4 use Test::More tests => 13;
9 use_ok('MooseX::Storage');
20 metaclass => 'DoNotSerialize',
22 default => sub { 'BAR' }
26 traits => [ 'DoNotSerialize' ],
28 default => sub { 'BAZ' }
33 default => sub { 'GORCH' }
42 is($foo->bar, 'BAR', '... got the value we expected');
43 is($foo->baz, 'BAZ', '... got the value we expected');
44 is($foo->gorch, 'GORCH', '... got the value we expected');
52 '... got the right packed class data'
56 ### more involved test; required attribute that's not serialized
64 metaclass => 'DoNotSerialize',
67 isa => 'Object', # type constraint is important
71 default => sub { $$ },
77 my $bar = Bar->new( foo => $obj );
79 ok( $bar, "New object created" );
80 is( $bar->foo, $obj, " ->foo => $obj" );
81 is( $bar->zot, $$, " ->zot => $$" );
83 my $bpack = $bar->pack;
88 }, " Packed correctly" );
90 eval { Bar->unpack( $bpack ) };
91 ok( $@, " Unpack without required attribute fails" );
92 like( $@, qr/foo/, " Proper error recorded" );
94 my $bar2 = Bar->unpack( $bpack, inject => { foo => bless {} } );
95 ok( $bar2, " Unpacked correctly with foo => Object");