X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F12-error.t;h=acf8cd3791398340665d7cad056779fb53700ef6;hb=9448ea2c4ec450d2c5bbf8f10692457cb583facb;hp=e253c783fb9917290974166890248f27f21910bf;hpb=9eb6e8c6a5da5d60eb1986db304565b8ea826aed;p=gitmo%2FMooseX-Types-Structured.git diff --git a/t/12-error.t b/t/12-error.t index e253c78..acf8cd3 100644 --- a/t/12-error.t +++ b/t/12-error.t @@ -1,8 +1,6 @@ -BEGIN { - use strict; - use warnings; - use Test::More tests=>25; -} +use strict; +use warnings; +use Test::More; use Moose::Util::TypeConstraints; use MooseX::Types::Structured qw(Dict Tuple Optional); @@ -116,10 +114,23 @@ my $deep_tuple = subtype 'deep_tuple', ok $deep_tuple->check([1,{a=>2},{name=>'Vincent',age=>15}]), 'Good Constraint'; -like $deep_tuple->validate([1,{a=>2},{name=>'Vincent',age=>'Hello'}]), - qr/Error is: Validation failed for 'MooseX::Types::Structured::Dict\[name,Str,age,Int\]'/, - 'Example deeper error'; +{ + my $message = $deep_tuple->validate([1,{a=>2},{name=>'Vincent',age=>'Hello'}]); + like $message, + qr/Validation failed for 'MooseX::Types::Structured::Dict\[name,Str,age,Int\]'/, + 'Example deeper error'; +} + +like $simple_tuple->validate(["aaa","bbb"]), + qr/'Int' with value aaa/, + 'correct deeper error'; + +like $deep_tuple->validate([1,{a=>2},{name=>'Vincent1',age=>'Hello1'}]), + qr/'Int' with value Hello1/, + 'correct deeper error'; ## Success Tests... ok !$deep_tuple->validate([1,{a=>2},{name=>'John',age=>40}]), 'Validates ok'; + +done_testing();