From: Graham Knop Date: Tue, 4 Mar 2014 02:46:07 +0000 (-0500) Subject: test composing modifiers into role X-Git-Tag: v1.003003~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FRole-Tiny.git;a=commitdiff_plain;h=291d3b5efe6b1d506946f55cec6bab1053e2cebe test composing modifiers into role --- diff --git a/t/modifiers.t b/t/modifiers.t index 63a9708..6d90efb 100644 --- a/t/modifiers.t +++ b/t/modifiers.t @@ -45,6 +45,19 @@ BEGIN { around 'broken modifier' => sub { my $orig = shift; $orig->(@_) }; } +BEGIN { + package MyRole2; + use Role::Tiny; + with 'MyRole'; +} + +BEGIN { + package ExtraClass2; + use Role::Tiny::With; + with 'MyRole2'; + sub foo { 'class foo' } +} + sub try_apply_to { my $to = shift; exception { Role::Tiny->apply_role_to_package($to, 'MyRole') } @@ -54,6 +67,9 @@ is(try_apply_to('MyClass'), undef, 'role applies cleanly'); is(MyClass->foo, 'role foo class foo', 'method modifier'); is(ExtraClass->foo, 'role foo class foo', 'method modifier with composition'); +is(ExtraClass2->foo, 'role foo class foo', + 'method modifier with role composed into role'); + ok(exception { my $new_class = Role::Tiny->create_class_with_roles('MyClass', 'BrokenRole'); }, 'exception caught creating class with broken modifier in a role');