X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=t%2F001_mouse%2F043-parameterized-type.t;fp=t%2F001_mouse%2F043-parameterized-type.t;h=531febbcbb8ad91109e660fbfda6d24bc25f4045;hp=e3e4cdaa2fa752d4bf3b1187622532e8e54f3a73;hb=85b15d5f1644327a51646d5081fa366caae7ac44;hpb=983d58a5ea543a21c48cb04311883f1b36de1874 diff --git a/t/001_mouse/043-parameterized-type.t b/t/001_mouse/043-parameterized-type.t index e3e4cda..531febb 100644 --- a/t/001_mouse/043-parameterized-type.t +++ b/t/001_mouse/043-parameterized-type.t @@ -6,6 +6,7 @@ use Test::Exception; use Tie::Hash; use Tie::Array; + { { package My::Role; @@ -224,7 +225,10 @@ else{ # under Moose is_deeply \%th_clone, \%th, 'the hash iterator is initialized'; -{ + +for my $i(1 .. 2) { + diag "derived from parameterized types #$i"; + my $myhashref = subtype 'MyHashRef', as 'HashRef[Value]', where { keys %$_ > 1 }; @@ -241,9 +245,14 @@ is_deeply \%th_clone, \%th, 'the hash iterator is initialized'; ok $myhashref->is_a_type_of('HashRef'), "$myhashref"; ok $myhashref->check({ a => 43, b => 100 }); - ok !$myhashref->check({ a => 43, b => 3.14 }); - ok !$myhashref->check({}); + ok $myhashref->check({ a => 43, b => 100, c => 0 }); + ok !$myhashref->check({}), 'empty hash'; + ok !$myhashref->check({ foo => 42 }); + ok !$myhashref->check({ a => 43, b => "foo" }); ok !$myhashref->check({ a => 42, b => [] }); + ok !$myhashref->check({ a => 42, b => undef }); + ok !$myhashref->check([42]); + ok !$myhashref->check("foo"); is $myhashref->type_parameter, 'Int'; }