From: Graham Knop Date: Fri, 22 Feb 2013 23:19:19 +0000 (-0500) Subject: also test that name is correct for moose types with coercion X-Git-Tag: v1.001000~21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5fe1827a3bd5b80ac007c6c6679f685f7dab8d77;hp=d885d85e8e545b3ef9ac7267aadcfb128e460158;p=gitmo%2FMoo.git also test that name is correct for moose types with coercion --- diff --git a/xt/moox-types-coercion.t b/xt/moox-types-coercion.t index 071a595..28ed12c 100644 --- a/xt/moox-types-coercion.t +++ b/xt/moox-types-coercion.t @@ -1,5 +1,6 @@ use strictures 1; use Test::More; +use Test::Fatal; { package ClassWithTypes; @@ -9,6 +10,7 @@ use Test::More; has split_comma => (is => 'ro', isa => ArrayRef, coerce => sub { [ split /,/, $_[0] ] } ); has split_space => (is => 'ro', isa => ArrayRef, coerce => sub { [ split / /, $_[0] ] } ); + has bad_coerce => (is => 'ro', isa => ArrayRef, coerce => sub { $_[0] } ); } my $o = ClassWithTypes->new(split_comma => 'a,b c,d', split_space => 'a,b c,d'); @@ -25,4 +27,9 @@ my $o2 = MooseSubclassWithTypes->new(split_comma => 'a,b c,d', split_space => 'a is_deeply $o2->split_comma, ['a','b c','d'], 'moose subclass has correct coercion'; is_deeply $o2->split_space, ['a,b','c,d'], ' ... and with different coercion on same type'; +like + exception { MooseSubclassWithTypes->new(bad_coerce => 1) }, + qr/Validation failed for 'ArrayRef' with value/, + 'inflated type has correct name'; + done_testing;