From: Florian Ragwitz Date: Wed, 3 Feb 2010 05:57:59 +0000 (+0100) Subject: Add failing tests for Optional[]. X-Git-Tag: 0.20~1^2~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ff0781f2e32ece5761542f8cdda51fc384715b98;p=gitmo%2FMooseX-Types-Structured.git Add failing tests for Optional[]. --- diff --git a/t/bug-optional.t b/t/bug-optional.t new file mode 100644 index 0000000..301de29 --- /dev/null +++ b/t/bug-optional.t @@ -0,0 +1,33 @@ +use strict; +use warnings; +use Test::More; + +BEGIN { + package MyTypes; + use MooseX::Types::Structured qw(Dict Tuple Optional); + use MooseX::Types::Moose qw(Object Any); + use MooseX::Types -declare => [qw( + Signature + MyDict + )]; + + subtype Signature, as Tuple[Tuple[Object], Dict[optional => Optional[Any], required => Any]]; + + subtype MyDict, as Dict[optional => Optional[Any], required => Any]; +} + +BEGIN { + MyTypes->import(':all'); +} + +ok(!Signature->check([ [bless {}, 'Foo'], {} ])); + +ok(!MyDict->check({ })); +ok(!MyDict->check({ optional => 42 })); +ok(!MyDict->check({ optional => 42, unknown => 23 })); +ok(!MyDict->check({ required => 42, unknown => 23 })); + +ok(MyDict->check({ optional => 42, required => 23 })); +ok(MyDict->check({ required => 23 })); + +done_testing;