X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Faccessor-roles.t;h=d2ab4709b317280c0dcbb53138904d310f26814c;hb=2f425b5770149d4ed2e59da001c3be052cbd6bc1;hp=eb8b8b652723a01fb872cef6a7c997f60a26c9da;hpb=c69190f1086805f314dbe3bc2926aa940abd4001;p=gitmo%2FMoo.git diff --git a/t/accessor-roles.t b/t/accessor-roles.t index eb8b8b6..d2ab470 100644 --- a/t/accessor-roles.t +++ b/t/accessor-roles.t @@ -1,5 +1,6 @@ use strictures 1; use Test::More; +use Test::Fatal; use Sub::Quote; { @@ -22,4 +23,20 @@ is $c->one, "one", "attr default set from class"; is $c->two, "two", "attr default set from role"; is $c->three, "three", "attr default set from role"; +{ + package Deux; use Moo; with 'One::P1'; + ::like( + ::exception { has two => (is => 'ro', default => sub { 'II' }); }, + qr{^You cannot overwrite a locally defined method \(two\) with a reader}, + 'overwriting accesssors with roles fails' + ); +} + +{ + package Two; use Moo; with 'One::P1'; + has '+two' => (is => 'ro', default => sub { 'II' }); +} + +is(Two->new->two, 'II', "overwriting accessors using +attr works"); + done_testing;