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=24dbac4ff888e7c786a07b0d79e07b9afc729e04;hp=9fb344f79978c46b8d0b4b13cf0e56d5a519e84b;hb=eed39dffe505fa8df062e315c23c1fbe36f9c95b;hpb=e15a70e5756560b2d25f0f377b1a255315b6e8d3 diff --git a/t/001_mouse/043-parameterized-type.t b/t/001_mouse/043-parameterized-type.t index 9fb344f..24dbac4 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 +#!perl use strict; use warnings; -use Test::More tests => 54; +use Test::More; use Test::Exception; use Tie::Hash; @@ -222,3 +222,30 @@ else{ # under Moose } is_deeply \%th_clone, \%th, 'the hash iterator is initialized'; + +{ + my $myhashref = subtype 'MyHashRef', + as 'HashRef[Value]', + where { keys %$_ > 1 }; + + 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 => 42, b => [] }); + + is $myhashref->type_parameter, 'Value'; + + $myhashref = subtype 'H', as 'MyHashRef[Int]'; + + 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 => 42, b => [] }); + + is $myhashref->type_parameter, 'Int'; +} + +done_testing; +