From: Arthur Axel 'fREW' Schmidt Date: Tue, 3 Apr 2012 22:39:16 +0000 (-0500) Subject: test Isa checking X-Git-Tag: v0.009_015~18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b014a523294f059352031025c45420979802cff3;p=gitmo%2FMoo.git test Isa checking --- diff --git a/xt/moose-accessor-isa.t b/xt/moose-accessor-isa.t new file mode 100644 index 0000000..bf67db4 --- /dev/null +++ b/xt/moose-accessor-isa.t @@ -0,0 +1,39 @@ +use strictures 1; +use Test::More; +use Test::Exception; + +use Moo::HandleMoose; + +{ + package FrewWithIsa; + use Moo::Role; + use Sub::Quote; + + has frooh => ( + is => 'rw', + isa => sub { die 'not int' unless $_[0] =~ /^\d$/ }, + ); + + has frew => ( + is => 'rw', + isa => quote_sub(q{ die 'not int' unless $_[0] =~ /^\d$/ }), + ); + + package Bar; + use Moose; + with 'FrewWithIsa'; +} + +lives_ok { + Bar->new(frooh => 1, frew => 1); +} 'creation of valid Bar'; + +dies_ok { + Bar->new(frooh => 'silly', frew => 1); +} 'creation of invalid Bar validated by coderef'; + +dies_ok { + Bar->new(frooh => 1, frew => 'goose'); +} 'creation of invalid Bar validated by quoted sub'; + +done_testing;