From: Dave Rolsky Date: Sat, 17 Sep 2011 14:40:30 +0000 (-0500) Subject: Add some tests for a union of two unions X-Git-Tag: 2.0300~43 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=491f96debfd03308962352dcf9e4c701f39ba6b5;p=gitmo%2FMoose.git Add some tests for a union of two unions --- diff --git a/t/type_constraints/union_types.t b/t/type_constraints/union_types.t index 9e5385b..58dddfc 100644 --- a/t/type_constraints/union_types.t +++ b/t/type_constraints/union_types.t @@ -157,4 +157,28 @@ is( 'parent of ArrayRef|HashRef is Ref' ); +my $double_union = Moose::Meta::TypeConstraint::Union->new( + type_constraints => [ $Str_or_Undef, $ArrayRef_or_HashRef ] ); + +is( + $double_union->parent, + find_type_constraint('Item'), + 'parent of (Str|Undef)|(ArrayRef|HashRef) is Item' +); + +ok( + $double_union->is_subtype_of('Item'), + '(Str|Undef)|(ArrayRef|HashRef) is a subtype of Item' +); + +ok( + $double_union->is_a_type_of('Item'), + '(Str|Undef)|(ArrayRef|HashRef) is a type of Item' +); + +ok( + !$double_union->is_a_type_of('Str'), + '(Str|Undef)|(ArrayRef|HashRef) is not a type of Str' +); + done_testing;