7 use Moose::Meta::TypeConstraint;
8 use Moose::Util::TypeConstraints;
13 local $TODO = 'type names are not validated in the TC metaclass';
15 # Test written in this way to avoid a warning from like(undef, qr...);
17 my $error = exception {
18 Moose::Meta::TypeConstraint->new( name => 'Foo-Bar' )
24 qr/contains invalid characters/,
25 'Type names cannot contain a dash',
28 fail("Type names cannot contain a dash");
32 lives_ok { Moose::Meta::TypeConstraint->new( name => 'Foo.Bar::Baz' ) }
33 'Type names can contain periods and colons';
35 throws_ok { subtype 'Foo-Baz' => as 'Item' }
36 qr/contains invalid characters/,
37 'Type names cannot contain a dash (via subtype sugar)';
39 lives_ok { subtype 'Foo.Bar::Baz' => as 'Item' }
40 'Type names can contain periods and colons (via subtype sugar)';
42 is( Moose::Util::TypeConstraints::find_or_parse_type_constraint('ArrayRef[In-valid]'),
44 'find_or_parse_type_constraint returns undef on an invalid name' );
46 is( Moose::Util::TypeConstraints::find_or_parse_type_constraint('ArrayRef[Va.lid]'),
48 'find_or_parse_type_constraint returns name for valid name' );