From: Chris Prather Date: Fri, 27 Mar 2009 20:43:43 +0000 (-0400) Subject: add tests for when we lazy load a value and the type constraint is violated X-Git-Tag: 0.73_01~57 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=599c554113edd8228fd68fb26daa918c10109535;p=gitmo%2FMoose.git add tests for when we lazy load a value and the type constraint is violated --- diff --git a/t/040_type_constraints/022_custom_type_errors.t b/t/040_type_constraints/022_custom_type_errors.t index 9167623..b5d5f01 100644 --- a/t/040_type_constraints/022_custom_type_errors.t +++ b/t/040_type_constraints/022_custom_type_errors.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 8; +use Test::More tests => 10; use Test::Exception; { @@ -26,7 +26,11 @@ use Test::Exception; has leg_count => ( is => 'rw', isa => 'NaturalLessThanTen', + lazy => 1, + default => 0, + ); + } lives_ok { my $goat = Animal->new(leg_count => 4) } '... no errors thrown, value is good'; @@ -53,3 +57,10 @@ throws_ok { $chimera->leg_count(16) } qr/This number \(16\) is not less than ten!/, "gave custom subtype error message on set_value"; +# try the lazy legs +my $gimp; +lives_ok { my $gimp = Animal->new() } '... no errors thrown, value is good'; +throws_ok { $gimp->leg_count } + qr/This number \(0\) is not less than ten!/, + "gave custom supertype error message on set_value"; +