5 'Test::LeakTrace' => '0.01',
6 'Test::Memory::Cycle' => '0',
12 use Moose::Util qw( apply_all_roles );
17 sub myname { "I'm a role" }
22 Moose::Meta::Class->create_anon_class->new_object;
24 'anonymous class with no roles is leak-free'
29 Moose::Meta::Role->initialize('MyRole2');
31 'Moose::Meta::Role->initialize is leak-free'
36 Moose::Meta::Class->create('MyClass2')->new_object;
38 'creating named class is leak-free'
43 = 'role application leaks because we end up applying the role more than once to the meta object';
46 Moose::Meta::Class->create( 'MyClass', roles => ['MyRole'] );
48 'named class with roles is leak-free'
53 Moose::Meta::Role->create( 'MyRole2', roles => ['MyRole'] );
55 'named role with roles is leak-free'
61 my $object = Moose::Meta::Class->create('MyClass2')->new_object;
62 apply_all_roles( $object, 'MyRole' );
64 'applying role to an instance is leak-free'
69 Moose::Meta::Role->create_anon_role;
71 'anonymous role is leak-free'
75 # fixing this leak currently triggers a bug in Carp
76 # we can un-TODO once that fix goes in allowing the leak
77 # in Eval::Closure to be fixed
78 local $TODO = 'Eval::Closure leaks a bit at the moment';
81 my $meta = Moose::Meta::Class->create_anon_class;
82 $meta->make_immutable;
84 'making an anon class immutable is leak-free'
89 my $meta3 = Moose::Meta::Class->create('MyClass3');
90 memory_cycle_ok( $meta3, 'named metaclass object is cycle-free' );
91 memory_cycle_ok( $meta3->new_object, 'MyClass3 object is cycle-free' );
93 my $anon_class = Moose::Meta::Class->create_anon_class;
94 memory_cycle_ok($anon_class, 'anon metaclass object is cycle-free' );
95 memory_cycle_ok( $anon_class->new_object, 'object from anon metaclass is cycle-free' );
97 $anon_class->make_immutable;
98 memory_cycle_ok($anon_class, 'immutable anon metaclass object is cycle-free' );
99 memory_cycle_ok( $anon_class->new_object, 'object from immutable anon metaclass is cycle-free' );
101 my $anon_role = Moose::Meta::Role->create_anon_role;
102 memory_cycle_ok($anon_role, 'anon role meta object is cycle-free' );