test array delegation edge cases
[gitmo/Moose.git] / t / 030_roles / 003_apply_role.t
index 1ccff67..e58c0e2 100644 (file)
@@ -3,13 +3,15 @@
 use strict;
 use warnings;
 
-use Test::More tests => 86;
+use Test::More;
 use Test::Exception;
 
 {
     package FooRole;
     use Moose::Role;
 
+    our $VERSION = 23;
+
     has 'bar' => ( is => 'rw', isa => 'FooClass' );
     has 'baz' => ( is => 'ro' );
 
@@ -43,7 +45,13 @@ use Test::Exception;
     use Moose;
 
     extends 'BarClass';
-    with 'FooRole';
+
+    ::throws_ok { with 'FooRole' => { -version => 42 } }
+        qr/FooRole version 42 required--this is only version 23/,
+        'applying role with unsatisfied version requirement';
+
+    ::lives_ok { with 'FooRole' => { -version => 13 } }
+        'applying role with satisfied version requirement';
 
     sub blau {'FooClass::blau'}    # << the role wraps this ...
 
@@ -183,3 +191,5 @@ foreach my $foo ( $foo, $foobar ) {
 
     is( $foo->bar, $foo2, '... got the right value for bar now' );
 }
+
+done_testing;