X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F040_type_constraints%2F018_custom_parameterized_types.t;h=c4969e5c62f56380def2c12f6b12c016bbf3920b;hb=43b9a91cacfa5e209171acd1141e3ad8e8a2d31a;hp=da19c8fc3f78a0e77a4795cbbe25710d0d9eb285;hpb=7e4e1ad46fd4c72845b18df57a80cdc03b47c4c4;p=gitmo%2FMoose.git diff --git a/t/040_type_constraints/018_custom_parameterized_types.t b/t/040_type_constraints/018_custom_parameterized_types.t index da19c8f..c4969e5 100644 --- a/t/040_type_constraints/018_custom_parameterized_types.t +++ b/t/040_type_constraints/018_custom_parameterized_types.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 21; +use Test::More; use Test::Exception; BEGIN { @@ -43,16 +43,25 @@ lives_ok { ok($t->check({ one => 1, two => 2 }), '... validated it correctly'); ok(!$t->check({ one1 => 1, two2 => 2 }), '... validated it correctly'); + + ok( $t->equals($t), "equals to self" ); + ok( !$t->equals($t->parent), "not equal to parent" ); } -my $hoi = Moose::Util::TypeConstraints::find_or_create_type_constraint('AlphaKeyHash[Int]'); +my $hoi = Moose::Util::TypeConstraints::find_or_parse_type_constraint('AlphaKeyHash[Int]'); ok($hoi->check({ one => 1, two => 2 }), '... validated it correctly'); ok(!$hoi->check({ one1 => 1, two2 => 2 }), '... validated it correctly'); ok(!$hoi->check({ one => 'uno', two => 'dos' }), '... validated it correctly'); ok(!$hoi->check({ one1 => 'un', two2 => 'deux' }), '... validated it correctly'); -my $th = Moose::Util::TypeConstraints::find_or_create_type_constraint('Trihash[Bool]'); +ok( $hoi->equals($hoi), "equals to self" ); +ok( !$hoi->equals($hoi->parent), "equals to self" ); +ok( !$hoi->equals(find_type_constraint('AlphaKeyHash')), "not equal to unparametrized self" ); +ok( $hoi->equals( Moose::Meta::TypeConstraint::Parameterized->new( name => "Blah", parent => find_type_constraint("AlphaKeyHash"), type_parameter => find_type_constraint("Int") ) ), "equal to clone" ); +ok( !$hoi->equals( Moose::Meta::TypeConstraint::Parameterized->new( name => "Oink", parent => find_type_constraint("AlphaKeyHash"), type_parameter => find_type_constraint("Str") ) ), "not equal to different parameter" ); + +my $th = Moose::Util::TypeConstraints::find_or_parse_type_constraint('Trihash[Bool]'); ok(!$th->check({ one => 1, two => 1 }), '... validated it correctly'); ok($th->check({ one => 1, two => 0, three => 1 }), '... validated it correctly'); @@ -75,3 +84,4 @@ dies_ok { ); } 'non-containers cannot be parameterized'; +done_testing;