Add tests for trying to delegate to a class or role which is not yet loaded
Dave Rolsky [Tue, 26 Oct 2010 21:11:49 +0000 (16:11 -0500)]
t/020_attributes/038_delegation_target_not_loaded.t [new file with mode: 0644]

diff --git a/t/020_attributes/038_delegation_target_not_loaded.t b/t/020_attributes/038_delegation_target_not_loaded.t
new file mode 100644 (file)
index 0000000..3938786
--- /dev/null
@@ -0,0 +1,35 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Fatal;
+
+{
+    package X;
+
+    use Moose;
+
+    ::like(
+        ::exception{ has foo => (
+                is      => 'ro',
+                isa     => 'Foo',
+                handles => qr/.*/,
+            )
+            },
+        qr/\QThe foo attribute is trying to delegate to a class which has not been loaded - Foo/,
+        'cannot delegate to a class which is not yet loaded'
+    );
+
+    ::like(
+        ::exception{ has foo => (
+                is      => 'ro',
+                does    => 'Role::Foo',
+                handles => qr/.*/,
+            )
+            },
+        qr/\QThe foo attribute is trying to delegate to a role which has not been loaded - Role::Foo/,
+        'cannot delegate to a role which is not yet loaded'
+    );
+}
+
+done_testing;