Convert all tests to done_testing.
[gitmo/Moose.git] / t / 040_type_constraints / 010_misc_type_tests.t
index 779bcf3..65987b6 100644 (file)
@@ -3,11 +3,11 @@
 use strict;
 use warnings;
 
-use Test::More tests => 8;
+use Test::More;
 use Test::Exception;
 
 BEGIN {
-    use_ok('Moose::Util::TypeConstraints');           
+    use_ok('Moose::Util::TypeConstraints');
 }
 
 # subtype 'aliasing' ...
@@ -47,3 +47,23 @@ ok $subtype1 => 'made a subtype from our type object';
 my $subtype2 = subtype 'New2' => as $subtype1;
 
 ok $subtype2 => 'made a subtype of our subtype';
+
+# assert_valid
+
+{
+    my $type = find_type_constraint('Num');
+
+    my $ok_1 = eval { $type->assert_valid(1); };
+    ok($ok_1, "we can assert_valid that 1 is of type $type");
+
+    my $ok_2 = eval { $type->assert_valid('foo'); };
+    my $error = $@;
+    ok(! $ok_2, "'foo' is not of type $type");
+    like(
+        $error,
+        qr{validation failed for .\Q$type\E.}i,
+        "correct error thrown"
+    );
+}
+
+done_testing;