my $meta = find_meta($class_or_obj);
return unless defined $meta;
-
+ return unless $meta->can('does_role');
return 1 if $meta->does_role($role);
return;
}
use strict;
use warnings;
-use Test::More tests => 7;
+use Test::More tests => 8;
BEGIN {
use_ok('Moose::Util', ':all');
use Moose;
}
+{
+ package Quux;
+
+ use metaclass;
+}
+
+{
+ package Foo::Foo;
+
+ use Moose::Role;
+
+ with 'Foo';
+}
+
# Classes
ok(does_role('Bar', 'Foo'), '... Bar does Foo');
ok(!does_role(undef,'Foo'), '... undef doesnt do Foo');
ok(!does_role(1,'Foo'), '... 1 doesnt do Foo');
+
+# non Moose metaclass
+
+ok(!does_role('Quux', 'Foo'), '... Quux doesnt do Foo (does not die tho)');
+
+# TODO: make the below work, maybe?
+
+# Self
+
+#ok(does_role('Foo', 'Foo'), '... Foo does do Foo');
+
+# sub-Roles
+
+#ok(does_role('Foo::Foo', 'Foo'), '... Foo::Foo does do Foo');
+