Commit | Line | Data |
eee1a213 |
1 | use strict; |
2 | use warnings; |
3 | |
a28e50e4 |
4 | use Test::More; |
eee1a213 |
5 | use Test::Exception; |
6 | |
7 | use Moose::Meta::TypeConstraint; |
8 | use Moose::Util::TypeConstraints; |
9 | |
10 | |
11 | TODO: |
12 | { |
13 | local $TODO = 'type names are not validated in the TC metaclass'; |
14 | |
15 | throws_ok { Moose::Meta::TypeConstraint->new( name => 'Foo-Bar' ) } |
16 | qr/contains invalid characters/, |
17 | 'Type names cannot contain a dash'; |
18 | } |
19 | |
20 | lives_ok { Moose::Meta::TypeConstraint->new( name => 'Foo.Bar::Baz' ) } |
21 | 'Type names can contain periods and colons'; |
22 | |
23 | throws_ok { subtype 'Foo-Baz' => as 'Item' } |
24 | qr/contains invalid characters/, |
25 | 'Type names cannot contain a dash (via subtype sugar)'; |
26 | |
27 | lives_ok { subtype 'Foo.Bar::Baz' => as 'Item' } |
28 | 'Type names can contain periods and colons (via subtype sugar)'; |
29 | |
30 | is( Moose::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 | |
34 | is( Moose::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' ); |
a28e50e4 |
37 | |
38 | done_testing; |