Created
March 7, 2010 11:21
-
-
Save clkao/324317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use Test::More; | |
{ | |
package RandomClass; | |
use Moose; | |
with 'MooseX::Traits'; | |
has '+_trait_namespace' => (default => 'RandomClass::Trait'); | |
__PACKAGE__->meta->make_immutable; | |
no Moose; | |
1; | |
} | |
{ | |
package RandomClass::Trait::Test; | |
use Moose::Role; | |
use Test::More; | |
} | |
my $anon_class = Moose::Meta::Class->create_anon_class( | |
superclasses => [ 'RandomClass' ], | |
roles => [ 'RandomClass::Trait::Test' ], | |
cache => 1, | |
); | |
my $class = $anon_class->name; | |
my $random = $class->new; | |
ok($random->DOES('RandomClass::Trait::Test')); | |
use Test::Requires qw(Test::Memory::Cycle); | |
memory_cycle_ok( $random, 'no leaks in subscriber' ); | |
$random = RandomClass->new_with_traits( traits => ['Test']); | |
memory_cycle_ok( $random, 'no leaks in subscriber' ); | |
ok($random->DOES('RandomClass::Trait::Test')); | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment