From: Stevan Little Date: Tue, 22 Jan 2008 23:38:26 +0000 (+0000) Subject: adding another test X-Git-Tag: 0_35~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c3b353923ef593af9b8860f32de0c3eca89ed864;p=gitmo%2FMoose.git adding another test --- diff --git a/Changes b/Changes index 18e4b64..9184c62 100644 --- a/Changes +++ b/Changes @@ -4,7 +4,7 @@ Revision history for Perl extension Moose * Moose::Meta::Method::Constructor - fix to make sure even Class::MOP attributes are handled correctly (Thanks to Dave Rolsky) - - added test for this + - added test for this (also Dave Rolsky) 0.34 Mon. Jan. 21, 2008 ~~~ more misc. doc. fixes ~~~ diff --git a/MANIFEST b/MANIFEST index 8d0618a..6d4723f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -112,6 +112,7 @@ t/030_roles/011_overriding.t t/030_roles/012_method_exclusion_in_composition.t t/030_roles/013_method_aliasing_in_composition.t t/030_roles/014_more_alias_and_exclude.t +t/030_roles/015_runtime_roles_and_attrs.t t/030_roles/020_role_composite.t t/030_roles/021_role_composite_exclusion.t t/030_roles/022_role_composition_req_methods.t diff --git a/t/030_roles/015_runtime_roles_and_attrs.t b/t/030_roles/015_runtime_roles_and_attrs.t new file mode 100644 index 0000000..ca4e51b --- /dev/null +++ b/t/030_roles/015_runtime_roles_and_attrs.t @@ -0,0 +1,50 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 9; +use Test::Exception; +use Scalar::Util 'blessed'; + +BEGIN { + use_ok('Moose'); +} + + +{ + package Dog; + use Moose::Role; + + sub talk { 'woof' } + + package Foo; + use Moose; + + has 'dog' => ( + is => 'rw', + does => 'Dog', + ); +} + +my $obj = Foo->new; +isa_ok($obj, 'Foo'); + +ok(!$obj->can( 'talk' ), "... the role is not composed yet"); +ok(!$obj->does('Dog'), '... we do not do any roles yet'); + +dies_ok { + $obj->dog($obj) +} '... and setting the accessor fails (not a Dog yet)'; + +Dog->meta->apply($obj); + +ok($obj->does('Dog'), '... we now do the Bark role'); +ok($obj->can('talk'), "... the role is now composed at the object level"); + +is($obj->talk, 'woof', '... got the right return value for the newly composed method'); + +lives_ok { + $obj->dog($obj) +} '... and setting the accessor is okay'; +