Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 900_mouse_bugs / 008_RT56837.t
1 #!perl
2 # This test is contributed by Sanko Robinson.
3 # https://rt.cpan.org/Public/Bug/Display.html?id=56837
4 # "Role application to instance with init_arg'd attributes"
5 use strict;
6 use Test::More tests => 2;
7
8 {
9     package Admin;
10     use Mouse::Role;
11     sub shutdown {1}
12 }
13 {
14     package User;
15     use Mouse;
16     has 'name' =>
17         (isa => 'Str', is => 'ro', init_arg => 'Name', required => 1);
18 }
19
20 package main;
21 my $tim = User->new(Name => 'Tim');
22
23 Admin->meta->apply($tim);
24
25 ok($tim->can('shutdown'),
26     'The role was successfully composed at the object level');
27 is($tim->name, 'Tim',
28     '... attribute with init_arg was re-initialized correctly');