Created
March 7, 2010 06:14
-
-
Save clkao/324209 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; | |
our ($built, $demolished) = (0, 0); | |
{ | |
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 { | |
$main::demolished++; | |
}; | |
} | |
{ | |
package RandomClass2; | |
use Moose; | |
with 'RandomClass::Trait::Test'; | |
} | |
my $bus = RandomClass->new_with_traits( traits => ['Test']); | |
ok($bus->DOES('RandomClass::Trait::Test')); | |
ok($built); | |
undef $bus; | |
ok($demolished); | |
($built, $demolished) = (0, 0); | |
$bus = RandomClass2->new; | |
ok($bus->DOES('RandomClass::Trait::Test')); | |
ok($built); | |
undef $bus; | |
ok($demolished); | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment