Skip to content

Instantly share code, notes, and snippets.

@clkao
Created March 7, 2010 06:05
Show Gist options
  • Save clkao/324198 to your computer and use it in GitHub Desktop.
Save clkao/324198 to your computer and use it in GitHub Desktop.
use strict;
use Test::More;
our ($built, $demolished) = @_;
{
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;
sub BUILD {}; after 'BUILD' => sub {
$main::built++;
};
sub DEMOLISH {}; after 'DEMOLISH' => sub {
$main::demolished++;
};
}
my $bus = RandomClass->new_with_traits( traits => ['Test']);
ok($bus->DOES('RandomClass::Trait::Test'));
ok($built);
ok($demolished);
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment