inlining for overloaded object isa/coerce
[gitmo/Moo.git] / xt / moox-types.t
CommitLineData
ceedd7fc 1use strictures 1;
2use Test::More;
3
4{
5 package TypeOMatic;
6
7 use Moo::Role;
8 use Sub::Quote;
9 use MooX::Types::MooseLike::Base qw(Str);
10 use MooX::Types::MooseLike::Numeric qw(PositiveInt);
11
12 has named_type => (
13 is => 'ro',
14 isa => Str,
15 );
16
17 has named_external_type => (
18 is => 'ro',
19 isa => PositiveInt,
20 );
21
22 package TypeOMatic::Consumer;
23
24 # do this as late as possible to simulate "real" behaviour
25 use Moo::HandleMoose;
26 use Moose;
27 with 'TypeOMatic';
28}
29
30my $meta = Class::MOP::class_of('TypeOMatic::Consumer');
31
32my ($str, $positive_int)
33 = map $meta->get_attribute($_)->type_constraint->name,
34 qw(named_type named_external_type);
35
36is($str, 'Str', 'Built-in Moose type ok');
37is(
38 $positive_int, 'MooseX::Types::Common::Numeric::PositiveInt',
39 'External (MooseX::Types type) ok'
40);
41
42done_testing;