Add tests for or-combination operator
[gitmo/Mouse.git] / lib / Mouse / Meta / TypeConstraint.pm
index a35b4d0..30edadd 100644 (file)
@@ -2,7 +2,17 @@ package Mouse::Meta::TypeConstraint;
 use Mouse::Util qw(:meta); # enables strict and warnings
 
 use overload
+    'bool'   => sub { 1 },             # always true
+
     '""'     => sub { $_[0]->name },   # stringify to tc name
+
+    '|'      => sub {                  # or-combination
+        require Mouse::Util::TypeConstraints;
+        return Mouse::Util::TypeConstraints::find_or_parse_type_constraint(
+            "$_[0] | $_[1]",
+        );
+    },
+
     fallback => 1;
 
 use Carp         ();