7 use Moose::Util::TypeConstraints;
13 has unknown_class => (
15 isa => 'UnknownClass',
20 does => 'UnknownRole',
27 my $class_tc = $meta->get_attribute('unknown_class')->type_constraint;
28 isa_ok($class_tc, 'Moose::Meta::TypeConstraint::Class');
29 is($class_tc, find_type_constraint('UnknownClass'),
30 "class type is registered");
32 exception { subtype 'UnknownClass', as 'Str'; },
33 qr/The type constraint 'UnknownClass' has already been created in Foo and cannot be created again in main/,
34 "Can't redefine implicitly defined class types"
37 my $role_tc = $meta->get_attribute('unknown_role')->type_constraint;
38 isa_ok($role_tc, 'Moose::Meta::TypeConstraint::Role');
39 is($role_tc, find_type_constraint('UnknownRole'),
40 "role type is registered");
42 exception { subtype 'UnknownRole', as 'Str'; },
43 qr/The type constraint 'UnknownRole' has already been created in Foo and cannot be created again in main/,
44 "Can't redefine implicitly defined class types"