From: gfx Date: Sat, 3 Oct 2009 05:57:20 +0000 (+0900) Subject: Add a test file X-Git-Tag: 0.37_02~21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2669196e30954006103bfb6a88f60457ebf2691c;p=gitmo%2FMouse.git Add a test file --- diff --git a/t/054-anon-leak.t b/t/054-anon-leak.t new file mode 100755 index 0000000..3ddb211 --- /dev/null +++ b/t/054-anon-leak.t @@ -0,0 +1,51 @@ +#!perl +# This is based on Class-MOP/t/312_anon_class_leak.t +use strict; +use warnings; +use Test::More; + +BEGIN { + eval "use Test::LeakTrace 0.10;"; + plan skip_all => "Test::LeakTrace 0.10 is required for this test" if $@; +} + +plan tests => 6; + +use Mouse (); +{ + package MyRole; + use Mouse::Role; + + sub my_role_method{ } +} + +# 5.10.0 has a bug on weaken($hash_ref) which leaks an AV. +my $expected = ( $] == 5.010_000 ? 1 : 0 ); + +leaks_cmp_ok { + Mouse::Meta::Class->create_anon_class(); +} '<=', $expected, 'create_anon_class()'; + +leaks_cmp_ok { + Mouse::Meta::Class->create_anon_class(superclasses => ['Mouse::Meta::Class']); +} '<=', $expected, 'create_anon_class() with superclasses'; + +leaks_cmp_ok { + Mouse::Meta::Class->create_anon_class(attributes => [ + Mouse::Meta::Attribute->new('foo', is => 'rw'), + ]); +} '<=', $expected, 'create_anon_class() with attributes'; + +leaks_cmp_ok { + Mouse::Meta::Class->create_anon_class(roles => [qw(MyRole)]); +} '<=', $expected, 'create_anon_class() with roles'; + + +leaks_cmp_ok { + Mouse::Meta::Role->create_anon_role(); +} '<=', $expected, 'create_anon_role()'; + +leaks_cmp_ok { + Mouse::Meta::Role->create_anon_role(roles => [qw(MyRole)]); +} '<=', $expected, 'create_anon_role() with roles'; +