X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F040_type_constraints%2F008_union_types.t;h=58e0b269178218e95e128511bb1da9bc6ce11ea9;hb=a098a4a3fa7da540ca8235cf5ab27e37a4f35d70;hp=cff72483c64b9a0aef8dedae0004a183c7aff648;hpb=a28e50e44945358d15eb19e4688573741a319fe0;p=gitmo%2FMoose.git diff --git a/t/040_type_constraints/008_union_types.t b/t/040_type_constraints/008_union_types.t index cff7248..58e0b26 100644 --- a/t/040_type_constraints/008_union_types.t +++ b/t/040_type_constraints/008_union_types.t @@ -30,6 +30,10 @@ ok($Str_or_Undef->check('String'), '... (Str | Undef) can accept a String value' ok($Str_or_Undef->is_a_type_of($Str), "subtype of Str"); ok($Str_or_Undef->is_a_type_of($Undef), "subtype of Undef"); +cmp_ok($Str_or_Undef->find_type_for('String'), 'eq', 'Str', 'find_type_for Str'); +cmp_ok($Str_or_Undef->find_type_for(undef), 'eq', 'Undef', 'find_type_for Undef'); +ok(!defined($Str_or_Undef->find_type_for(sub { })), 'no find_type_for CodeRef'); + ok( !$Str_or_Undef->equals($Str), "not equal to Str" ); ok( $Str_or_Undef->equals($Str_or_Undef), "equal to self" ); ok( $Str_or_Undef->equals(Moose::Meta::TypeConstraint::Union->new(type_constraints => [ $Str, $Undef ])), "equal to clone" ); @@ -67,15 +71,15 @@ ok(!defined($HashOrArray->validate([])), '... (ArrayRef | HashRef) can accept [] ok(!defined($HashOrArray->validate({})), '... (ArrayRef | HashRef) can accept {}'); like($HashOrArray->validate(\(my $var2)), -qr/Validation failed for \'ArrayRef\' failed with value SCALAR\(0x.+?\) and Validation failed for \'HashRef\' failed with value SCALAR\(0x.+?\) in \(ArrayRef\|HashRef\)/, +qr/Validation failed for \'ArrayRef\' with value SCALAR\(0x.+?\) and Validation failed for \'HashRef\' with value SCALAR\(0x.+?\) in \(ArrayRef\|HashRef\)/, '... (ArrayRef | HashRef) cannot accept scalar refs'); like($HashOrArray->validate(sub {}), -qr/Validation failed for \'ArrayRef\' failed with value CODE\(0x.+?\) and Validation failed for \'HashRef\' failed with value CODE\(0x.+?\) in \(ArrayRef\|HashRef\)/, +qr/Validation failed for \'ArrayRef\' with value CODE\(0x.+?\) and Validation failed for \'HashRef\' with value CODE\(0x.+?\) in \(ArrayRef\|HashRef\)/, '... (ArrayRef | HashRef) cannot accept code refs'); is($HashOrArray->validate(50), -'Validation failed for \'ArrayRef\' failed with value 50 and Validation failed for \'HashRef\' failed with value 50 in (ArrayRef|HashRef)', +'Validation failed for \'ArrayRef\' with value 50 and Validation failed for \'HashRef\' with value 50 in (ArrayRef|HashRef)', '... (ArrayRef | HashRef) cannot accept Numbers'); done_testing;