6 use Test::More tests => 2;
10 use MooseX::Types -declare => [qw/MyChar MyDigit ArrayRefOfMyCharOrDigit/];
11 use MooseX::Types::Moose qw/ArrayRef Str Int/;
13 subtype MyChar, as Str, where {
17 subtype MyDigit, as Int, where {
21 coerce ArrayRef[MyChar|MyDigit], from Str, via {
25 # same thing with an explicit subtype
26 subtype ArrayRefOfMyCharOrDigit, as ArrayRef[MyChar|MyDigit];
28 coerce ArrayRefOfMyCharOrDigit, from Str, via {
35 BEGIN { TypeLib->import(qw/MyChar MyDigit ArrayRefOfMyCharOrDigit/) };
36 use MooseX::Types::Moose 'ArrayRef';
38 has parameterized => (is => 'rw', isa => ArrayRef[MyChar|MyDigit], coerce => 1);
39 has subtype => (is => 'rw', isa => ArrayRefOfMyCharOrDigit, coerce => 1);
42 my $instance = AClass->new;
44 lives_ok { $instance->parameterized('foo') }
45 'coercion applied to parameterized type';
47 lives_ok { $instance->subtype('foo') } 'coercion applied to subtype';