X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F017_add_method_modifier.t;h=e2e44222f4445dd8c1c1a71827f367671be473ba;hb=2607a7f5facebe68cf85e493f86fa7eed58eeb05;hp=7ac25f6b20a5e79d4eaf167e9d4d55c56e8dd56d;hpb=96ceced87583646c1396bba4fdfa92d0b6c37058;p=gitmo%2FClass-MOP.git diff --git a/t/017_add_method_modifier.t b/t/017_add_method_modifier.t index 7ac25f6..e2e4422 100644 --- a/t/017_add_method_modifier.t +++ b/t/017_add_method_modifier.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 17; +use Test::More tests => 20; use Test::Exception; BEGIN { @@ -19,7 +19,7 @@ BEGIN { use Carp 'confess'; - BankAccount->meta->add_attribute('$:balance' => ( + BankAccount->meta->add_attribute('balance' => ( accessor => 'balance', init_arg => 'balance', default => 0 @@ -48,7 +48,7 @@ BEGIN { use base 'BankAccount'; - CheckingAccount->meta->add_attribute('$:overdraft_account' => ( + CheckingAccount->meta->add_attribute('overdraft_account' => ( accessor => 'overdraft_account', init_arg => 'overdraft', )); @@ -63,6 +63,8 @@ BEGIN { }); ::ok(CheckingAccount->meta->has_method('withdraw'), '... checking account now has a withdraw method'); + ::isa_ok(CheckingAccount->meta->get_method('withdraw'), 'Class::MOP::Method::Wrapped'); + ::isa_ok(BankAccount->meta->get_method('withdraw'), 'Class::MOP::Method'); } @@ -74,6 +76,10 @@ lives_ok { $savings_account->withdraw(50); } '... withdrew from savings successfully'; is($savings_account->balance, 200, '... got the right savings balance after withdrawl'); +dies_ok { + $savings_account->withdraw(250); +} '... could not withdraw from savings successfully'; + $savings_account->deposit(150); is($savings_account->balance, 350, '... got the right savings balance after deposit');