Changelogging
[gitmo/Mouse.git] / t / 030_roles / 036_free_anonymous_roles.t
CommitLineData
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!!!
4use t::lib::MooseCompat;
7a50b450 5use strict;
6use warnings;
fde8e43f 7use Test::More;
8use Mouse ();
7a50b450 9use Scalar::Util 'weaken';
10
11my $weak;
12my $name;
13do {
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
35ok(!$weak, "the role metaclass is freed after its last reference (from a consuming anonymous class) is freed");
36
37ok(!$name->can('improperly_freed'), "we blew away the role's symbol table entries");
fde8e43f 38
39done_testing;