just synchronizing the examples and more tests with where clauses
[gitmo/MooseX-Dependent.git] / t / 01-basic.t
index 611cb06..86b12e0 100644 (file)
@@ -15,25 +15,24 @@ use Test::More tests=>9; {
        
        my $dep_tc = MooseX::Meta::TypeConstraint::Dependent->new(
                name => "MooseX::Types::Dependent::Depending" ,
-               parent => find_type_constraint('Int'),
+               parent => find_type_constraint('ArrayRef'),
                dependent_type_constraint=>$int,
                comparison_callback=>sub {
-                       my ($constraining_value, $check_value) = @_;
-                       return $check_value > $constraining_value ? 0:1;
+                       my ($dependent_val, $constraining_val) = @_;
+                       return ($dependent_val > $constraining_val) ? 1:undef;
                },
                constraining_type_constraint =>$int,
                constraint_generator=> sub {
-                       ## Because "shift->(shift,shift)" is not very clear, is it :)
-                       my ($callback, $constraining_value, $check_value) = @_;
-                       return $callback->($constraining_value, $check_value);
+                       my ($dependent_val, $callback, $constraining_val) = @_;
+                       return $callback->($dependent_val, $constraining_val);
                },
        );
 
        isa_ok $dep_tc, 'MooseX::Meta::TypeConstraint::Dependent';
        
-       ok !$dep_tc->check('a',10), "Fails, 'a' is not an Int.";
-       ok !$dep_tc->check(5,'b'), "Fails, 'b' is not an Int either.";
-       ok !$dep_tc->check([4,1]), "Fails, since this isn't an arrayref";
-       ok !$dep_tc->check(5,10), "Fails, 5 is less than 10";
-       ok $dep_tc->check(11,6), "Success, 11 is greater than 6.";
+       ok !$dep_tc->check(['a',10]), "Fails, 'a' is not an Int.";
+       ok !$dep_tc->check([5,'b']), "Fails, 'b' is not an Int either.";
+       ok !$dep_tc->check({4,1}), "Fails, since this isn't an arrayref";
+       ok !$dep_tc->check([5,10]), "Fails, 5 is less than 10";
+       ok $dep_tc->check([11,6]), "Success, 11 is greater than 6.";
 }