X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xt%2Fmoose-accessor-isa.t;h=525494816bcff6b65aa8b3f003b851b20cabcf3e;hb=040b273865600d815731e915e4806c8618486e25;hp=bf67db41d69021ea73b139ae59e4b2e7e18f4599;hpb=b014a523294f059352031025c45420979802cff3;p=gitmo%2FMoo.git diff --git a/xt/moose-accessor-isa.t b/xt/moose-accessor-isa.t index bf67db4..5254948 100644 --- a/xt/moose-accessor-isa.t +++ b/xt/moose-accessor-isa.t @@ -22,6 +22,23 @@ use Moo::HandleMoose; package Bar; use Moose; with 'FrewWithIsa'; + + package OffByOne; + use Moo::Role; + + has off_by_one => (is => 'rw', coerce => sub { $_[0] + 1 }); + + package Baz; + use Moo; + + with 'OffByOne'; + + package Quux; + use Moose; + + with 'OffByOne'; + + __PACKAGE__->meta->make_immutable; } lives_ok { @@ -36,4 +53,19 @@ dies_ok { Bar->new(frooh => 1, frew => 'goose'); } 'creation of invalid Bar validated by quoted sub'; +sub test_off_by_one { + my ($class, $type) = @_; + + my $obo = $class->new(off_by_one => 1); + + is($obo->off_by_one, 2, "Off by one (new) ($type)"); + + $obo->off_by_one(41); + + is($obo->off_by_one, 42, "Off by one (set) ($type)"); +} + +test_off_by_one('Baz', 'Moo'); +test_off_by_one('Quux', 'Moose'); + done_testing;