From: Shawn M Moore Date: Thu, 5 Feb 2009 00:46:24 +0000 (+0000) Subject: Failing test for using a custom message in a subtype X-Git-Tag: 0.19~66 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=c5146d28b022be0f0a3112e1780d484de4385727 Failing test for using a custom message in a subtype --- diff --git a/t/039-subtype.t b/t/039-subtype.t new file mode 100644 index 0000000..5c4d9e1 --- /dev/null +++ b/t/039-subtype.t @@ -0,0 +1,26 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More tests => 2; +use Test::Exception; + +do { + package My::Class; + use Mouse; + use Mouse::Util::TypeConstraints; + + subtype 'NonemptyStr' + => as 'Str' + => where { length $_ } + => message { "The string is empty!" }; + + has name => ( + is => 'ro', + isa => 'NonemptyStr', + ); +}; + +ok(My::Class->new(name => 'foo')); + +throws_ok { My::Class->new(name => '') } qr/^Attribute \(name\) does not pass the type constraint because: The string is empty!/; +