From: Toby Inkster Date: Fri, 15 Feb 2013 12:09:39 +0000 (+0000) Subject: test cases for +attr and overwriting methods X-Git-Tag: v1.001000~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2e512d300d6d3c57dd9f41784ee762491daaaef1;p=gitmo%2FMoo.git test cases for +attr and overwriting methods --- 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;