[Moose-commits] r7541 - Mouse/trunk/t
sartak at code2.0beta.co.uk
sartak at code2.0beta.co.uk
Thu Feb 5 00:46:24 GMT 2009
Author: sartak
Date: 2009-02-04 16:46:24 -0800 (Wed, 04 Feb 2009)
New Revision: 7541
Added:
Mouse/trunk/t/039-subtype.t
Log:
Failing test for using a custom message in a subtype
Added: Mouse/trunk/t/039-subtype.t
===================================================================
--- Mouse/trunk/t/039-subtype.t (rev 0)
+++ Mouse/trunk/t/039-subtype.t 2009-02-05 00:46:24 UTC (rev 7541)
@@ -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!/;
+
More information about the Moose-commits
mailing list