Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 050_metaclasses / 051_metarole_on_anon.t
CommitLineData
6475f69d 1use strict;
6217087a 2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
6475f69d 5use warnings;
6
7use Test::More;
8use Test::Exception;
9
10use Mouse ();
11use Mouse::Meta::Class;
12use Mouse::Util::MetaRole;
13
14{
15 package Foo;
16 use Mouse;
17}
18
19{
20 package Role::Bar;
21 use Mouse::Role;
22}
23
24my $anon_name;
25
26{
27 my $anon_class = Mouse::Meta::Class->create_anon_class(
28 superclasses => ['Foo'],
29 cache => 1,
30 );
31
32 $anon_name = $anon_class->name;
33
34 ok( $anon_name->meta, 'anon class has a metaclass' );
35}
36
37ok(
38 $anon_name->meta,
39 'cached anon class still has a metaclass after \$anon_class goes out of scope'
40);
41
42Mouse::Util::MetaRole::apply_metaroles(
43 for => $anon_name,
44 class_metaroles => {
45 class => ['Role::Bar'],
46 },
47);
48
49BAIL_OUT('Cannot continue if the anon class does not have a metaclass')
50 unless $anon_name->can('meta');
51
52my $meta = $anon_name->meta;
53ok( $meta, 'cached anon class still has a metaclass applying a metarole' );
54
55done_testing;