X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F003_basic_hash.t;h=5f29544b23424d6d7b4683adccd5c17a7f5ab633;hb=2d1a76d7e09a43ce4010a0b6251d31446d8efeff;hp=24a6b3fd473ed0cd0c2ffac26b1fb446c888a4b1;hpb=05f7da43b612f6c35c40227fa84a0a970c442ab1;p=gitmo%2FMooseX-AttributeHelpers.git diff --git a/t/003_basic_hash.t b/t/003_basic_hash.t index 24a6b3f..5f29544 100644 --- a/t/003_basic_hash.t +++ b/t/003_basic_hash.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 32; +use Test::More tests => 37; use Test::Exception; BEGIN { @@ -27,6 +27,11 @@ BEGIN { 'count' => 'num_options', 'clear' => 'clear_options', 'delete' => 'delete_option', + }, + curries => { + 'set' => { + set_quantity => ['quantity'] + }, } ); } @@ -94,6 +99,12 @@ $stuff->clear_options; is_deeply($stuff->options, { }, "... cleared options" ); lives_ok { + $stuff->set_quantity(4); +} '... options added okay with defaults'; + +is_deeply($stuff->options, {quantity => 4}); + +lives_ok { Stuff->new(options => { foo => 'BAR' }); } '... good constructor params'; @@ -107,4 +118,18 @@ dies_ok { Stuff->new(options => { foo => [] }); } '... bad constructor params'; +## test the meta + +my $options = $stuff->meta->get_attribute('options'); +isa_ok($options, 'MooseX::AttributeHelpers::Collection::Hash'); + +is_deeply($options->provides, { + 'set' => 'set_option', + 'get' => 'get_option', + 'empty' => 'has_options', + 'count' => 'num_options', + 'clear' => 'clear_options', + 'delete' => 'delete_option', +}, '... got the right provies mapping'); +is($options->type_constraint->type_parameter, 'Str', '... got the right container type');