clean up ::Destructor
[gitmo/Moose.git] / t / 040_type_constraints / 010_misc_type_tests.t
index 2cf0985..4b5e1d3 100644 (file)
@@ -3,8 +3,9 @@
 use strict;
 use warnings;
 
-use Test::More tests => 11;
-use Test::Exception;
+use Test::More;
+use Test::Fatal;
+use Scalar::Util qw(refaddr);
 
 BEGIN {
     use_ok('Moose::Util::TypeConstraints');
@@ -12,9 +13,9 @@ BEGIN {
 
 # subtype 'aliasing' ...
 
-lives_ok {
+is( exception {
     subtype 'Numb3rs' => as 'Num';
-} '... create bare subtype fine';
+}, undef, '... create bare subtype fine' );
 
 my $numb3rs = find_type_constraint('Numb3rs');
 isa_ok($numb3rs, 'Moose::Meta::TypeConstraint');
@@ -65,3 +66,24 @@ ok $subtype2 => 'made a subtype of our subtype';
         "correct error thrown"
     );
 }
+
+{
+    for my $t (qw(Bar Foo)) {
+        my $tc = Moose::Meta::TypeConstraint->new({
+            name => $t,
+        });
+
+        Moose::Util::TypeConstraints::register_type_constraint($tc);
+    }
+
+    my $foo = Moose::Util::TypeConstraints::find_type_constraint('Foo');
+    my $bar = Moose::Util::TypeConstraints::find_type_constraint('Bar');
+
+    ok(!$foo->equals($bar), "Foo type is not equal to Bar type");
+    ok( $foo->equals($foo), "Foo equals Foo");
+    ok( 0+$foo == refaddr($foo), "overloading works");
+}
+
+ok $subtype1, "type constraint boolean overload works";
+
+done_testing;