From: Graham Knop Date: Mon, 24 Jun 2013 04:48:49 +0000 (-0400) Subject: test for invalid handles spec X-Git-Tag: v1.003000~33 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a736c76b5a77f3ccd6796376eb5ee6ec5d9dea47;p=gitmo%2FMoo.git test for invalid handles spec --- diff --git a/t/accessor-handles.t b/t/accessor-handles.t index d96abb8..2125784 100644 --- a/t/accessor-handles.t +++ b/t/accessor-handles.t @@ -1,5 +1,6 @@ use strictures 1; use Test::More; +use Test::Fatal; use lib "t/lib"; @@ -75,16 +76,19 @@ is $bar->foobot, 'beep', 'asserter checks for existence not truth, on false valu is $bar->foobar, 'bar', 'asserter checks for existence not truth, on undef '; -{ - local $@; - ok !eval q{ - package Baz; - use Moo; - has foo => ( is => 'ro', handles => 'Robot' ); - sub smash { 1 }; - 1; - }, 'handles will not overwrite locally defined method'; - like $@, qr{You cannot overwrite a locally defined method \(smash\) with a delegation}; -} +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;