Add assert_valid() to Meta::TypeConstraint
[gitmo/Mouse.git] / t / 040_type_constraints / failing / 033_type_names.t
CommitLineData
b2b106d7 1use strict;
2use warnings;
3
4use Test::More tests => 6;
5use Test::Exception;
6
7use Mouse::Meta::TypeConstraint;
8use Mouse::Util::TypeConstraints;
9
10
11TODO:
12{
13 local $TODO = 'type names are not validated in the TC metaclass';
14
15 throws_ok { Mouse::Meta::TypeConstraint->new( name => 'Foo-Bar' ) }
16 qr/contains invalid characters/,
17 'Type names cannot contain a dash';
18}
19
20lives_ok { Mouse::Meta::TypeConstraint->new( name => 'Foo.Bar::Baz' ) }
21'Type names can contain periods and colons';
22
23throws_ok { subtype 'Foo-Baz' => as 'Item' }
24qr/contains invalid characters/,
25 'Type names cannot contain a dash (via subtype sugar)';
26
27lives_ok { subtype 'Foo.Bar::Baz' => as 'Item' }
28'Type names can contain periods and colons (via subtype sugar)';
29
30is( Mouse::Util::TypeConstraints::find_or_parse_type_constraint('ArrayRef[In-valid]'),
31 undef,
32 'find_or_parse_type_constraint returns undef on an invalid name' );
33
34is( Mouse::Util::TypeConstraints::find_or_parse_type_constraint('ArrayRef[Va.lid]'),
35 'ArrayRef[Va.lid]',
36 'find_or_parse_type_constraint returns name for valid name' );