From: Matt S Trout Date: Wed, 4 Apr 2012 09:51:43 +0000 (+0000) Subject: add test for named types X-Git-Tag: v0.009_015~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ceedd7fc6ac2d98801d03b71b2b4beb3bd2ed7d0;p=gitmo%2FMoo.git add test for named types --- diff --git a/xt/moox-types.t b/xt/moox-types.t new file mode 100644 index 0000000..3f3eef5 --- /dev/null +++ b/xt/moox-types.t @@ -0,0 +1,42 @@ +use strictures 1; +use Test::More; + +{ + package TypeOMatic; + + use Moo::Role; + use Sub::Quote; + use MooX::Types::MooseLike::Base qw(Str); + use MooX::Types::MooseLike::Numeric qw(PositiveInt); + + has named_type => ( + is => 'ro', + isa => Str, + ); + + has named_external_type => ( + is => 'ro', + isa => PositiveInt, + ); + + package TypeOMatic::Consumer; + + # do this as late as possible to simulate "real" behaviour + use Moo::HandleMoose; + use Moose; + with 'TypeOMatic'; +} + +my $meta = Class::MOP::class_of('TypeOMatic::Consumer'); + +my ($str, $positive_int) + = map $meta->get_attribute($_)->type_constraint->name, + qw(named_type named_external_type); + +is($str, 'Str', 'Built-in Moose type ok'); +is( + $positive_int, 'MooseX::Types::Common::Numeric::PositiveInt', + 'External (MooseX::Types type) ok' +); + +done_testing;