pod typos
[gitmo/MooseX-Types.git] / t / 21_coerce_parameterized_types.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Test::Exception;
5
6 use Test::More tests => 2;
7
8 BEGIN {
9     package TypeLib;
10     use MooseX::Types -declare => [qw/
11         MyChar MyDigit ArrayRefOfMyCharOrDigit
12     /];
13     use MooseX::Types::Moose qw/ArrayRef Str Int/;
14
15     subtype MyChar, as Str, where {
16         length == 1
17     };
18
19     subtype MyDigit, as Int, where {
20         length == 1
21     };
22
23     coerce ArrayRef[MyChar|MyDigit], from Str, via {
24         [split //]
25     };
26
27 # same thing with an explicit subtype
28     subtype ArrayRefOfMyCharOrDigit, as ArrayRef[MyChar|MyDigit];
29
30     coerce ArrayRefOfMyCharOrDigit, from Str, via {
31         [split //]
32     };
33 }
34
35 {
36     BEGIN { TypeLib->import(qw/
37         MyChar MyDigit ArrayRefOfMyCharOrDigit/
38     ) };
39     use MooseX::Types::Moose 'ArrayRef';
40
41     my $parameterized = ArrayRef[MyChar|MyDigit];
42     { local $::TODO = "see comments in MooseX::Types->create_arged_...";
43       ::ok( $parameterized->has_coercion, 'coercion applied to parameterized type' );
44     }
45
46     my $subtype = ArrayRefOfMyCharOrDigit;
47     ::ok( $subtype->has_coercion, 'coercion applied to subtype' );
48 }
49