X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F001_basic_counter.t;h=b94c0a58b14d955d50618770097978fbd66c2eda;hb=4a35a0ad2542b236a6ea02022d55c4193a58a321;hp=5430d449753d87e7ec03364057803984af01290d;hpb=69dde336792f25d5ed7d0a47d237a5382b4593a9;p=gitmo%2FMooseX-AttributeHelpers.git diff --git a/t/001_basic_counter.t b/t/001_basic_counter.t index 5430d44..b94c0a5 100644 --- a/t/001_basic_counter.t +++ b/t/001_basic_counter.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More no_plan => 1; +use Test::More tests => 18; BEGIN { use_ok('MooseX::AttributeHelpers'); @@ -19,8 +19,10 @@ BEGIN { isa => 'Int', default => sub { 0 }, provides => { - inc => 'inc_counter', - dec => 'dec_counter', + inc => 'inc_counter', + dec => 'dec_counter', + reset => 'reset_counter', + set => 'set_counter' } ); } @@ -31,6 +33,8 @@ isa_ok($page, 'MyHomePage'); can_ok($page, $_) for qw[ dec_counter inc_counter + reset_counter + set_counter ]; is($page->counter, 0, '... got the default value'); @@ -44,6 +48,18 @@ is($page->counter, 2, '... got the incremented value (again)'); $page->dec_counter; is($page->counter, 1, '... got the decremented value'); +$page->reset_counter; +is($page->counter, 0, '... got the original value'); + +$page->set_counter(5); +is($page->counter, 5, '... set the value'); + +$page->inc_counter(2); +is($page->counter, 7, '... increment by arg'); + +$page->dec_counter(5); +is($page->counter, 2, '... decrement by arg'); + # check the meta .. my $counter = $page->meta->get_attribute('counter'); @@ -54,7 +70,9 @@ is($counter->helper_type, 'Num', '... got the expected helper type'); is($counter->type_constraint->name, 'Int', '... got the expected type constraint'); is_deeply($counter->provides, { - inc => 'inc_counter', - dec => 'dec_counter', + inc => 'inc_counter', + dec => 'dec_counter', + reset => 'reset_counter', + set => 'set_counter' }, '... got the right provides methods');