new release with updated M::I
[gitmo/MooseX-Types.git] / t / lib / DecoratorLibrary.pm
index 8361866..6ad113c 100644 (file)
@@ -1,6 +1,6 @@
 package DecoratorLibrary;
 
-use MooseX::Types::Moose qw( Str ArrayRef HashRef Int );
+use MooseX::Types::Moose qw( Str ArrayRef HashRef Int Object);
 use MooseX::Types
     -declare => [qw(
         MyArrayRefBase
@@ -13,6 +13,14 @@ use MooseX::Types
         Jobs
         SubOfMyArrayRefInt01
         BiggerInt
+        isFive
+        isTen
+        isFifteen
+        TwoEqualArrayRefs
+        VeryBigInt
+        FiveOrTenOrFifteen
+        WierdIntergersArrayRef1
+        WierdIntergersArrayRef2
     )];
 
 subtype MyArrayRefBase,
@@ -28,23 +36,9 @@ subtype MyArrayRefInt01,
 subtype BiggerInt,
     as Int,
     where {$_>10};
-
-## We can change this when the .61 Moose comes out.  When that happens we will
-## have the correct patch to Moose::Meta::TypeConstraint::Parameterized to let
-## us support parameterizing parameterized subtypes.  When we get this we can
-## then replace the where clause with:
-
-    ##as MyArrayRefInt01[BiggerInt];
-
+    
 subtype SubOfMyArrayRefInt01,
-    as MyArrayRefInt01,
-    where {
-        my $ok_or_not = 1;
-        foreach my $int (@$_) {
-            $ok_or_not = $int>10 ? 1:0
-             if $ok_or_not;
-        } $ok_or_not;
-    };
+    as MyArrayRefInt01[BiggerInt];
 
 coerce MyArrayRefInt01,
     from Str,
@@ -81,4 +75,28 @@ subtype AtLeastOneInt,
 enum Jobs,
     (qw/Programming Teaching Banking/);
     
+subtype isFive,
+ as Int,
+ where { $_ == 5};
+
+subtype isTen,
+ as Int,
+ where { $_ == 10};
+subtype isFifteen,
+ as Int,
+ where { $_ == 15};
+subtype VeryBigInt,
+ as BiggerInt,
+ where {$_>100};
+subtype FiveOrTenOrFifteen,
+ as isFive|isTen|isFifteen;
+
+subtype WierdIntergersArrayRef1,
+ as ArrayRef[FiveOrTenOrFifteen|VeryBigInt];
+
+subtype WierdIntergersArrayRef2,
+ as ArrayRef[FiveOrTenOrFifteen|Object];    
 1;