From: Dave Rolsky Date: Sun, 19 Feb 2012 18:10:19 +0000 (-0600) Subject: Add tests for memory leaks X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=98f27a2f6851152bead79b7f1b665ec631a63440;p=gitmo%2FMoose.git Add tests for memory leaks Some of these tests are failing right now. --- diff --git a/t/bugs/memory_leaks.t b/t/bugs/memory_leaks.t new file mode 100644 index 0000000..ed3334a --- /dev/null +++ b/t/bugs/memory_leaks.t @@ -0,0 +1,63 @@ +use strict; +use warnings; + +use Test::Requires { + 'Test::LeakTrace' => '0.01', +}; + +use Test::More; + +use Moose; + +{ + package MyRole; + use Moose::Role; + sub myname { "I'm a role" } +} + +no_leaks_ok( + sub { + Moose::Meta::Class->create_anon_class->new_object; + }, + 'anonymous class with no roles is leak-free' +); + +no_leaks_ok( + sub { + Moose::Meta::Role->initialize('MyRole2'); + }, + 'Moose::Meta::Role->initialize is leak-free' +); + +no_leaks_ok( + sub { + Moose::Meta::Class->create('MyClass2')->new_object; + }, + 'creating named class is leak-free' +); + +no_leaks_ok( + sub { + Moose::Meta::Class->create( 'MyClass', roles => ['MyRole'] ) + ->new_object; + }, + 'named class with roles is leak-free' +); + +no_leaks_ok( + sub { + Moose::Meta::Role->create_anon_role; + }, + 'anonymous role is leak-free' +); + +no_leaks_ok( + sub { + my $meta = Moose::Meta::Class->create_anon_class; + $meta->make_immutable; + $meta->new_object; + }, + 'making an anon class immutable is leak-free' +); + +done_testing;