shut up the test eol complaints
[gitmo/MooseX-Types-Structured.git] / t / regressions / 01-is_type_of.t
1 BEGIN {
2     use strict;
3     use warnings;
4     use Test::More tests=>11;
5 }
6
7 {
8     package TypeLib;
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
13     )];
14
15     subtype MyDict1,
16     as Dict[name=>Str, age=>Int];
17
18     subtype MyDict2,
19     as Dict[name=>Str, age=>Int];
20
21      subtype MyDict4,
22     as Dict[name=>Str, age=>Item];
23
24 }
25
26 BEGIN {
27     TypeLib->import(':all');
28 }
29
30 use Moose::Util::TypeConstraints;
31 use MooseX::Types::Structured qw(Dict Tuple);
32 use MooseX::Types::Moose qw(Item Any);
33
34
35 ok ( MyDict2->is_a_type_of(MyDict4),
36   'MyDict2 is_a_type_of MyDict4');
37
38 ok ( MyDict1->is_subtype_of(MyDict4),
39   'MyDict1 is_subtype_of MyDict4');
40
41 ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_a_type_of( Tuple[Tuple[ Item, Item ], Dict[]] ),
42   "tuple of tuple" );
43
44 ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_a_type_of( Tuple[Tuple[ Item, Item ], Dict[]] ),
45   "tuple of tuple" );
46
47 ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_subtype_of( Tuple[Tuple[ Item, Item ], Dict[]] ),
48   "tuple of tuple" );
49
50 my $item = subtype as 'Item';
51
52 ok ( $item->is_subtype_of('Any'),
53   q[$item is subtype of 'Any']);
54
55 ok ( Item->is_subtype_of('Any'),
56   q[Item is subtype of 'Any']);
57
58 ok ( $item->is_subtype_of(Any),
59   q[Item is subtype of Any]);
60
61 ok ( Item->is_subtype_of(Any),
62   q[Item is subtype of Any]);
63
64 my $any = subtype as 'Any';
65
66 ok ( ! $item->is_subtype_of($any),
67   q[$item is NOT a subtype of $any]);
68
69 ok ( ! Item->is_subtype_of($any),
70   q[Item is NOT a subtype of $any]);