X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F13_typedecorator.t;h=4bd5960d6655bb8b29def5b28b58d150841aef7d;hb=e088dd0352e963c94da8202d73abd3a68b6f2486;hp=585dce244ab3c907853526a3bc0e483705f660b7;hpb=cf1a8bfa50cb6cab796582ddae0a5b05dfcd8759;p=gitmo%2FMooseX-Types.git diff --git a/t/13_typedecorator.t b/t/13_typedecorator.t index 585dce2..4bd5960 100644 --- a/t/13_typedecorator.t +++ b/t/13_typedecorator.t @@ -2,7 +2,7 @@ use warnings; use strict; -use Test::More tests => 29; +use Test::More tests => 33; use Test::Exception; use FindBin; use lib "$FindBin::Bin/lib"; @@ -16,6 +16,7 @@ use lib "$FindBin::Bin/lib"; ); use DecoratorLibrary qw( MyArrayRefBase MyArrayRefInt01 MyArrayRefInt02 StrOrArrayRef + AtLeastOneInt ); has 'arrayrefbase' => (is=>'rw', isa=>MyArrayRefBase, coerce=>1); @@ -23,6 +24,7 @@ use lib "$FindBin::Bin/lib"; has 'arrayrefint02' => (is=>'rw', isa=>MyArrayRefInt02, coerce=>1); has 'arrayrefint03' => (is=>'rw', isa=>MyArrayRefBase[Int]); has 'StrOrArrayRef' => (is=>'rw', isa=>StrOrArrayRef); + has 'AtLeastOneInt' => (is=>'rw', isa=>AtLeastOneInt); } ## Make sure we have a 'create object sanity check' @@ -125,4 +127,21 @@ ok $type->StrOrArrayRef([1,2,3]) throws_ok sub { $type->StrOrArrayRef({a=>111}); -}, qr/Attribute \(StrOrArrayRef\) does not pass the type constraint/ => 'Correctly failed to use a hashref'; \ No newline at end of file +}, qr/Attribute \(StrOrArrayRef\) does not pass the type constraint/ => 'Correctly failed to use a hashref'; + +# Test AtLeastOneInt + +ok $type->AtLeastOneInt([1,2]), + => 'Good assignment'; + +is_deeply $type->AtLeastOneInt, [1,2] + => "Got expected values."; + +throws_ok sub { + $type->AtLeastOneInt([]); +}, qr/Attribute \(AtLeastOneInt\) does not pass the type constraint/ => 'properly fails'; + +throws_ok sub { + $type->AtLeastOneInt(['a','b']); +}, qr/Attribute \(AtLeastOneInt\) does not pass the type constraint/ => 'properly fails arrayref of strings'; +