From: Dave Rolsky Date: Fri, 27 Mar 2009 20:48:42 +0000 (-0500) Subject: Tidied the code X-Git-Tag: 0.73_01~55 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=62bf83c7852f67069cac54c4dfbac869610ac7cd;p=gitmo%2FMoose.git Tidied the code --- diff --git a/t/040_type_constraints/022_custom_type_errors.t b/t/040_type_constraints/022_custom_type_errors.t index b5d5f01..32bcfbc 100644 --- a/t/040_type_constraints/022_custom_type_errors.t +++ b/t/040_type_constraints/022_custom_type_errors.t @@ -9,58 +9,58 @@ use Test::Exception; { package Animal; use Moose; + BEGIN { ::use_ok("Moose::Util::TypeConstraints"); } - subtype 'Natural' - => as 'Int' - => where { $_ > 0 } - => message { "This number ($_) is not a positive integer!" }; + subtype 'Natural' => as 'Int' => where { $_ > 0 } => + message {"This number ($_) is not a positive integer!"}; - subtype 'NaturalLessThanTen' - => as 'Natural' - => where { $_ < 10 } - => message { "This number ($_) is not less than ten!" }; + subtype 'NaturalLessThanTen' => as 'Natural' => where { $_ < 10 } => + message {"This number ($_) is not less than ten!"}; has leg_count => ( - is => 'rw', - isa => 'NaturalLessThanTen', - lazy => 1, + is => 'rw', + isa => 'NaturalLessThanTen', + lazy => 1, default => 0, ); - + } -lives_ok { my $goat = Animal->new(leg_count => 4) } '... no errors thrown, value is good'; -lives_ok { my $spider = Animal->new(leg_count => 8) } '... no errors thrown, value is good'; +lives_ok { my $goat = Animal->new( leg_count => 4 ) } +'... no errors thrown, value is good'; +lives_ok { my $spider = Animal->new( leg_count => 8 ) } +'... no errors thrown, value is good'; -throws_ok { my $fern = Animal->new(leg_count => 0) } - qr/This number \(0\) is not less than ten!/, - "gave custom supertype error message on new"; +throws_ok { my $fern = Animal->new( leg_count => 0 ) } +qr/This number \(0\) is not less than ten!/, + "gave custom supertype error message on new"; -throws_ok { my $centipede = Animal->new(leg_count => 30) } - qr/This number \(30\) is not less than ten!/, - "gave custom subtype error message on new"; +throws_ok { my $centipede = Animal->new( leg_count => 30 ) } +qr/This number \(30\) is not less than ten!/, + "gave custom subtype error message on new"; my $chimera; -lives_ok { $chimera = Animal->new(leg_count => 4) } '... no errors thrown, value is good'; +lives_ok { $chimera = Animal->new( leg_count => 4 ) } +'... no errors thrown, value is good'; # first we remove the lion's legs.. throws_ok { $chimera->leg_count(0) } - qr/This number \(0\) is not less than ten!/, - "gave custom supertype error message on set_value"; +qr/This number \(0\) is not less than ten!/, + "gave custom supertype error message on set_value"; # mix in a few octopodes throws_ok { $chimera->leg_count(16) } - qr/This number \(16\) is not less than ten!/, - "gave custom subtype error message on set_value"; +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'; +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"; - +qr/This number \(0\) is not less than ten!/, + "gave custom supertype error message on set_value"; +