From: Karen Etheridge Date: Wed, 11 Aug 2010 19:35:04 +0000 (-0700) Subject: add native hash attribute tests to confirm that set will always return the value... X-Git-Tag: 1.10~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ea8529e40a6f5301ab04c7bcd2b1f33a2f38b78c;p=gitmo%2FMoose.git add native hash attribute tests to confirm that set will always return the value(s) stored in the hash --- diff --git a/t/070_native_traits/203_trait_hash.t b/t/070_native_traits/203_trait_hash.t index 1b621b5..a4d4b38 100644 --- a/t/070_native_traits/203_trait_hash.t +++ b/t/070_native_traits/203_trait_hash.t @@ -55,10 +55,12 @@ is( $stuff->num_options, 0, '... we have no options' ); is_deeply( $stuff->options, {}, '... no options yet' ); ok( !$stuff->has_option('foo'), '... we have no foo option' ); +my $set_result; lives_ok { - $stuff->set_option( foo => 'bar' ); + $set_result = $stuff->set_option( foo => 'bar' ); } '... set the option okay'; +is($set_result, 'bar', '... returns value set'); ok( $stuff->is_defined('foo'), '... foo is defined' ); @@ -68,9 +70,10 @@ ok( $stuff->has_option('foo'), '... we have a foo option' ); is_deeply( $stuff->options, { foo => 'bar' }, '... got options now' ); lives_ok { - $stuff->set_option( bar => 'baz' ); + $set_result = $stuff->set_option( bar => 'baz' ); } '... set the option okay'; +is($set_result, 'baz', '... returns value set'); is( $stuff->num_options, 2, '... we have 2 option(s)' ); is_deeply( $stuff->options, { foo => 'bar', bar => 'baz' }, @@ -84,10 +87,12 @@ is_deeply( [ $stuff->get_option(qw(foo bar)) ], [qw(bar baz)], is( scalar($stuff->get_option(qw( foo bar) )), "baz", '... got last option in scalar context'); +my @set_return; lives_ok { - $stuff->set_option( oink => "blah", xxy => "flop" ); + @set_return = $stuff->set_option( oink => "blah", xxy => "flop" ); } '... set the option okay'; +is_deeply(\@set_return, [ qw(blah flop) ], '... and returns values set'); is( $stuff->num_options, 4, "4 options" ); is_deeply( [ $stuff->get_option(qw(foo bar oink xxy)) ],