6 use Test::More tests => 2;
10 use MooseX::Types -declare => [qw/
11 MyChar MyDigit ArrayRefOfMyCharOrDigit
13 use MooseX::Types::Moose qw/ArrayRef Str Int/;
15 subtype MyChar, as Str, where {
19 subtype MyDigit, as Int, where {
23 coerce ArrayRef[MyChar|MyDigit], from Str, via {
27 # same thing with an explicit subtype
28 subtype ArrayRefOfMyCharOrDigit, as ArrayRef[MyChar|MyDigit];
30 coerce ArrayRefOfMyCharOrDigit, from Str, via {
37 BEGIN { TypeLib->import(qw/
38 MyChar MyDigit ArrayRefOfMyCharOrDigit/
40 use MooseX::Types::Moose 'ArrayRef';
42 local *Moose::Deprecated::deprecated = sub { };
43 has parameterized => (is => 'rw', isa => ArrayRef[MyChar|MyDigit], coerce => 1);
44 has subtype_parameterized => (is => 'rw', isa => ArrayRefOfMyCharOrDigit, coerce => 1);
47 my $instance = AClass->new;
49 { local $TODO = "see comments in MooseX::Types->create_arged_...";
50 lives_ok { $instance->parameterized('foo') }
51 'coercion applied to parameterized type';
54 lives_ok { $instance->subtype_parameterized('foo') }
55 'coercion applied to subtype';