Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 900_mouse_bugs / 008_RT56837.t
CommitLineData
6c7491f2 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"
5use strict;
6use 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
20package main;
21my $tim = User->new(Name => 'Tim');
22
23Admin->meta->apply($tim);
24
25ok($tim->can('shutdown'),
26 'The role was successfully composed at the object level');
27is($tim->name, 'Tim',
28 '... attribute with init_arg was re-initialized correctly');