From: Tomas Doran Date: Thu, 16 Oct 2008 07:11:16 +0000 (+0000) Subject: TODO Test for bug in Moose::Exporter X-Git-Tag: 0.60~26 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d5e6d777a0db00d2ced2ea46dd07adefecc4eae7;p=gitmo%2FMoose.git TODO Test for bug in Moose::Exporter --- diff --git a/Changes b/Changes index 9dade02..e72d2a9 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,10 @@ Revision history for Perl extension Moose + * Tests + - Test bug causing exported methods to get the wrong caller when + the -traits option is passed, and traits are loaded from disk + (thus recursively calling Moose::Exporter). (t0m) + 0.59 Tue October 14, 2008 * Moose - Add abridged documentation for builder/default/initializer/ diff --git a/t/050_metaclasses/013_metaclass_traits.t b/t/050_metaclasses/013_metaclass_traits.t index 950665c..a78ea4c 100644 --- a/t/050_metaclasses/013_metaclass_traits.t +++ b/t/050_metaclasses/013_metaclass_traits.t @@ -3,7 +3,9 @@ use strict; use warnings; -use Test::More tests => 28; +use lib 't/lib', 'lib'; + +use Test::More tests => 31; use Test::Exception; { @@ -188,3 +190,30 @@ can_ok( Foo::Subclass->meta(), 'attr2' ); is( Foo::Subclass->meta()->attr2(), 'something', 'Foo::Subclass->meta()->attr2() returns expected value' ); +{ + package Class::WithAlreadyPresentTrait; + use Moose -traits => 'My::SimpleTrait'; + + has an_attr => ( is => 'ro' ); +} +lives_ok { + my $instance = Class::WithAlreadyPresentTrait->new(an_attr => 'value'); + is($instance->an_attr, 'value', 'Can get value'); +} 'Can create instance and access attributes'; + +{ + package Class::WhichLoadsATraitFromDisk; + use Moose -traits => 'Role::Parent'; # Any role you like here, the only important bit is that it + # gets loaded from disk and has not already been defined. + + has an_attr => ( is => 'ro' ); +} + +TODO: { + local $TODO = 'Not working yet'; + lives_ok { + my $instance = Class::WhichLoadsATraitFromDisk->new(an_attr => 'value'); + is($instance->an_attr, 'value', 'Can get value'); + } 'Can create instance and access attributes'; +} +