added some code to improve the error message and added test for that
[gitmo/MooseX-Types-Structured.git] / t / 12-error.t
CommitLineData
797510e3 1BEGIN {
2 use strict;
3 use warnings;
4 use Test::More tests=>4;
5}
6
7use Moose::Util::TypeConstraints;
8use MooseX::Types::Structured qw(Dict Tuple);
9use MooseX::Types::Moose qw(Int Str ArrayRef HashRef);
10
11# Create some TCs from which errors will be generated
12my $simple_tuple = subtype 'simple_tuple', as Tuple[Int,Str];
13my $simple_dict = subtype 'simple_dict', as Dict[name=>Str,age=>Int];
14
15# We probably need more stuff here...
16ok $simple_tuple->check([1,'hello']), "simple_tuple validates: 1,'hello'";
17ok !$simple_tuple->check(['hello',1]), "simple_tuple fails: 'hello',1";
18like $simple_tuple->validate(['hello',1]), qr/"hello", 1/, 'got expected valiate message';
19like $simple_dict->validate(['hello',1]), qr/"hello", 1/, 'got expected valiate message';
20