From: Ricardo SIGNES Date: Fri, 5 Dec 2008 01:18:37 +0000 (+0000) Subject: default needs invocant X-Git-Tag: 0.19~141 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c217840932f794182884a5695d792666b734d51d;p=gitmo%2FMouse.git default needs invocant --- diff --git a/t/017-default-reference.t b/t/017-default-reference.t index 18dc7b2..304b55d 100644 --- a/t/017-default-reference.t +++ b/t/017-default-reference.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 8; +use Test::More tests => 9; use Mouse::Util ':test'; do { @@ -48,3 +48,12 @@ is(ref(Class->new->code), 'CODE', "default => sub { sub { 1 } } stuffs a coderef is(Class->new->code->(), 1, "default => sub sub strips off the first coderef"); is_deeply(Class->new->a, [1], "default of sub { reference } works"); +do { + package Class::Two; + use Mouse; + has foo => (is => 'rw', default => sub { shift->default_foo }); + sub default_foo { 1 }; +}; + +my $obj2 = Class::Two->new; +is($obj2->foo, 1, 'default method gets the $_[0] it needs to work');