Revert "convert all uses of Test::Exception to Test::Fatal."
[gitmo/Class-MOP.git] / t / 017_add_method_modifier.t
index 753e2ca..a9c7945 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 19;
+use Test::More;
 use Test::Exception;
 
 use Class::MOP;
@@ -65,12 +65,25 @@ use Class::MOP;
         }
     );
 
+    ::throws_ok(
+        sub {
+            CheckingAccount->meta->add_before_method_modifier(
+                'does_not_exist' => sub { } );
+        },
+        qr/\QThe method 'does_not_exist' was not found in the inheritance hierarchy for CheckingAccount/
+    );
+
     ::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' );
+
+    CheckingAccount->meta->add_method( foo => sub { 'foo' } );
+    CheckingAccount->meta->add_before_method_modifier( foo => sub { 'wrapped' } );
+    ::isa_ok( CheckingAccount->meta->get_method('foo'),
+        'Class::MOP::Method::Wrapped' );
 }
 
 my $savings_account = BankAccount->new( balance => 250 );
@@ -82,7 +95,7 @@ lives_ok {
 }
 '... withdrew from savings successfully';
 is( $savings_account->balance, 200,
-    '... got the right savings balance after withdrawl' );
+    '... got the right savings balance after withdrawal' );
 dies_ok {
     $savings_account->withdraw(250);
 }
@@ -109,9 +122,9 @@ lives_ok {
 }
 '... withdrew from checking successfully';
 is( $checking_account->balance, 50,
-    '... got the right checkings balance after withdrawl' );
+    '... got the right checkings balance after withdrawal' );
 is( $savings_account->balance, 350,
-    '... got the right savings balance after checking withdrawl (no overdraft)'
+    '... got the right savings balance after checking withdrawal (no overdraft)'
 );
 
 lives_ok {
@@ -119,7 +132,8 @@ lives_ok {
 }
 '... withdrew from checking successfully';
 is( $checking_account->balance, 0,
-    '... got the right checkings balance after withdrawl' );
+    '... got the right checkings balance after withdrawal' );
 is( $savings_account->balance, 200,
-    '... got the right savings balance after overdraft withdrawl' );
+    '... got the right savings balance after overdraft withdrawal' );
 
+done_testing;