X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F040_type_constraints%2F010_misc_type_tests.t;h=779bcf3f8f9fa959f2e05f5e6f2f0d6d2917c8c2;hb=6b83828f50414e18c31109c8c790158b7c0a7820;hp=8e7a1cfffb53a566a22e00a0cf76e3fce4a3345d;hpb=e59a5c292a333cac504b65ebd4bba20b5e98d796;p=gitmo%2FMoose.git diff --git a/t/040_type_constraints/010_misc_type_tests.t b/t/040_type_constraints/010_misc_type_tests.t index 8e7a1cf..779bcf3 100644 --- a/t/040_type_constraints/010_misc_type_tests.t +++ b/t/040_type_constraints/010_misc_type_tests.t @@ -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,33 @@ 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'; +} + +my $dummy_instance = Test::Moose::Meta::TypeConstraint::Union->new; + +ok $dummy_instance => "Created Instance"; + +isa_ok $dummy_instance, + 'Test::Moose::Meta::TypeConstraint::Union' => 'isa correct type'; + +is "$dummy_instance", "Broken|Test" => + 'Got expected stringification result'; + +my $subtype1 = subtype 'New1' => as $dummy_instance; + +ok $subtype1 => 'made a subtype from our type object'; + +my $subtype2 = subtype 'New2' => as $subtype1; + +ok $subtype2 => 'made a subtype of our subtype';