* 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 ~~~
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
--- /dev/null
+#!/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';
+