1 use Test::More tests=>8; {
7 use MooseX::Types::Dependent qw(Depending);
8 use MooseX::Types::Moose qw(Int Str Object ArrayRef HashRef Maybe);
9 use MooseX::Types -declare => [qw(
13 subtype IntGreaterThanInt,
17 my ($dependent_val, $constraining_val) = @_;
18 return ($dependent_val > $constraining_val) ? 1:undef;
23 isa_ok IntGreaterThanInt, 'MooseX::Meta::TypeConstraint::Dependent';
25 ok !IntGreaterThanInt->check(['a',10]), "Fails, 'a' is not an Int.";
26 ok !IntGreaterThanInt->check([5,'b']), "Fails, 'b' is not an Int either.";
27 ok !IntGreaterThanInt->check({4,1}), "Fails, since this isn't an arrayref";
28 ok !IntGreaterThanInt->check([5,10]), "Fails, 5 is less than 10";
29 ok IntGreaterThanInt->check([11,6]), "Success, 11 is greater than 6.";
30 ok IntGreaterThanInt->check([12,1]), "Success, 12 is greater than1.";
31 ok IntGreaterThanInt->check([0,-10]), "Success, 0 is greater than -10.";