X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Foverloaded-coderefs.t;fp=t%2Foverloaded-coderefs.t;h=66bdc0b4dcaaac806d0273949004b92cf49d885a;hb=707f101cf9e90c6a8bc858b08da601ce94e7fd8e;hp=5e59ae8f9061019729ca04f8bd23068c614ba247;hpb=235b63fc17ce97b0d16c5cb7f81a4423ce1427b5;p=gitmo%2FMoo.git diff --git a/t/overloaded-coderefs.t b/t/overloaded-coderefs.t index 5e59ae8..66bdc0b 100644 --- a/t/overloaded-coderefs.t +++ b/t/overloaded-coderefs.t @@ -2,10 +2,11 @@ use strict; use warnings; use Test::More; +my $codified = 0; { package Dark::Side; use overload - q[&{}] => sub { shift->to_code }, + q[&{}] => sub { $codified++; shift->to_code }, fallback => 1; sub new { my $class = shift; @@ -37,13 +38,16 @@ is($theforce->(6), 12, 'check The::Force coderef'); { package Doubleena; use Moo; - has a => (is => "ro", coerce => $darkside, isa => sub { 1 }); - has b => (is => "ro", coerce => $theforce, isa => The::Force->new('my $z = "I am your father"')); + has a => (is => "rw", coerce => $darkside, isa => sub { 1 }); + has b => (is => "rw", coerce => $theforce, isa => The::Force->new('my $z = "I am your father"')); } my $o = Doubleena->new(a => 11, b => 12); is($o->a, 22, 'non-Sub::Quoted inlined coercion overload works'); is($o->b, 24, 'Sub::Quoted inlined coercion overload works'); +my $codified_before = $codified; +$o->a(5); +is($codified_before, $codified, "repeated calls to accessor don't re-trigger overload"); use B::Deparse; my $constructor = B::Deparse->new->coderef2text(Doubleena->can('new'));