From: Jos Boumans Date: Wed, 24 Jun 2009 12:11:08 +0000 (+0200) Subject: * add extra test to ensure restoring fails if required argument isn't provided X-Git-Tag: 0.20~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=335eb37774e94d72fe990375dd4fd647e6275395;p=gitmo%2FMooseX-Storage.git * add extra test to ensure restoring fails if required argument isn't provided --- diff --git a/t/008_do_not_serialize.t b/t/008_do_not_serialize.t index adc8e14..e0ff4b3 100644 --- a/t/008_do_not_serialize.t +++ b/t/008_do_not_serialize.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 11; +use Test::More tests => 13; use Test::Exception; BEGIN { @@ -65,6 +65,7 @@ BEGIN { metaclass => 'DoNotSerialize', required => 1, is => 'rw', + isa => 'Str', # type constraint is important ); has zot => ( @@ -86,8 +87,12 @@ BEGIN { zot => $$, }, " Packed correctly" ); + eval { Bar->unpack( $bpack ) }; + ok( $@, " Unpack without required attribute fails" ); + like( $@, qr/foo/, " Proper error recorded" ); + my $bar2 = Bar->unpack({ %$bpack, foo => $$ }); - ok( $bar2, " Unpacked correctly by supplying foo => $$"); + ok( $bar2, " Unpacked correctly with foo => $$"); }