X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F040_type_constraints%2F010_misc_type_tests.t;fp=t%2F040_type_constraints%2F010_misc_type_tests.t;h=f5cc487dad7f7490f41f36a1ff8cb822e92ce8b6;hb=184f8f53393b72298e3de0132bf8c06d5909dcb9;hp=43fcebc76cf11cc9c06b5e2f827191c4a7a9cc24;hpb=35ce550a1ba037da13228f2bbb8306e101d263d5;p=gitmo%2FMouse.git diff --git a/t/040_type_constraints/010_misc_type_tests.t b/t/040_type_constraints/010_misc_type_tests.t index 43fcebc..f5cc487 100644 --- a/t/040_type_constraints/010_misc_type_tests.t +++ b/t/040_type_constraints/010_misc_type_tests.t @@ -3,8 +3,9 @@ use strict; use warnings; -use Test::More tests => 11; +use Test::More; use Test::Exception; +use Scalar::Util qw(refaddr); BEGIN { use_ok('Mouse::Util::TypeConstraints'); @@ -65,3 +66,24 @@ ok $subtype2 => 'made a subtype of our subtype'; "correct error thrown" ); } + +{ + for my $t (qw(Bar Foo)) { + my $tc = Mouse::Meta::TypeConstraint->new({ + name => $t, + }); + + Mouse::Util::TypeConstraints::register_type_constraint($tc); + } + + my $foo = Mouse::Util::TypeConstraints::find_type_constraint('Foo'); + my $bar = Mouse::Util::TypeConstraints::find_type_constraint('Bar'); + + ok(!$foo->is_a_type_of($bar), "Foo type is not equal to Bar type"); + ok( $foo->is_a_type_of($foo), "Foo equals Foo"); + ok( 0+$foo == refaddr($foo), "overloading works"); +} + +ok $subtype1, "type constraint boolean overload works"; + +done_testing;