From: gfx Date: Fri, 21 Aug 2009 09:00:36 +0000 (+0900) Subject: Add a test file for method generation testing X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b943fad7e2580b8892fe158f90702e45862101a0;p=gitmo%2FMoose.git Add a test file for method generation testing --- diff --git a/t/020_attributes/031_method_leak.t b/t/020_attributes/031_method_leak.t new file mode 100755 index 0000000..7ead624 --- /dev/null +++ b/t/020_attributes/031_method_leak.t @@ -0,0 +1,53 @@ +use strict; +use warnings; + +use Test::More; +#use Devel::Peek; + +BEGIN { + eval "use Test::LeakTrace;"; + plan skip_all => "Test::LeakTrace is required for this test" if $@; +} + +use Test::More tests => 5; +use Class::MOP; + +{ + package Foo; + use Moose; +} + + +my $expected = ($] == 5.010_000) ? 3 : 0; # for a bug on 5.10.0 + +leaks_cmp_ok { + my $meta = Foo->meta; + $meta->add_attribute(foo => (reader => 'foo')); + $meta->remove_attribute('foo'); +} '<=', $expected, 'add_attribute with reader and remove_attribute'; + +leaks_cmp_ok { + my $meta = Foo->meta; + $meta->add_attribute(foo => (writer => 'foo')); + $meta->remove_attribute('foo'); +} '<=', $expected, 'add_attribute with writer and remove_attribute'; + + +leaks_cmp_ok { + my $meta = Foo->meta; + $meta->add_attribute(foo => (accessor => 'foo')); + $meta->remove_attribute('foo'); +} '<=', $expected, 'add_attribute with accessor and remove_attribute'; + +leaks_cmp_ok { + my $meta = Foo->meta; + $meta->add_attribute(foo => (predicate => 'foo')); + $meta->remove_attribute('foo'); +} '<=', $expected, 'add_attribute with predicate and remove_attribute'; + +leaks_cmp_ok { + my $meta = Foo->meta; + $meta->add_attribute(foo => (clearer => 'foo')); + $meta->remove_attribute('foo'); +} '<=', $expected, 'add_attribute with clearer and remove_attribute'; +