Require Dist::Zilla 4.200016+
[gitmo/Moose.git] / t / roles / reinitialize_anon_role.t
CommitLineData
082256d0 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More;
5
6{
7 package Role::Metarole;
8 use Moose::Role;
9}
10
11my ($role2);
12{
13 my $role1 = Moose::Meta::Role->create_anon_role(
14 methods => {
15 foo => sub { },
16 },
17 );
18 ok($role1->has_method('foo'), "role has method foo");
19 $role2 = Moose::Util::MetaRole::apply_metaroles(
20 for => $role1->name,
21 role_metaroles => { role => ['Role::Metarole'] },
22 );
23 isnt($role1, $role2, "anon role was reinitialized");
24 is($role1->name, $role2->name, "but it's the same anon role");
25 is_deeply([sort $role2->get_method_list], ['foo', 'meta'],
26 "has the right methods");
27}
28is_deeply([sort $role2->get_method_list], ['foo', 'meta'],
29 "still has the right methods");
30
31done_testing;