From: Dave Rolsky Date: Tue, 26 Aug 2008 17:00:33 +0000 (+0000) Subject: Add tests for applying several roles in succession, to make sure we X-Git-Tag: 0.55_04~2^2~24 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=82b388d5a2a8c772420c852d51d98863e33a9c3c;p=gitmo%2FMoose.git Add tests for applying several roles in succession, to make sure we preserve previously applied roles. Also added a test count. --- diff --git a/t/050_metaclasses/015_metarole.t b/t/050_metaclasses/015_metarole.t index 45244d1..d52c109 100644 --- a/t/050_metaclasses/015_metarole.t +++ b/t/050_metaclasses/015_metarole.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More 'no_plan'; +use Test::More tests => 47; use Moose::Util::MetaRole; @@ -265,3 +265,34 @@ use Moose::Util::MetaRole; ok( ( grep { $_ eq 'My::Meta::Class' } My::Class3->meta()->meta()->superclasses() ), 'apply_metaclass_roles() does not interfere with metaclass set via Moose->init_meta()' ); } + +{ + package Role::Bar; + use Moose::Role; + has 'bar' => ( is => 'ro', default => 200 ); +} + +{ + package My::Class4; + use Moose; +} + +{ + Moose::Util::MetaRole::apply_metaclass_roles( + for_class => 'My::Class4', + metaclass_roles => ['Role::Foo'], + ); + + ok( My::Class4->meta()->meta()->does_role('Role::Foo'), + 'apply Role::Foo to My::Class4->meta()' ); + + Moose::Util::MetaRole::apply_metaclass_roles( + for_class => 'My::Class4', + metaclass_roles => ['Role::Bar'], + ); + + ok( My::Class4->meta()->meta()->does_role('Role::Bar'), + 'apply Role::Bar to My::Class4->meta()' ); + ok( My::Class4->meta()->meta()->does_role('Role::Foo'), + '... and My::Class4->meta() still does Role::Foo' ); +}