Commit | Line | Data |
7a50b450 |
1 | #!/usr/bin/env perl |
fde8e43f |
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; |
7a50b450 |
5 | use strict; |
6 | use warnings; |
fde8e43f |
7 | use Test::More; |
8 | use Mouse (); |
7a50b450 |
9 | use Scalar::Util 'weaken'; |
10 | |
11 | my $weak; |
12 | my $name; |
13 | do { |
14 | my $anon_class; |
15 | |
16 | do { |
17 | my $role = Mouse::Meta::Role->create_anon_role( |
18 | methods => { |
19 | improperly_freed => sub { 1 }, |
20 | }, |
21 | ); |
22 | weaken($weak = $role); |
23 | |
24 | $name = $role->name; |
25 | |
26 | $anon_class = Mouse::Meta::Class->create_anon_class( |
27 | roles => [ $role->name ], |
28 | ); |
29 | }; |
30 | |
31 | ok($weak, "we still have the role metaclass because the anonymous class that consumed it is still alive"); |
32 | ok($name->can('improperly_freed'), "we have not blown away the role's symbol table"); |
33 | }; |
34 | |
35 | ok(!$weak, "the role metaclass is freed after its last reference (from a consuming anonymous class) is freed"); |
36 | |
37 | ok(!$name->can('improperly_freed'), "we blew away the role's symbol table entries"); |
fde8e43f |
38 | |
39 | done_testing; |