Move features used only for testing to t/lib/Test/Mouse.pm
[gitmo/Mouse.git] / t / lib / Test / Mouse.pm
index c166c7b..a538ec3 100644 (file)
@@ -53,6 +53,25 @@ sub has_attribute_ok ($$;$) {
     }
 }
 
+# Moose compatible methods/functions
+
+package Mouse::Util::TypeConstraints;
+
+use Mouse::Util::TypeConstraints ();
+
+sub export_type_constraints_as_functions { # TEST ONLY
+    my $into = caller;
+
+    foreach my $type( list_all_type_constraints() ) {
+        my $tc = find_type_constraint($type)->{_compiled_type_constraint};
+        my $as = $into . '::' . $type;
+
+        no strict 'refs';
+        *{$as} = sub{ &{$tc} || undef };
+    }
+    return;
+}
+
 1;
 
 __END__