replace tabs with spaces (oops) s/\t/ /g
[gitmo/MooseX-Dependent.git] / t / 07-no-message.t
CommitLineData
cbac5987 1use strict;
2use warnings;
3
4use Test::More;
5
6{
7 package Test::MyMooseClass;
8
9 use Moose;
10 use MooseX::Types::Parameterizable qw(Parameterizable);
11 use MooseX::Types::Moose qw(Str Int);
12 use MooseX::Types -declare=>[qw(Varchar)];
13
14 ## Minor change from docs to avoid additional test dependencies
15 subtype Varchar,
16 as Parameterizable[Str,Int],
17 where {
18 my($string, $int) = @_;
19 $int >= length($string) ? 1:0;
20 };
21
37821564 22 has short_string => ( is => 'rw', isa => Varchar[5] );
cbac5987 23}
24
25my $obj = Test::MyMooseClass->new(short_string => 'four');
26
27is $obj->short_string, 'four', 'attribute stored correctly';
28
29# this should die
30eval { $obj->short_string('longer') };
31
32like $@, qr/Attribute \(short_string\) does not pass the type constraint/, 'fails on longer string with correct error message';
33
34done_testing;