From: Tokuhiro Matsuno Date: Mon, 13 Apr 2009 07:35:59 +0000 (+0900) Subject: bug fixed. test is very important things! X-Git-Tag: 0.22~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0d6273f0da76fefde1c6d84676f4af4c6161b02e;p=gitmo%2FMouse.git bug fixed. test is very important things! Klass->does_role should check the parent classes. --- diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index 9e55fa4..81fb0b0 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -309,7 +309,7 @@ sub does_role { for my $class ($self->linearized_isa) { next unless $class->can('meta') and $class->meta->can('roles'); - for my $role (@{ $self->roles }) { + for my $role (@{ $class->meta->roles }) { return 1 if $role->name eq $role_name; } } diff --git a/t/900_bug/002_does_role_should_search_parent.t b/t/900_bug/002_does_role_should_search_parent.t new file mode 100644 index 0000000..4dd1919 --- /dev/null +++ b/t/900_bug/002_does_role_should_search_parent.t @@ -0,0 +1,26 @@ +use strict; +use warnings; +use Test::More tests => 2; + +# Klass->does_role should check the parent classes. + +{ + package R1; + use Mouse::Role; +} + +{ + package C1; + use Mouse; + with 'R1'; +} + +{ + package C2; + use Mouse; + extends 'C1'; +} + +ok(C1->meta->does_role('R1')); +ok(C2->meta->does_role('R1')); +