Add distributions to author/test-externals.pl
[gitmo/Mouse.git] / t / 039-subtype.t
CommitLineData
c5146d28 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More tests => 2;
5use Test::Exception;
6
7do {
8 package My::Class;
9 use Mouse;
10 use Mouse::Util::TypeConstraints;
11
12 subtype 'NonemptyStr'
13 => as 'Str'
14 => where { length $_ }
15 => message { "The string is empty!" };
16
17 has name => (
18 is => 'ro',
19 isa => 'NonemptyStr',
20 );
21};
22
23ok(My::Class->new(name => 'foo'));
24
29607c02 25throws_ok { My::Class->new(name => '') } qr/^Attribute \(name\) does not pass the type constraint because: The string is empty!/;
c5146d28 26