Don't use $_ as loop variable when calling arbitrary code (RT#81072)
[gitmo/Moo.git] / xt / moox-types.t
1 use strictures 1;
2 use 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
30 my $meta = Class::MOP::class_of('TypeOMatic::Consumer');
31
32 my ($str, $positive_int)
33   = map $meta->get_attribute($_)->type_constraint->name,
34       qw(named_type named_external_type);
35
36 is($str, 'Str', 'Built-in Moose type ok');
37 is(
38   $positive_int, 'MooseX::Types::Common::Numeric::PositiveInt',
39   'External (MooseX::Types type) ok'
40 );
41
42 done_testing;