From: John Napiorkowski Date: Wed, 27 Oct 2010 00:03:26 +0000 (-0400) Subject: working example for anonymously created types X-Git-Tag: 0.05~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=82314ac815ebec5ade1aeee412fa403d692e943c;p=gitmo%2FMooseX-Dependent.git working example for anonymously created types --- diff --git a/t/06-anonymous.t b/t/06-anonymous.t index a238aea..f2f84dc 100644 --- a/t/06-anonymous.t +++ b/t/06-anonymous.t @@ -3,13 +3,27 @@ use strict; use warnings; use Test::More; +use MooseX::Types; use MooseX::Types::Parameterizable qw(Parameterizable); use MooseX::Types::Moose qw(Int Str); -ok my $varchar = (subtype as Parameterizable[Str, Int], where { $_[1] > length($_[0]); }), - 'Anonymous Type'; +my $varchar = + subtype as Parameterizable[Str, Int], + where { + my ($str, $int) = @_; + $int > length($str); + }; -ok $varchar->parameterize(5)->check('aaa'); -ok !$varchar->parameterize(5)->check('aaaaa'); +ok $varchar, + 'got anonymouse type'; +ok $varchar->parameterize(5)->check('aaa'), + 'smaller than 5'; + +ok !$varchar->parameterize(5)->check('aaaaa'), + 'bigger than 5'; + +ok !$varchar->parameterize(5)->check([1..3]), + 'Not correct type'; + done_testing;