From: Shawn M Moore Date: Wed, 26 Nov 2008 01:26:05 +0000 (+0000) Subject: Test that we free anonymous roles automatically (we don't) X-Git-Tag: 0.62~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=db121d240f901f8d42dada36cd5240143080cef8;p=gitmo%2FMoose.git Test that we free anonymous roles automatically (we don't) --- diff --git a/t/030_roles/036_free_anonymous_roles.t b/t/030_roles/036_free_anonymous_roles.t new file mode 100644 index 0000000..a17622d --- /dev/null +++ b/t/030_roles/036_free_anonymous_roles.t @@ -0,0 +1,29 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More tests => 2; +use Moose (); +use Scalar::Util 'weaken'; + +my $weak; +do { + my $anon_class; + + do { + my $role = Moose::Meta::Role->create_anon_role; + weaken($weak = $role); + + $anon_class = Moose::Meta::Class->create_anon_class( + roles => [ $role->name ], + ); + }; + + ok($weak, "we still have the role metaclass because the anonymous class that consumed it is still alive"); + +}; + +TODO: { + local $TODO = "we don't weaken role metaclasses yet"; + ok(!$weak, "the role metaclass is freed after its last reference (from a consuming anonymous class) is freed"); +}; +