Skip to content

Commit

Permalink
working example for anonymously created types
Browse files Browse the repository at this point in the history
  • Loading branch information
jjn1056 committed Oct 27, 2010
1 parent ffd6c41 commit 82314ac
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions t/06-anonymous.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 82314ac

Please sign in to comment.