4 use Test::More tests=>11;
9 use MooseX::Types::Structured qw(Dict Tuple);
10 use MooseX::Types::Moose qw(Int Str Item);
11 use MooseX::Types -declare => [qw(
12 MyDict1 MyDict2 MyDict4
16 as Dict[name=>Str, age=>Int];
19 as Dict[name=>Str, age=>Int];
22 as Dict[name=>Str, age=>Item];
27 TypeLib->import(':all');
30 use Moose::Util::TypeConstraints;
31 use MooseX::Types::Structured qw(Dict Tuple);
32 use MooseX::Types::Moose qw(Item Any);
35 ok ( MyDict2->is_a_type_of(MyDict4),
36 'MyDict2 is_a_type_of MyDict4');
38 ok ( MyDict1->is_subtype_of(MyDict4),
39 'MyDict1 is_subtype_of MyDict4');
41 ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_a_type_of( Tuple[Tuple[ Item, Item ], Dict[]] ),
44 ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_a_type_of( Tuple[Tuple[ Item, Item ], Dict[]] ),
47 ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_subtype_of( Tuple[Tuple[ Item, Item ], Dict[]] ),
50 my $item = subtype as 'Item';
52 ok ( $item->is_subtype_of('Any'),
53 q[$item is subtype of 'Any']);
55 ok ( Item->is_subtype_of('Any'),
56 q[Item is subtype of 'Any']);
58 ok ( $item->is_subtype_of(Any),
59 q[Item is subtype of Any]);
61 ok ( Item->is_subtype_of(Any),
62 q[Item is subtype of Any]);
64 my $any = subtype as 'Any';
66 ok ( ! $item->is_subtype_of($any),
67 q[$item is NOT a subtype of $any]);
69 ok ( ! Item->is_subtype_of($any),
70 q[Item is NOT a subtype of $any]);