revise Makefile.PL boilerplate
[gitmo/Role-Tiny.git] / t / modifiers.t
index a557d50..6d90efb 100644 (file)
@@ -4,8 +4,8 @@ use Test::More;
 use Test::Fatal;
 
 BEGIN {
-  plan skip_all => "Class::Method::Modifiers not installed"
-    unless eval "use Class::Method::Modifiers; 1";
+  plan skip_all => "Class::Method::Modifiers not installed or too old"
+    unless eval "use Class::Method::Modifiers 1.05; 1";
 }
 
 BEGIN {
@@ -17,18 +17,47 @@ BEGIN {
 }
 
 BEGIN {
+  package ExtraRole;
+
+  use Role::Tiny;
+}
+
+BEGIN {
   package MyClass;
 
   sub foo { 'class foo' }
 }
 
 BEGIN {
+  package ExtraClass;
+
+  use Role::Tiny::With;
+
+  with qw(MyRole ExtraRole);
+
+  sub foo { 'class foo' }
+}
+
+BEGIN {
   package BrokenRole;
   use Role::Tiny;
 
   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') }
@@ -36,6 +65,10 @@ sub try_apply_to {
 
 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');