X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F040_type_constraints%2F013_advanced_type_creation.t;h=8de07c9213548c315002b529a7bd41c7647b196a;hb=a098a4a3fa7da540ca8235cf5ab27e37a4f35d70;hp=bb60379c64d9217ebe113ee8677f01c052b89718;hpb=f1917f58b73bdba0319305bf6260a1fa608593fe;p=gitmo%2FMoose.git diff --git a/t/040_type_constraints/013_advanced_type_creation.t b/t/040_type_constraints/013_advanced_type_creation.t index bb60379..8de07c9 100644 --- a/t/040_type_constraints/013_advanced_type_creation.t +++ b/t/040_type_constraints/013_advanced_type_creation.t @@ -3,12 +3,12 @@ use strict; use warnings; -use Test::More tests => 33; +use Test::More; use Test::Exception; -BEGIN { - use_ok('Moose::Util::TypeConstraints'); - use_ok('Moose::Meta::TypeConstraint::Container'); +BEGIN { + use_ok('Moose::Util::TypeConstraints'); + use_ok('Moose::Meta::TypeConstraint::Parameterized'); } my $r = Moose::Util::TypeConstraints->get_type_constraint_registry; @@ -17,8 +17,8 @@ my $r = Moose::Util::TypeConstraints->get_type_constraint_registry; # Array of Ints or Strings -my $array_of_ints_or_strings = Moose::Util::TypeConstraints::create_container_type_constraint('ArrayRef[Int | Str]'); -isa_ok($array_of_ints_or_strings, 'Moose::Meta::TypeConstraint::Container'); +my $array_of_ints_or_strings = Moose::Util::TypeConstraints::create_parameterized_type_constraint('ArrayRef[Int|Str]'); +isa_ok($array_of_ints_or_strings, 'Moose::Meta::TypeConstraint::Parameterized'); ok($array_of_ints_or_strings->check([ 1, 'two', 3 ]), '... this passed the type check'); ok($array_of_ints_or_strings->check([ 1, 2, 3 ]), '... this passed the type check'); @@ -30,8 +30,8 @@ $r->add_type_constraint($array_of_ints_or_strings); # Array of Ints or HashRef -my $array_of_ints_or_hash_ref = Moose::Util::TypeConstraints::create_container_type_constraint('ArrayRef[Int | HashRef]'); -isa_ok($array_of_ints_or_hash_ref, 'Moose::Meta::TypeConstraint::Container'); +my $array_of_ints_or_hash_ref = Moose::Util::TypeConstraints::create_parameterized_type_constraint('ArrayRef[Int | HashRef]'); +isa_ok($array_of_ints_or_hash_ref, 'Moose::Meta::TypeConstraint::Parameterized'); ok($array_of_ints_or_hash_ref->check([ 1, {}, 3 ]), '... this passed the type check'); ok($array_of_ints_or_hash_ref->check([ 1, 2, 3 ]), '... this passed the type check'); @@ -43,10 +43,10 @@ $r->add_type_constraint($array_of_ints_or_hash_ref); # union of Arrays of Str | Int or Arrays of Int | Hash -# we can't build this using the simplistic parser +# we can't build this using the simplistic parser # we have, so we have to do it by hand - SL -my $pure_insanity = Moose::Util::TypeConstraints::create_type_constraint_union('ArrayRef[Int | Str] | ArrayRef[Int | HashRef]'); +my $pure_insanity = Moose::Util::TypeConstraints::create_type_constraint_union('ArrayRef[Int|Str] | ArrayRef[Int | HashRef]'); isa_ok($pure_insanity, 'Moose::Meta::TypeConstraint::Union'); ok($pure_insanity->check([ 1, {}, 3 ]), '... this passed the type check'); @@ -59,8 +59,8 @@ ok(!$pure_insanity->check([ [], {}, 1 ]), '... this didnt pass the type check'); # Array of Ints -my $array_of_ints = Moose::Util::TypeConstraints::create_container_type_constraint('ArrayRef[Int]'); -isa_ok($array_of_ints, 'Moose::Meta::TypeConstraint::Container'); +my $array_of_ints = Moose::Util::TypeConstraints::create_parameterized_type_constraint('ArrayRef[Int]'); +isa_ok($array_of_ints, 'Moose::Meta::TypeConstraint::Parameterized'); isa_ok($array_of_ints, 'Moose::Meta::TypeConstraint'); ok($array_of_ints->check([ 1, 2, 3, 4 ]), '... [ 1, 2, 3, 4 ] passed successfully'); @@ -73,8 +73,8 @@ ok(!$array_of_ints->check(sub { () }), '... sub { () } failed successfully'); # Array of Array of Ints -my $array_of_array_of_ints = Moose::Util::TypeConstraints::create_container_type_constraint('ArrayRef[ArrayRef[Int]]'); -isa_ok($array_of_array_of_ints, 'Moose::Meta::TypeConstraint::Container'); +my $array_of_array_of_ints = Moose::Util::TypeConstraints::create_parameterized_type_constraint('ArrayRef[ArrayRef[Int]]'); +isa_ok($array_of_array_of_ints, 'Moose::Meta::TypeConstraint::Parameterized'); isa_ok($array_of_array_of_ints, 'Moose::Meta::TypeConstraint'); ok($array_of_array_of_ints->check( @@ -86,8 +86,8 @@ ok(!$array_of_array_of_ints->check( # Array of Array of Array of Ints -my $array_of_array_of_array_of_ints = Moose::Util::TypeConstraints::create_container_type_constraint('ArrayRef[ArrayRef[ArrayRef[Int]]]'); -isa_ok($array_of_array_of_array_of_ints, 'Moose::Meta::TypeConstraint::Container'); +my $array_of_array_of_array_of_ints = Moose::Util::TypeConstraints::create_parameterized_type_constraint('ArrayRef[ArrayRef[ArrayRef[Int]]]'); +isa_ok($array_of_array_of_array_of_ints, 'Moose::Meta::TypeConstraint::Parameterized'); isa_ok($array_of_array_of_array_of_ints, 'Moose::Meta::TypeConstraint'); ok($array_of_array_of_array_of_ints->check( @@ -97,5 +97,4 @@ ok(!$array_of_array_of_array_of_ints->check( [[[ 1, 2, 3 ]], [[ qw/foo bar/ ]]] ), '... [[[ 1, 2, 3 ]], [[ qw/foo bar/ ]]] failed successfully'); - - +done_testing;