fix types with stringifyable TC objects
[gitmo/Moose.git] / t / 040_type_constraints / 010_misc_type_tests.t
index 8e7a1cf..1aa0ba5 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 3;
+use Test::More tests => 8;
 use Test::Exception;
 
 BEGIN {
@@ -17,4 +17,30 @@ lives_ok {
 } '... create bare subtype fine';
 
 my $numb3rs = find_type_constraint('Numb3rs');
-isa_ok($numb3rs, 'Moose::Meta::TypeConstraint');
\ No newline at end of file
+isa_ok($numb3rs, 'Moose::Meta::TypeConstraint');
+
+# subtype with unions
+
+{
+    package Test::Moose::Meta::TypeConstraint::Union;
+    
+    use overload '""' => sub { 'Broken|Test' }, fallback => 1;
+    use Moose;
+    
+    extends 'Moose::Meta::TypeConstraint';
+}
+
+ok my $dummy_instance = Test::Moose::Meta::TypeConstraint::Union->new
+ => "Created Instance";
+
+isa_ok $dummy_instance, 'Test::Moose::Meta::TypeConstraint::Union'
+ => 'isa correct type';
+
+is "$dummy_instance", "Broken|Test"
+ => "Got expected stringification result";
+ok my $subtype1 = subtype('New1', as $dummy_instance)
+ => "made a subtype";
+ok my $subtype2 = subtype('New2', as $subtype1)
+ => "made another subtype";