--- /dev/null
+#!perl\r
+# This is based on Class-MOP/t/312_anon_class_leak.t\r
+use strict;\r
+use warnings;\r
+use Test::More;\r
+\r
+BEGIN {\r
+ eval "use Test::LeakTrace 0.10;";\r
+ plan skip_all => "Test::LeakTrace 0.10 is required for this test" if $@;\r
+}\r
+\r
+plan tests => 6;\r
+\r
+use Mouse ();\r
+{\r
+ package MyRole;\r
+ use Mouse::Role;\r
+\r
+ sub my_role_method{ }\r
+}\r
+\r
+# 5.10.0 has a bug on weaken($hash_ref) which leaks an AV.\r
+my $expected = ( $] == 5.010_000 ? 1 : 0 );\r
+\r
+leaks_cmp_ok {\r
+ Mouse::Meta::Class->create_anon_class();\r
+} '<=', $expected, 'create_anon_class()';\r
+\r
+leaks_cmp_ok {\r
+ Mouse::Meta::Class->create_anon_class(superclasses => ['Mouse::Meta::Class']);\r
+} '<=', $expected, 'create_anon_class() with superclasses';\r
+\r
+leaks_cmp_ok {\r
+ Mouse::Meta::Class->create_anon_class(attributes => [\r
+ Mouse::Meta::Attribute->new('foo', is => 'rw'),\r
+ ]);\r
+} '<=', $expected, 'create_anon_class() with attributes';\r
+\r
+leaks_cmp_ok {\r
+ Mouse::Meta::Class->create_anon_class(roles => [qw(MyRole)]);\r
+} '<=', $expected, 'create_anon_class() with roles';\r
+\r
+\r
+leaks_cmp_ok {\r
+ Mouse::Meta::Role->create_anon_role();\r
+} '<=', $expected, 'create_anon_role()';\r
+\r
+leaks_cmp_ok {\r
+ Mouse::Meta::Role->create_anon_role(roles => [qw(MyRole)]);\r
+} '<=', $expected, 'create_anon_role() with roles';\r
+\r