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