summaryrefslogtreecommitdiff
path: root/t/roles/reinitialize_anon_role.t
blob: 2554f2e30cad0828b93e1864ef4160a0aeff138a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use strict;
use warnings;
use Test::More;

{
    package Role::Metarole;
    use Moose::Role;
}

my ($role2);
{
    my $role1 = Moose::Meta::Role->create_anon_role(
        methods => {
            foo => sub { },
        },
    );
    ok($role1->has_method('foo'), "role has method foo");
    $role2 = Moose::Util::MetaRole::apply_metaroles(
        for => $role1->name,
        role_metaroles => { role => ['Role::Metarole'] },
    );
    isnt($role1, $role2, "anon role was reinitialized");
    is($role1->name, $role2->name, "but it's the same anon role");
    is_deeply([sort $role2->get_method_list], ['foo', 'meta'],
              "has the right methods");
}
is_deeply([sort $role2->get_method_list], ['foo', 'meta'],
          "still has the right methods");

done_testing;