tckect #42992: Method modifiers affect all classes in the whole inheritance tree
[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
a68fed5d 25TODO: {
26 local $TODO = "message is not used";
27 throws_ok { My::Class->new(name => '') } qr/^Attribute \(name\) does not pass the type constraint because: The string is empty!/;
28};
c5146d28 29