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 Moose::Meta::Class->create( 'MyClass', roles => ['MyRole'] );
45 'named class with roles is leak-free'
50 Moose::Meta::Role->create( 'MyRole2', roles => ['MyRole'] );
52 'named role with roles is leak-free'
57 my $object = Moose::Meta::Class->create('MyClass2')->new_object;
58 apply_all_roles( $object, 'MyRole' );
60 'applying role to an instance is leak-free'
65 Moose::Meta::Role->create_anon_role;
67 'anonymous role is leak-free'
71 # fixing this leak currently triggers a bug in Carp
72 # we can un-TODO once that fix goes in allowing the leak
73 # in Eval::Closure to be fixed
74 local $TODO = 'Eval::Closure leaks a bit at the moment';
77 my $meta = Moose::Meta::Class->create_anon_class;
78 $meta->make_immutable;
80 'making an anon class immutable is leak-free'
85 my $meta3 = Moose::Meta::Class->create('MyClass3');
86 memory_cycle_ok( $meta3, 'named metaclass object is cycle-free' );
87 memory_cycle_ok( $meta3->new_object, 'MyClass3 object is cycle-free' );
89 my $anon_class = Moose::Meta::Class->create_anon_class;
90 memory_cycle_ok($anon_class, 'anon metaclass object is cycle-free' );
91 memory_cycle_ok( $anon_class->new_object, 'object from anon metaclass is cycle-free' );
93 $anon_class->make_immutable;
94 memory_cycle_ok($anon_class, 'immutable anon metaclass object is cycle-free' );
95 memory_cycle_ok( $anon_class->new_object, 'object from immutable anon metaclass is cycle-free' );
97 my $anon_role = Moose::Meta::Role->create_anon_role;
98 memory_cycle_ok($anon_role, 'anon role meta object is cycle-free' );