Commit | Line | Data |
6475f69d |
1 | use strict; |
6217087a |
2 | # This is automatically generated by author/import-moose-test.pl. |
3 | # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! |
4 | use t::lib::MooseCompat; |
6475f69d |
5 | use warnings; |
6 | |
7 | use Test::More; |
8 | use Test::Exception; |
9 | |
10 | use Mouse (); |
11 | use Mouse::Meta::Class; |
12 | use Mouse::Util::MetaRole; |
13 | |
14 | { |
15 | package Foo; |
16 | use Mouse; |
17 | } |
18 | |
19 | { |
20 | package Role::Bar; |
21 | use Mouse::Role; |
22 | } |
23 | |
24 | my $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 | |
37 | ok( |
38 | $anon_name->meta, |
39 | 'cached anon class still has a metaclass after \$anon_class goes out of scope' |
40 | ); |
41 | |
42 | Mouse::Util::MetaRole::apply_metaroles( |
43 | for => $anon_name, |
44 | class_metaroles => { |
45 | class => ['Role::Bar'], |
46 | }, |
47 | ); |
48 | |
49 | BAIL_OUT('Cannot continue if the anon class does not have a metaclass') |
50 | unless $anon_name->can('meta'); |
51 | |
52 | my $meta = $anon_name->meta; |
53 | ok( $meta, 'cached anon class still has a metaclass applying a metarole' ); |
54 | |
55 | done_testing; |