— |
use lib qw( ./lib ./t/lib ../inc ./inc ) ; my $Any = "Type::Tiny" ->new( name => "Anything" );
my $Int = $Any ->create_child_type(
name => "Integer" ,
constraint => sub { defined ( $_ ) and ! ref ( $_ ) and $_ =~ /^[+-]?[0-9]+$/sm },
);
my $mAny = $Any ->mouse_type;
my $mInt = $Int ->mouse_type;
isa_ok( $mAny , 'Mouse::Meta::TypeConstraint' , '$mAny' );
isa_ok( $mInt , 'Mouse::Meta::TypeConstraint' , '$mInt' );
is( $mInt ->parent, $mAny , 'type constraint inheritance seems right' );
should_pass(42, $mAny );
should_pass([], $mAny );
should_pass(42, $mInt );
should_fail([], $mInt );
done_testing;
|