6 use Test::More tests => 2;
10 use MooseX::Types -declare => [qw/MyType ArrayRefOfMyType/];
11 use MooseX::Types::Moose qw/ArrayRef Str/;
13 subtype MyType, as Str, where {
17 coerce ArrayRef[MyType], from Str, via {
21 # same thing with an explicit subtype
22 subtype ArrayRefOfMyType, as ArrayRef[MyType];
24 coerce ArrayRefOfMyType, from Str, via {
31 BEGIN { TypeLib->import(qw/MyType ArrayRefOfMyType/) };
32 use MooseX::Types::Moose 'ArrayRef';
34 has parameterized => (is => 'rw', isa => ArrayRef[MyType], coerce => 1);
35 has subtype => (is => 'rw', isa => ArrayRefOfMyType, coerce => 1);
38 my $instance = AClass->new;
40 lives_ok { $instance->parameterized('foo') }
41 'coercion applied to parameterized type';
43 lives_ok { $instance->subtype('foo') } 'coercion applied to subtype';