9 use Moo::HandleMoose ();
13 die unless defined $_[0] && !ref $_[0];
15 $Moo::HandleMoose::TYPE_MAP{$type} = sub {
16 require Moose::Util::TypeConstraints;
17 Moose::Util::TypeConstraints::find_type_constraint("Str");
23 die unless defined $_[0] && !ref $_[0] && $_[0] =~ /^-?\d+/;
25 $Moo::HandleMoose::TYPE_MAP{$type} = sub {
26 require Moose::Util::TypeConstraints;
27 require MooseX::Types::Common::Numeric;
28 Moose::Util::TypeConstraints::find_type_constraint(
29 "MooseX::Types::Common::Numeric::PositiveInt");
39 has named_external_type => (
44 package TypeOMatic::Consumer;
46 # do this as late as possible to simulate "real" behaviour
52 my $meta = Class::MOP::class_of('TypeOMatic::Consumer');
54 my ($str, $positive_int)
55 = map $meta->get_attribute($_)->type_constraint->name,
56 qw(named_type named_external_type);
58 is($str, 'Str', 'Built-in Moose type ok');
60 $positive_int, 'MooseX::Types::Common::Numeric::PositiveInt',
61 'External (MooseX::Types type) ok'
69 $Moo::HandleMoose::TYPE_MAP{$isa} = sub { $isa };
70 has barble => (is => "ro", isa => $isa);
71 __PACKAGE__->meta->get_attribute("barble");
76 qr/^error inflating attribute 'barble' for package 'Fooble': \$TYPE_MAP\{CODE\(\w+?\)\} did not return a valid type constraint/,
77 'error message for incorrect type constraint inflation',