From: Dave Rolsky Date: Fri, 16 Sep 2011 15:48:40 +0000 (-0500) Subject: Add tests for delegation overriding local methods (real and stub) X-Git-Tag: 2.0300~60 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8ac521f79b0a33c24bb0ea70922b342b40d51e65;p=gitmo%2FMoose.git Add tests for delegation overriding local methods (real and stub) --- diff --git a/t/attributes/attribute_delegation.t b/t/attributes/attribute_delegation.t index 18b9048..733542c 100644 --- a/t/attributes/attribute_delegation.t +++ b/t/attributes/attribute_delegation.t @@ -454,4 +454,32 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); is( exception { $k->foo_baz }, undef, "but not for class name" ); } +{ + package Delegator; + use Moose; + + sub full { 1 } + sub stub; + + ::like( + ::exception{ has d1 => ( + isa => 'X', + handles => ['full'], + ); + }, + qr/\QYou cannot overwrite a locally defined method (full) with a delegation/, + 'got an error when trying to declare a delegation method that overwrites a local method' + ); + + ::is( + ::exception{ has d2 => ( + isa => 'X', + handles => ['stub'], + ); + }, + undef, + 'no error when trying to declare a delegation method that overwrites a stub method' + ); +} + done_testing;