X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F008_do_not_serialize.t;h=0748c5dceae8cc4b591e0c2e301702c858b9116a;hb=2f3976d17c78e0ac58a7b318a57c90971ede5e4e;hp=27afeb16daa1841149899970aeb82472462f61ff;hpb=619ab942be0a8bd8f530c57ca5b0c8d833cdc89b;p=gitmo%2FMooseX-Storage.git diff --git a/t/008_do_not_serialize.t b/t/008_do_not_serialize.t index 27afeb1..0748c5d 100644 --- a/t/008_do_not_serialize.t +++ b/t/008_do_not_serialize.t @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings; @@ -21,30 +19,30 @@ BEGIN { has 'bar' => ( metaclass => 'DoNotSerialize', is => 'rw', - default => sub { 'BAR' } + default => sub { 'BAR' } ); - + has 'baz' => ( traits => [ 'DoNotSerialize' ], is => 'rw', - default => sub { 'BAZ' } - ); - + default => sub { 'BAZ' } + ); + has 'gorch' => ( - is => 'rw', + is => 'rw', default => sub { 'GORCH' } - ); + ); 1; } { my $foo = Foo->new; isa_ok($foo, 'Foo'); - + is($foo->bar, 'BAR', '... got the value we expected'); is($foo->baz, 'BAZ', '... got the value we expected'); is($foo->gorch, 'GORCH', '... got the value we expected'); - + cmp_deeply( $foo->pack, { @@ -68,36 +66,36 @@ BEGIN { is => 'rw', isa => 'Object', # type constraint is important ); - + has zot => ( default => sub { $$ }, is => 'rw', - ); + ); } { my $obj = bless {}; my $bar = Bar->new( foo => $obj ); - + ok( $bar, "New object created" ); is( $bar->foo, $obj, " ->foo => $obj" ); is( $bar->zot, $$, " ->zot => $$" ); - + my $bpack = $bar->pack; cmp_deeply( $bpack, { __CLASS__ => 'Bar', zot => $$, }, " Packed correctly" ); - + eval { Bar->unpack( $bpack ) }; ok( $@, " Unpack without required attribute fails" ); like( $@, qr/foo/, " Proper error recorded" ); - + my $bar2 = Bar->unpack( $bpack, inject => { foo => bless {} } ); - ok( $bar2, " Unpacked correctly with foo => Object"); -} - - - - + ok( $bar2, " Unpacked correctly with foo => Object"); +} + + + +