2 use Test::More tests=>9; {
7 use MooseX::Dependent::Types qw(Dependent);
8 use MooseX::Types::Moose qw(Int Str HashRef ArrayRef);
10 use MooseX::Types -declare=>[qw(
17 defined $_->{older_than};
18 }), 'Created InfoHash Set (reduce need to depend on Dict type';
20 ok InfoHash->check({older_than=>25}), 'Good InfoHash';
21 ok !InfoHash->check({older_than=>'aaa'}), 'Bad InfoHash';
22 ok !InfoHash->check({at_least=>25}), 'Bad InfoHash';
24 ok subtype( OlderThanAge,
25 as Dependent[Int, InfoHash],
27 my ($value, $dict) = @_;
28 return $value > $dict->{older_than} ? 1:0;
29 }), 'Created the OlderThanAge subtype';
31 ok OlderThanAge([{older_than=>25}])->check(39), '39 is older than 25';
32 ok OlderThanAge([older_than=>1])->check(9), '9 is older than 1';
33 ok !OlderThanAge([older_than=>1])->check('aaa'), '"aaa" not an int';
34 ok !OlderThanAge([older_than=>10])->check(9), '9 is not older than 10';
39 my ($arrayref, $constraining_value) = @_;
41 $age += $_ for @$arrayref;
45 #warn OlderThanAge([older_than=>1])->coerce([1,2,3,4]);