[Moose-commits] r7864 - in MooseX-Types-Dependent/trunk: lib/MooseX/Types t

jnapiorkowski at code2.0beta.co.uk jnapiorkowski at code2.0beta.co.uk
Sun Mar 29 18:18:25 BST 2009


Author: jnapiorkowski
Date: 2009-03-29 10:18:24 -0700 (Sun, 29 Mar 2009)
New Revision: 7864

Modified:
   MooseX-Types-Dependent/trunk/lib/MooseX/Types/Dependent.pm
   MooseX-Types-Dependent/trunk/t/01-basic.t
Log:
Got the basic requirement in place!

Modified: MooseX-Types-Dependent/trunk/lib/MooseX/Types/Dependent.pm
===================================================================
--- MooseX-Types-Dependent/trunk/lib/MooseX/Types/Dependent.pm	2009-03-29 17:04:23 UTC (rev 7863)
+++ MooseX-Types-Dependent/trunk/lib/MooseX/Types/Dependent.pm	2009-03-29 17:18:24 UTC (rev 7864)
@@ -21,16 +21,16 @@
           as Depending[
             Int,
             sub {
-              shift->not_exists(shift);
+              shift->exists(shift) ? 0:1;
             },
             Set,
           ];
           
         possible sugar options
         
-        Depending 
-        as Depending sub :Set {} Int;
-        depending(Set $set) { $set->exists($Int) } Int;
+        as Depending {
+                shift->exists(shift) ? 0:1;        
+        } [Int, Set];
         
         May have some ready to go, such as
         as isGreaterThan[

Modified: MooseX-Types-Dependent/trunk/t/01-basic.t
===================================================================
--- MooseX-Types-Dependent/trunk/t/01-basic.t	2009-03-29 17:04:23 UTC (rev 7863)
+++ MooseX-Types-Dependent/trunk/t/01-basic.t	2009-03-29 17:18:24 UTC (rev 7864)
@@ -15,7 +15,7 @@
 	
 	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) = @_;
@@ -31,9 +31,9 @@
 
 	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.";
 }




More information about the Moose-commits mailing list