got rid of all the use_ok junk except for 000_load.t
[gitmo/Class-MOP.git] / t / 017_add_method_modifier.t
index 7ac25f6..079d921 100644 (file)
@@ -3,12 +3,10 @@
 use strict;
 use warnings;
 
-use Test::More tests => 17;
+use Test::More tests => 19;
 use Test::Exception;
 
-BEGIN {
-    use_ok('Class::MOP');
-}
+use Class::MOP;
 
 {
     package BankAccount;
@@ -19,7 +17,7 @@ BEGIN {
         
     use Carp 'confess';
     
-    BankAccount->meta->add_attribute('$:balance' => (
+    BankAccount->meta->add_attribute('balance' => (
         accessor => 'balance',
                init_arg => 'balance',
         default  => 0
@@ -48,7 +46,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 +61,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 +74,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');