Fix type constraint issue
[gitmo/Mouse.git] / t / 019-handles.t
index 03797d6..10acf1e 100644 (file)
@@ -1,7 +1,8 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 24;
+use Test::More tests => 28;
+use Test::Exception;
 
 do {
     package Person;
@@ -117,3 +118,30 @@ is_deeply(
     "correct handles layout for 'person'",
 );
 
+
+{
+    local $TODO = "failed in 5.10.1, but I don't know why (gfx)" if $] == 5.010_001;
+    throws_ok{
+        $object->person(undef);
+        $object->person_name();
+    } qr/Cannot delegate person_name to name because the value of person is not defined/;
+
+    throws_ok{
+        $object->person([]);
+        $object->person_age();
+    } qr/Cannot delegate person_age to age because the value of person is not an object/;
+}
+
+eval{
+    $object->person(undef);
+    $object->person_name();
+};
+like $@, qr/Cannot delegate person_name to name because the value of person is not defined/;
+
+eval{
+    $object->person([]);
+    $object->person_age();
+};
+like $@, qr/Cannot delegate person_age to age because the value of person is not an object/;
+
+