additional tests for applying multiple roles
[gitmo/Moo.git] / t / accessor-handles.t
index b88a700..2125784 100644 (file)
@@ -1,5 +1,6 @@
 use strictures 1;
 use Test::More;
+use Test::Fatal;
 
 use lib "t/lib";
 
@@ -74,4 +75,20 @@ is $bar->eat_curry, 'Curry!', 'handles works for currying';
 is $bar->foobot, 'beep', 'asserter checks for existence not truth, on false value';
 
 is $bar->foobar, 'bar', 'asserter checks for existence not truth, on undef ';
+
+ok(my $e = exception {
+  package Baz;
+  use Moo;
+  has foo => ( is => 'ro', handles => 'Robot' );
+  sub smash { 1 };
+}, 'handles will not overwrite locally defined method');
+like $e, qr{You cannot overwrite a locally defined method \(smash\) with a delegation},
+  '... and has correct error message';
+
+ok(exception {
+  package Fuzz;
+  use Moo;
+  has foo => ( is => 'ro', handles => $bar );
+}, 'invalid handles throws exception');
+
 done_testing;