Don't call ->does_role on meta object until we know it has that method
[gitmo/moose-presentations.git] / moose-class / exercises / t / lib / MooseClass / Tests.pm
index d5a86bf..c3a333a 100644 (file)
@@ -30,6 +30,9 @@ sub tests01 {
 
     no_droppings('Person');
     is_immutable('Person');
+
+    no_droppings('Employee');
+    is_immutable('Employee');
 }
 
 sub tests02 {
@@ -325,7 +328,8 @@ sub tests06 {
     }
 
     ok(
-        $history_attr->meta()
+        $history_attr->meta()->can('does_role')
+            && $history_attr->meta()
             ->does_role('Moose::Meta::Attribute::Native::Trait::Array'),
         'BankAccount history attribute uses native delegation to an array ref'
     );
@@ -669,9 +673,17 @@ sub employee03 {
 }
 
 sub person06 {
+    my $account = BankAccount->new();
+
     my $person = Person->new(
         first_name => 'Bilbo',
         last_name  => 'Baggins',
+        account    => $account,
+    );
+
+    is(
+        $person->account, $account,
+        'account object passed to Person->new is still in object'
     );
 
     isa_ok( $person->account, 'BankAccount' );