From: gfx Date: Fri, 30 Oct 2009 01:03:34 +0000 (+0900) Subject: Add tests for or-combination operator X-Git-Tag: 0.40_03~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b880de945fcf59e9811132613b5bcbca8a6d8696;p=gitmo%2FMouse.git Add tests for or-combination operator --- diff --git a/t/001_mouse/810-isa-or.t b/t/001_mouse/810-isa-or.t index 57b212c..aeb326a 100644 --- a/t/001_mouse/810-isa-or.t +++ b/t/001_mouse/810-isa-or.t @@ -6,7 +6,7 @@ use strict; use warnings; -use Test::More tests => 18; +use Test::More tests => 22; { package Foo; @@ -103,3 +103,19 @@ isa_ok $k->foo, 'KLASS'; $k->foo(undef); is $k->foo, undef, 'foo is undef'; +# or-combination operator ('|') +{ + use Mouse::Util::TypeConstraints; + my $Int = find_type_constraint 'Int'; + my $Str = find_type_constraint 'Str'; + my $Object = find_type_constraint 'Object'; + + *t = \&Mouse::Util::TypeConstraints::find_or_parse_type_constraint; # alias + + is $Int | $Str, t('Int | Str'); + is $Str | $Int, t('Int | Str'); + + is $Int | $Str | $Object, t('Int | Str | Object'); + is $Str | $Object | $Int, t('Int | Str | Object'); +} +