Permalink
Browse files

working example for anonymously created types

  • Loading branch information...
1 parent ffd6c41 commit 82314ac815ebec5ade1aeee412fa403d692e943c @jjn1056 committed Oct 27, 2010
Showing with 18 additions and 4 deletions.
  1. +18 −4 t/06-anonymous.t
View
@@ -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.