From: Moritz Onken Date: Sun, 16 Jan 2011 20:58:54 +0000 (+0100) Subject: added test from #62467 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d7ebfe7871af833331ba23b96ce7194254470804;p=gitmo%2FMooseX-ClassAttribute.git added test from #62467 --- diff --git a/t/07-parameterized-role.t b/t/07-parameterized-role.t index ba28077..7fd9201 100644 --- a/t/07-parameterized-role.t +++ b/t/07-parameterized-role.t @@ -2,10 +2,10 @@ use strict; use warnings; use Test::More; -use Test::Fatal; use Test::Requires { 'MooseX::Role::Parameterized' => '0', + 'Test::Fatal' => '0' }; plan skip_all => diff --git a/t/08-role-composition.t b/t/08-role-composition.t index 81eeb44..f4b7f36 100644 --- a/t/08-role-composition.t +++ b/t/08-role-composition.t @@ -14,6 +14,16 @@ use Test::More; isa => 'HashRef', default => sub { {} }, ); + + class_has 'lazy_fail' => ( + isa => 'Int' + , is => 'ro' + , lazy => 1 + , default => sub { + my $self = shift; + $self->life + 42; + } + ); } { @@ -24,13 +34,31 @@ use Test::More; { package Bar; use Moose; + use MooseX::ClassAttribute; with( 'Role2', 'Role' ); + + class_has 'life' => ( isa => 'Int', is => 'ro', default => 42 ); } { local $TODO = 'Class attributes are lost during role composition'; can_ok( 'Bar', 'CA', ); + my $obj; + eval { + $obj = Bar->new; + }; + ok( !$@, 'No errors creating object' ); + is( $obj->life, 42, 'Right value for object' ); + eval { + $obj->lazy_fail; + }; + ok (!$@, "Calling class attribute declared in role syyucceeded" ); + + eval { + $obj->lazy_fail = 84 ? return : die "Not equal"; + }; + ok (!$@, "Lazy class attribute in role was able to utilize non-lazy values in base class" ); } done_testing();