merge trunk to pluggable errors
[gitmo/Moose.git] / t / 000_recipes / basics / 002_bank_account.t
similarity index 74%
rename from t/000_recipes/002_bank_account.t
rename to t/000_recipes/basics/002_bank_account.t
index 4e0b571..ff318cc 100644 (file)
@@ -3,51 +3,49 @@
 use strict;
 use warnings;
 
-use Test::More tests => 24;
+use Test::More tests => 23;
 use Test::Exception;
 
-BEGIN {
-    use_ok('Moose');           
-}
-
 {
     package BankAccount;
     use Moose;
-    
-    has 'balance' => (isa => 'Num', is => 'rw', default => 0);
+
+    has 'balance' => ( isa => 'Num', is => 'rw', default => 0 );
 
     sub deposit {
-        my ($self, $amount) = @_;
-        $self->balance($self->balance + $amount);
+        my ( $self, $amount ) = @_;
+        $self->balance( $self->balance + $amount );
     }
-    
+
     sub withdraw {
-        my ($self, $amount) = @_;
+        my ( $self, $amount ) = @_;
         my $current_balance = $self->balance();
-        ($current_balance >= $amount)
+        ( $current_balance >= $amount )
             || confess "Account overdrawn";
-        $self->balance($current_balance - $amount);
+        $self->balance( $current_balance - $amount );
     }
-    
-       __PACKAGE__->meta->make_immutable(debug => 0);
-}{
-       package CheckingAccount;        
-       use Moose;
-
-       extends 'BankAccount';
-       
-    has 'overdraft_account' => (isa => 'BankAccount', is => 'rw');     
-
-       before 'withdraw' => sub {
-               my ($self, $amount) = @_;
-               my $overdraft_amount = $amount - $self->balance();
-               if ($self->overdraft_account && $overdraft_amount > 0) {
-                       $self->overdraft_account->withdraw($overdraft_amount);
-                       $self->deposit($overdraft_amount);
-               }
-       };
-
-       __PACKAGE__->meta->make_immutable(debug => 0);
+
+    __PACKAGE__->meta->make_immutable( debug => 0 );
+}
+
+{
+    package CheckingAccount;
+    use Moose;
+
+    extends 'BankAccount';
+
+    has 'overdraft_account' => ( isa => 'BankAccount', is => 'rw' );
+
+    before 'withdraw' => sub {
+        my ( $self, $amount ) = @_;
+        my $overdraft_amount = $amount - $self->balance();
+        if ( $self->overdraft_account && $overdraft_amount > 0 ) {
+            $self->overdraft_account->withdraw($overdraft_amount);
+            $self->deposit($overdraft_amount);
+        }
+    };
+
+    __PACKAGE__->meta->make_immutable( debug => 0 );
 }
 
 my $savings_account = BankAccount->new(balance => 250);