X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F001_mouse%2F043-parameterized-type.t;h=9fb344f79978c46b8d0b4b13cf0e56d5a519e84b;hb=9864f0e4ba233c5f30ad6dc7c484ced43d883d27;hp=74b3ea956d928e8c470b3a5f62780a35efc96ac3;hpb=24dd8fef0e410b79a65dc3faa1a6cacf5719e386;p=gitmo%2FMouse.git diff --git a/t/001_mouse/043-parameterized-type.t b/t/001_mouse/043-parameterized-type.t index 74b3ea9..9fb344f 100644 --- a/t/001_mouse/043-parameterized-type.t +++ b/t/001_mouse/043-parameterized-type.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 51; +use Test::More tests => 54; use Test::Exception; use Tie::Hash; @@ -69,30 +69,30 @@ use Tie::Array; # check bad args throws_ok { Foo->new( foo => { a => 'b' }); - } qr/Attribute \(foo\) does not pass the type constraint because: Validation failed for 'HashRef\[Int\]' failed with value/, "Bad args for hash throws an exception"; + } qr/Attribute \(foo\) does not pass the type constraint because: Validation failed for 'HashRef\[Int\]' with value/, "Bad args for hash throws an exception"; throws_ok { Foo->new( bar => [ a => 'b' ]); - } qr/Attribute \(bar\) does not pass the type constraint because: Validation failed for 'ArrayRef\[Int\]' failed with value/, "Bad args for array throws an exception"; + } qr/Attribute \(bar\) does not pass the type constraint because: Validation failed for 'ArrayRef\[Int\]' with value/, "Bad args for array throws an exception"; throws_ok { Foo->new( complex => [ { a => 1, b => 1 }, { c => "d", e => "f" } ] ) - } qr/Attribute \(complex\) does not pass the type constraint because: Validation failed for 'ArrayRef\[HashRef\[Int\]\]' failed with value/, "Bad args for complex types throws an exception"; + } qr/Attribute \(complex\) does not pass the type constraint because: Validation failed for 'ArrayRef\[HashRef\[Int\]\]' with value/, "Bad args for complex types throws an exception"; throws_ok { Foo->new( my_class => [ 10 ] ); - } qr/Attribute \(my_class\) does not pass the type constraint because: Validation failed for 'ArrayRef\[My::Class\]' failed with value/; + } qr/Attribute \(my_class\) does not pass the type constraint because: Validation failed for 'ArrayRef\[My::Class\]' with value/; throws_ok { Foo->new( my_class => [ {foo => 'bar'} ] ); - } qr/Attribute \(my_class\) does not pass the type constraint because: Validation failed for 'ArrayRef\[My::Class\]' failed with value/; + } qr/Attribute \(my_class\) does not pass the type constraint because: Validation failed for 'ArrayRef\[My::Class\]' with value/; throws_ok { Foo->new( my_role => [ 20 ] ); - } qr/Attribute \(my_role\) does not pass the type constraint because: Validation failed for 'ArrayRef\[My::Role\]' failed with value/; + } qr/Attribute \(my_role\) does not pass the type constraint because: Validation failed for 'ArrayRef\[My::Role\]' with value/; throws_ok { Foo->new( my_role => [ {foo => 'bar'} ] ); - } qr/Attribute \(my_role\) does not pass the type constraint because: Validation failed for 'ArrayRef\[My::Role\]' failed with value/; + } qr/Attribute \(my_role\) does not pass the type constraint because: Validation failed for 'ArrayRef\[My::Role\]' with value/; } { @@ -126,7 +126,7 @@ use Tie::Array; throws_ok { Bar->new(list => [ { 1 => 2 }, 2, 3 ]); - } qr/Attribute \(list\) does not pass the type constraint because: Validation failed for 'Bar::List' failed with value/, "Bad coercion parameter throws an error"; + } qr/Attribute \(list\) does not pass the type constraint because: Validation failed for 'Bar::List' with value/, "Bad coercion parameter throws an error"; } use Mouse::Util::TypeConstraints; @@ -210,4 +210,15 @@ while(my($k, $v) = each %th){ $th_clone{$k} = $v; } +is( $hash_of_int->type_parameter, 'Int' ); + +if('Mouse' eq ('Mo' . 'use')){ # under Mouse + ok $hash_of_int->__is_parameterized(); + ok!$hash_of_int->type_parameter->__is_parameterized(); +} +else{ # under Moose + ok $hash_of_int->can('type_parameter'); + ok!$hash_of_int->type_parameter->can('type_parameter'); +} + is_deeply \%th_clone, \%th, 'the hash iterator is initialized';