rafl's pathological test case
Yuval Kogman [Sat, 18 Apr 2009 17:44:59 +0000 (19:44 +0200)]
lib/MooseX/Meta/TypeConstraint/Structured.pm
t/06-api.t

index f199370..e674f8b 100644 (file)
@@ -213,9 +213,7 @@ sub is_a_type_of {
     my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
 
     if ( $other->isa(__PACKAGE__) and @{ $other->type_constraints || [] }) {
-        warn "structured ( $self, $other )";
         if ( $self->parent->is_a_type_of($other->parent) ) {
-            warn "related ( $self, $other )";
             return $self->_type_constraints_op_all($other, "is_a_type_of");
         } elsif ( $self->parent->is_a_type_of($other) ) {
             return 1;
index cbfb687..203e2c3 100644 (file)
@@ -1,7 +1,7 @@
 BEGIN {
        use strict;
        use warnings;
-       use Test::More tests=>83;
+       use Test::More tests=>88;
 }
 
 use Moose::Util::TypeConstraints;
@@ -112,6 +112,12 @@ ok (!MyTuple2->is_a_type_of(MyTuple3), 'MyTuple2 NOT is_a_type_of MyTuple3');
 
 ## is_subtype_of
 
+ok ( not((Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->equals( Tuple[Tuple[ Item, Item ], Dict[]] )), "tuple of tuple" );
+ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->equals( Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]] ), "tuple of tuple" );
+ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_a_type_of( Tuple[Tuple[ Item, Item ], Dict[]] ), "tuple of tuple" );
+ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_a_type_of( Tuple[Tuple[ Item, Item ], Dict[]] ), "tuple of tuple" );
+ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_subtype_of( Tuple[Tuple[ Item, Item ], Dict[]] ), "tuple of tuple" );
+
 ok ( MyDict1->is_subtype_of(HashRef), 'MyDict1 is_subtype_of HashRef');
 ok ( MyDict1->is_subtype_of(Dict), 'MyDict1 is_subtype_of Dict');
 ok ( MyDict1->is_subtype_of(MyDict4), 'MyDict1 is_subtype_of MyDict4');