X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F21_coerce_parameterized_types.t;h=4a4cf9c8d20f04c6fda24cbe5d8f7075c53aa771;hb=7186792babbd64572f1b227c2666ead4ee549ede;hp=08df149b781f827c12eb8c6bd740d896d2dde6d0;hpb=d46ddd3c6468ef28ced63b72d6285cc2f13e04a7;p=gitmo%2FMooseX-Types.git diff --git a/t/21_coerce_parameterized_types.t b/t/21_coerce_parameterized_types.t index 08df149..4a4cf9c 100644 --- a/t/21_coerce_parameterized_types.t +++ b/t/21_coerce_parameterized_types.t @@ -1,13 +1,14 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::Exception; -use Test::More tests => 2; +use Test::More; BEGIN { package TypeLib; - use MooseX::Types -declare => [qw/MyChar MyDigit ArrayRefOfMyCharOrDigit/]; + use MooseX::Types -declare => [qw/ + MyChar MyDigit ArrayRefOfMyCharOrDigit + /]; use MooseX::Types::Moose qw/ArrayRef Str Int/; subtype MyChar, as Str, where { @@ -29,19 +30,20 @@ BEGIN { [split //] }; } + { - package AClass; - use Moose; - BEGIN { TypeLib->import(qw/MyChar MyDigit ArrayRefOfMyCharOrDigit/) }; + BEGIN { TypeLib->import(qw/ + MyChar MyDigit ArrayRefOfMyCharOrDigit/ + ) }; use MooseX::Types::Moose 'ArrayRef'; - has parameterized => (is => 'rw', isa => ArrayRef[MyChar|MyDigit], coerce => 1); - has subtype => (is => 'rw', isa => ArrayRefOfMyCharOrDigit, coerce => 1); -} - -my $instance = AClass->new; + my $parameterized = ArrayRef[MyChar|MyDigit]; + { local $::TODO = "see comments in MooseX::Types->create_arged_..."; + ::ok( $parameterized->has_coercion, 'coercion applied to parameterized type' ); + } -lives_ok { $instance->parameterized('foo') } - 'coercion applied to parameterized type'; + my $subtype = ArrayRefOfMyCharOrDigit; + ::ok( $subtype->has_coercion, 'coercion applied to subtype' ); +} -lives_ok { $instance->subtype('foo') } 'coercion applied to subtype'; +done_testing();