From: John Napiorkowski Date: Wed, 23 Jun 2010 18:30:06 +0000 (-0400) Subject: start renaming to parameterized X-Git-Tag: 0.01~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=88f7dcd23a5adc905f0fd92f9bcfdb01ccbb5e99;p=gitmo%2FMooseX-Dependent.git start renaming to parameterized --- diff --git a/Changes b/Changes index f265ea9..56e6cfc 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,4 @@ -Revision history for MooseX-Types-Structured +Revision history for MooseX-Types-Parameterized 0.01 29 March 2009 - Completed basic requirements, documentation and tests.: diff --git a/Makefile.PL b/Makefile.PL index da14559..7cd3009 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -3,10 +3,10 @@ use strict; use warnings; use inc::Module::Install 1.00; -name 'MooseX-Dependent'; -all_from 'lib/MooseX/Dependent.pm'; +name 'MooseX-Parameterizable-Types'; +all_from 'lib/MooseX/Parameterizable/Types.pm'; author 'John Napiorkowski '; -repository 'git://git.moose.perl.org/MooseX-Dependent.git' +## repository 'git://git.moose.perl.org/MooseX-Parameterizable.git' license 'perl'; diff --git a/lib/MooseX/Dependent.pm b/lib/MooseX/Dependent.pm deleted file mode 100644 index 7d6a9c2..0000000 --- a/lib/MooseX/Dependent.pm +++ /dev/null @@ -1,142 +0,0 @@ -package MooseX::Dependent; - -use 5.008; - -use strict; -use warnings; - -our $VERSION = '0.01'; -our $AUTHORITY = 'cpan:JJNAPIORK'; - -=head1 NAME - -MooseX::Dependent - Dependent L constraints and L attributes - -=head1 SYNOPSIS - -Given some L declared as: - - package MyApp::Types; - - use MooseX::Types::Moose qw(Object, Int); - use MooseX::Dependent::Types qw(Dependent); - use Moosex::Types -declare => [qw(Set UniqueInt)]; - - use Set::Scalar; - - subtype Set, - as class_type("Set::Scalar"); - - subtype UniqueInt, - as Dependent[Int, Set], - where { - my ($int, $set) = @_; - return !$set->has($int) ; - }; - -Assuming 'Set' is a class that creates and manages sets of values (lists of -unique but unordered values) with a method '->has($n)', which returns true when -$n is a member of the set and which you instantiate like so: - - my $set_obj = Set->new(1,2,3,4,5); ## 1..5 are member of Set $set_obj' - -You can then use this $set_obj as a parameter on the previously declared type -constraint 'UniqueInt'. This $set_obj become part of the constraint (you can't -actually use the constraint without it.) - - UniqueInt([$set_obj])->check(1); ## Not OK, since one isn't unique in $set_obj - UniqueInt([$set_obj])->check('AAA'); ## Not OK, since AAA is not an Int - UniqueInt([$set_obj])->check(100); ## OK, since 100 isn't in the set. - -You can assign the result of a parameterized dependent type to a variable or to -another type constraint, as like any other type constraint: - - ## As variable - my $unique = UniqueInt[$set_obj]; - $unique->check(10); ## OK - $unique->check(2); ## Not OK, '2' is already in the set. - - ## As a new subtype - subtype UniqueInSet, as UniqueInt[$set_obj]; - UniqueInSet->check(99); ## OK - UniqueInSet->check(3); ## Not OK, '3' is already in the set. - -However, you can't use a dependent type constraint to check or validate a value -until you've parameterized the dependent value: - - UniqueInt->check(1000); ## Throws exception - UniqueInt->validate(1000); ## Throws exception also - -This is a hard exception, rather than just returning a failure message (via the -validate method) or a false boolean (via the check method) since I consider an -unparameterized type constraint to be more than just an invalid condition. You -will have to catch these in an eval if you think you might have them. - -Afterward, you can use these dependent types on your L based classes -and set the dependency target to the value of another attribute or method: - - TDB: Following is tentative - - package MyApp::MyClass; - - use Moose; - use MooseX::Dependent (or maybe a role, or traits...?) - use MooseX::Types::Moose qw(); - use MyApp::Types qw(UniqueInt Set); - - has people => (is=>'ro', isa=>Set, required=>1); - has id => (is=>'ro', dependent_isa=>UniqueInt, required=>1); - - TODO notes, coerce=>1 should coerce both check value and constraining value - -Please see the test cases for more examples. - -=head1 DESCRIPTION - -A dependent type is a type constraint whose validity is dependent on a second -value. You defined the dependent type constraint with a primary type constraint -(such as 'Int') a 'constraining' value type constraint (such as a 'Set' object) -and a coderef (such as a 'where' clause in your type constraint declaration) -which will compare the incoming value to be checked with a value that conforms -to the constraining type constraint. - -Once created, you can use dependent types directly, or in your L based -attributes and methods (if you are using L). Attribute traits -are available to make it easy to assign the dependency to the value of another -attribute or another method. - -A Dependent Type Constraint should be a 'drop in' replacement for any place you -need the parent type (the type constraint being made dependent). For example, -if you are expecting an 'Int' type, you can use the 'UniqueInt' type constraint -as described above, since a UniqueInt is considered a subtype of Int. - -=head1 TYPE CONSTRAINTS - -All type constraints are defined in L. Please see -that class for more documentation and examples of how to create type constraint -libraries using dependent types. - -=cut - -=head1 ATTRIBUTE TRAITS - - TBD - -=head1 SEE ALSO - -L, L, L - -=head1 AUTHOR - -John Napiorkowski, C<< >> - -=head1 COPYRIGHT & LICENSE - -Copyright 2009, John Napiorkowski C<< >> - -This program is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut - -1; diff --git a/lib/MooseX/Dependent/Meta/TypeCoercion/Dependent.pm b/lib/MooseX/Parameterizable/Meta/TypeCoercion/Parameterizable.pm similarity index 82% rename from lib/MooseX/Dependent/Meta/TypeCoercion/Dependent.pm rename to lib/MooseX/Parameterizable/Meta/TypeCoercion/Parameterizable.pm index 9cb10b4..1f39519 100644 --- a/lib/MooseX/Dependent/Meta/TypeCoercion/Dependent.pm +++ b/lib/MooseX/Parameterizable/Meta/TypeCoercion/Parameterizable.pm @@ -1,12 +1,12 @@ package ## Hide from PAUSE - MooseX::Dependent::Meta::TypeCoercion::Dependent; + MooseX::Parameterizable::Meta::TypeCoercion::Parameterizable; use Moose; extends 'Moose::Meta::TypeCoercion'; =head1 NAME -MooseX::Meta::TypeCoercion::Dependent - Coerce Dependent type constraints. +MooseX::Meta::TypeCoercion::Parameterizable - Coerce Parameterizable type constraints. =head1 DESCRIPTION @@ -20,9 +20,9 @@ This class defines the following methods. =head add_type_coercions method modification to throw exception should we try to add a coercion on a -dependent type that is already defined by a constraining value. We do this -since defined dependent type constraints inherit their coercion from the parent -constraint. It makes no sense to even be using dependent types if you know the +parameterizable type that is already defined by a constraining value. We do this +since defined parameterizable type constraints inherit their coercion from the parent +constraint. It makes no sense to even be using parameterizable types if you know the constraining value beforehand! =cut @@ -30,7 +30,7 @@ constraining value beforehand! around 'add_type_coercions' => sub { my ($add_type_coercions, $self, @args) = @_; if($self->type_constraint->has_constraining_value) { - Moose->throw_error("Cannot add type coercions to a dependent type constraint that's been defined."); + Moose->throw_error("Cannot add type coercions to a parameterizable type constraint that's been defined."); } else { return $self->$add_type_coercions(@args); } diff --git a/lib/MooseX/Dependent/Meta/TypeConstraint/Dependent.pm b/lib/MooseX/Parameterizable/Meta/TypeConstraint/Parameterizable.pm similarity index 90% rename from lib/MooseX/Dependent/Meta/TypeConstraint/Dependent.pm rename to lib/MooseX/Parameterizable/Meta/TypeConstraint/Parameterizable.pm index 359685d..3dedf12 100644 --- a/lib/MooseX/Dependent/Meta/TypeConstraint/Dependent.pm +++ b/lib/MooseX/Parameterizable/Meta/TypeConstraint/Parameterizable.pm @@ -1,9 +1,9 @@ package ## Hide from PAUSE - MooseX::Dependent::Meta::TypeConstraint::Dependent; + MooseX::Parameterizable::Meta::TypeConstraint::Parameterizable; use Moose; use Moose::Util::TypeConstraints (); -use MooseX::Dependent::Meta::TypeCoercion::Dependent; +use MooseX::Parameterizable::Meta::TypeCoercion::Parameterizable; use Scalar::Util qw(blessed); use Data::Dump; use Digest::MD5; @@ -12,13 +12,13 @@ extends 'Moose::Meta::TypeConstraint'; =head1 NAME -MooseX::Dependent::Meta::TypeConstraint::Dependent - Metaclass for Dependent type constraints. +MooseX::Parameterizable::Meta::TypeConstraint::Parameterizable - Metaclass for Parameterizable type constraints. =head1 DESCRIPTION -see L for examples and details of how to use dependent +see L for examples and details of how to use parameterizable types. This class is a subclass of L which -provides the gut functionality to enable dependent type constraints. +provides the gut functionality to enable parameterizable type constraints. This class is not intended for public consumption. Please don't subclass it or rely on it. Chances are high stuff here is going to change a lot. For @@ -31,7 +31,7 @@ This class defines the following attributes. =head2 parent_type_constraint -The type constraint whose validity is being made dependent. +The type constraint whose validity is being made parameterizable. =cut @@ -48,7 +48,7 @@ has 'parent_type_constraint' => ( =head2 constraining_value_type_constraint This is a type constraint which defines what kind of value is allowed to be the -constraining value of the dependent type. +constraining value of the parameterizable type. =cut @@ -82,13 +82,13 @@ Do some post build stuff =cut -## Right now I add in the dependent type coercion until I can merge some Moose +## Right now I add in the parameterizable type coercion until I can merge some Moose ## changes upstream around 'new' => sub { my ($new, $class, @args) = @_; my $self = $class->$new(@args); - my $coercion = MooseX::Dependent::Meta::TypeCoercion::Dependent->new(type_constraint => $self); + my $coercion = MooseX::Parameterizable::Meta::TypeCoercion::Parameterizable->new(type_constraint => $self); $self->coercion($coercion); return $self; }; @@ -207,7 +207,7 @@ sub parameterize { =head2 _generate_subtype_name -Returns a name for the dependent type that should be unique +Returns a name for the parameterizable type that should be unique =cut @@ -240,9 +240,9 @@ around 'create_child_type' => sub { =head2 equals ($type_constraint) -Override the base class behavior so that a dependent type equal both the parent -type and the overall dependent container. This behavior may change if we can -figure out what a dependent type is (multiply inheritance or a role...) +Override the base class behavior so that a parameterizable type equal both the parent +type and the overall parameterizable container. This behavior may change if we can +figure out what a parameterizable type is (multiply inheritance or a role...) =cut @@ -266,8 +266,8 @@ around 'equals' => sub { =head2 is_subtype_of -Method modifier to make sure we match on subtype for both the dependent type -as well as the type being made dependent +Method modifier to make sure we match on subtype for both the parameterizable type +as well as the type being made parameterizable =cut diff --git a/lib/MooseX/Dependent/Types.pm b/lib/MooseX/Parameterizable/Types.pm similarity index 76% rename from lib/MooseX/Dependent/Types.pm rename to lib/MooseX/Parameterizable/Types.pm index b23e750..7608d10 100644 --- a/lib/MooseX/Dependent/Types.pm +++ b/lib/MooseX/Parameterizable/Types.pm @@ -1,24 +1,29 @@ -package MooseX::Dependent::Types; +package MooseX::Parameterizable::Types; + +use 5.008; + +our $VERSION = '0.01'; +$VERSION = eval $VERSION; use Moose::Util::TypeConstraints; -use MooseX::Dependent::Meta::TypeConstraint::Dependent; -use MooseX::Types -declare => [qw(Dependent)]; +use MooseX::Parameterizable::Meta::TypeConstraint::Parameterizable; +use MooseX::Types -declare => [qw(Parameterizable)]; =head1 NAME -MooseX::Dependent::Types - L constraints that depend on values. +MooseX::Parameterizable::Types - Create your own Parameterizable Types. =head1 SYNOPSIS Within your L declared library module: - use MooseX::Dependent::Types qw(Dependent); + use MooseX::Parameterizable::Types qw(Parameterizable); subtype Set, as class_type("Set::Scalar"); subtype UniqueInt, - as Dependent[Int, Set], + as Parameterizable[Int, Set], where { my ($int, $set) = @_; return !$set->has($int); @@ -50,7 +55,7 @@ Within your L declared library module: =head1 DESCRIPTION -A L library for creating dependent types. A dependent type +A L library for creating parameterizable types. A parameterizable type constraint for all intents and uses is a subclass of a parent type, but adds a secondary type parameter which is available to constraint callbacks (such as inside the 'where' clause) or in the coercions. @@ -67,7 +72,7 @@ for a integer, such as in: }; subtype RangedInt, - as Dependent[Int, Range], + as Parameterizable[Int, Range], where { my ($value, $range) = @_; return ($value >= $range->{min} && @@ -92,7 +97,7 @@ values first, as in: RangedInt($range)->check(99); } -Please note that for ArrayRef or HashRef dependent type constraints, as in the +Please note that for ArrayRef or HashRef parameterizable type constraints, as in the example above, as a convenience we automatically ref the incoming type parameters, so that the above could also be written as: @@ -113,14 +118,14 @@ parameters. This seems to have something to do with the precendent level of "->". Patches or thoughts welcomed. You only need to do this in the above case which I imagine is not a very common case. -==head2 Subtyping a Dependent type constraints +==head2 Subtyping a Parameterizable type constraints -When subclassing a dependent type you must be careful to match either the +When subclassing a parameterizable type you must be careful to match either the required type parameter type constraint, or if re-parameterizing, the new type constraints are a subtype of the parent. For example: subtype RangedInt, - as Dependent[Int, Range], + as Parameterizable[Int, Range], where { my ($value, $range) = @_; return ($value >= $range->{min} && @@ -153,42 +158,42 @@ Or you could have done the following instead: subtype PositiveRangedInt, as RangedInt[PositiveRange]; -Notice how re-parameterizing the dependent type 'RangedInt' works slightly +Notice how re-parameterizing the parameterizable type 'RangedInt' works slightly differently from re-parameterizing 'PositiveRange' Although it initially takes -two type constraint values to declare a dependent type, should you wish to +two type constraint values to declare a parameterizable type, should you wish to later re-parameterize it, you only use a subtype of the second type parameter -(the dependent type constraint) since the first type constraint sets the parent -type for the dependent type. In other words, given the example above, a type -constraint of 'RangedInt' would have a parent of 'Int', not 'Dependent' and for +(the parameterizable type constraint) since the first type constraint sets the parent +type for the parameterizable type. In other words, given the example above, a type +constraint of 'RangedInt' would have a parent of 'Int', not 'Parameterizable' and for all intends and uses you could stick it wherever you'd need an Int. subtype NameAge, as Tuple[Str, Int]; - ## re-parameterized subtypes of NameAge containing a Dependent Int + ## re-parameterized subtypes of NameAge containing a Parameterizable Int subtype NameBetween18and35Age, as NameAge[ Str, PositiveRangedInt[min=>18,max=>35], ]; -One caveat is that you can't stick an unparameterized dependent type inside a +One caveat is that you can't stick an unparameterized parameterizable type inside a structure, such as L since that would require the -ability to convert a 'containing' type constraint into a dependent type, which +ability to convert a 'containing' type constraint into a parameterizable type, which is a capacity we current don't have. =head2 Coercions -Dependent types have some limited support for coercions. Several things must +Parameterizable types have some limited support for coercions. Several things must be kept in mind. The first is that the coercion targets the type constraint -which is being made dependent, Not the dependent type. So for example if you -create a Dependent type like: +which is being made parameterizable, Not the parameterizable type. So for example if you +create a Parameterizable type like: subtype RequiredAgeInYears, as Int; subtype PersonOverAge, - as Dependent[Person, RequiredAgeInYears] + as Parameterizable[Person, RequiredAgeInYears] where { my ($person, $required_years_old) = @_; return $person->years_old > $required_years_old; @@ -212,7 +217,7 @@ This coercion would then apply to all the following: PersonOverAge([18])->check(30); ## via the Int coercion PersonOverAge([18])->check({age=>50}); ## via the Dict coercion -However, you are not allowed to place coercions on dependent types that have +However, you are not allowed to place coercions on parameterizable types that have had their constraining value filled, nor subtypes of such. For example: coerce PersonOverAge[18], @@ -228,7 +233,7 @@ it is available to the constraint. ## Create a type constraint where a Person must be in the set subtype PersonInSet, - as Dependent[Person, PersonSet], + as Parameterizable[Person, PersonSet], where { my ($person, $person_set) = @_; $person_set->find($person); @@ -249,10 +254,10 @@ it is available to the constraint. This type library defines the following constraints. -=head2 Dependent[ParentTypeConstraint, DependentValueTypeConstraint] +=head2 Parameterizable[ParentTypeConstraint, ParameterizableValueTypeConstraint] Create a subtype of ParentTypeConstraint with a dependency on a value that can -pass the DependentValueTypeConstraint. If DependentValueTypeConstraint is empty +pass the ParameterizableValueTypeConstraint. If ParameterizableValueTypeConstraint is empty we default to the 'Any' type constraint (see L). This creates a type constraint which must be further parameterized at later time @@ -262,8 +267,8 @@ will cause an exception. =cut Moose::Util::TypeConstraints::get_type_constraint_registry->add_type_constraint( - MooseX::Dependent::Meta::TypeConstraint::Dependent->new( - name => 'MooseX::Dependent::Types::Dependent', + MooseX::Parameterizable::Meta::TypeConstraint::Parameterizable->new( + name => 'MooseX::Parameterizable::Types::Parameterizable', parent => find_type_constraint('Any'), constraint => sub {1}, ) diff --git a/t/00-load.t b/t/00-load.t index 811a91f..8a3706f 100644 --- a/t/00-load.t +++ b/t/00-load.t @@ -1,13 +1,9 @@ +use Test::More tests=>3; -use Test::More tests=>4; { - - use strict; - use warnings; - - ## List all the modules we want to make sure can at least compile - use_ok 'MooseX::Dependent'; - use_ok 'MooseX::Dependent::Types'; - use_ok 'MooseX::Dependent::Meta::TypeConstraint::Dependent'; - use_ok 'MooseX::Dependent::Meta::TypeCoercion::Dependent'; -} +use strict; +use warnings; + +use_ok 'MooseX::Parameterizable::Types'; +use_ok 'MooseX::Parameterizable::Meta::TypeConstraint::Parameterizable'; +use_ok 'MooseX::Parameterizable::Meta::TypeCoercion::Parameterizable'; diff --git a/t/01-types-dependent.t b/t/01-types-parameterizable.t similarity index 68% rename from t/01-types-dependent.t rename to t/01-types-parameterizable.t index 2417184..deb719e 100644 --- a/t/01-types-dependent.t +++ b/t/01-types-parameterizable.t @@ -4,82 +4,82 @@ use Test::More tests=>79; { use strict; use warnings; - use MooseX::Dependent::Types qw(Dependent); + use MooseX::Parameterizable::Types qw(Parameterizable); use MooseX::Types::Moose qw(Int Any Maybe); use Moose::Util::TypeConstraints; - use MooseX::Types -declare=>[qw(SubDependent IntLessThan EvenInt + use MooseX::Types -declare=>[qw(SubParameterizable IntLessThan EvenInt LessThan100GreatThen5andEvenIntNot44 IntNot54 GreatThen5andEvenIntNot54or64)]; - ok Dependent->check(1), - 'Dependent is basically an "Any"'; + ok Parameterizable->check(1), + 'Parameterizable is basically an "Any"'; - is Dependent->validate(1), undef, + is Parameterizable->validate(1), undef, 'No Error Message'; - is Dependent->parent, 'Any', - 'Dependent is an Any'; + is Parameterizable->parent, 'Any', + 'Parameterizable is an Any'; - is Dependent->name, 'MooseX::Dependent::Types::Dependent', - 'Dependent has expected name'; + is Parameterizable->name, 'MooseX::Parameterizable::Types::Parameterizable', + 'Parameterizable has expected name'; - like Dependent->get_message, - qr/Validation failed for 'MooseX::Dependent::Types::Dependent' with value undef/, + like Parameterizable->get_message, + qr/Validation failed for 'MooseX::Parameterizable::Types::Parameterizable' with value undef/, 'Got Expected Message'; - ok Dependent->equals(Dependent), - 'Dependent equal Dependent'; + ok Parameterizable->equals(Parameterizable), + 'Parameterizable equal Parameterizable'; - ok Dependent->is_a_type_of(Dependent), - 'Dependent is_a_type_of Dependent'; + ok Parameterizable->is_a_type_of(Parameterizable), + 'Parameterizable is_a_type_of Parameterizable'; - ok Dependent->is_a_type_of('Any'), - 'Dependent is_a_type_of Any'; + ok Parameterizable->is_a_type_of('Any'), + 'Parameterizable is_a_type_of Any'; - ok Dependent->is_subtype_of('Any'), - 'Dependent is_subtype_of Dependent'; + ok Parameterizable->is_subtype_of('Any'), + 'Parameterizable is_subtype_of Parameterizable'; - is Dependent->parent_type_constraint, 'Any', + is Parameterizable->parent_type_constraint, 'Any', 'Correct parent type'; - is subtype( SubDependent, as Dependent ), - 'main::SubDependent', + is subtype( SubParameterizable, as Parameterizable ), + 'main::SubParameterizable', 'Create a useless subtype'; - ok SubDependent->check(1), - 'SubDependent is basically an "Any"'; + ok SubParameterizable->check(1), + 'SubParameterizable is basically an "Any"'; - is SubDependent->validate(1), undef, + is SubParameterizable->validate(1), undef, 'validate returned no error message'; - is SubDependent->parent, 'MooseX::Dependent::Types::Dependent', - 'SubDependent is a Dependent'; + is SubParameterizable->parent, 'MooseX::Parameterizable::Types::Parameterizable', + 'SubParameterizable is a Parameterizable'; - is SubDependent->name, 'main::SubDependent', - 'Dependent has expected name'; + is SubParameterizable->name, 'main::SubParameterizable', + 'Parameterizable has expected name'; - like SubDependent->get_message, - qr/Validation failed for 'main::SubDependent' with value undef/, + like SubParameterizable->get_message, + qr/Validation failed for 'main::SubParameterizable' with value undef/, 'Got Expected Message'; - ok SubDependent->equals(SubDependent), - 'SubDependent equal SubDependent'; + ok SubParameterizable->equals(SubParameterizable), + 'SubParameterizable equal SubParameterizable'; - ok !SubDependent->equals(Dependent), - 'SubDependent does not equal Dependent'; + ok !SubParameterizable->equals(Parameterizable), + 'SubParameterizable does not equal Parameterizable'; - ok SubDependent->is_a_type_of(Dependent), - 'SubDependent is_a_type_of Dependent'; + ok SubParameterizable->is_a_type_of(Parameterizable), + 'SubParameterizable is_a_type_of Parameterizable'; - ok SubDependent->is_a_type_of(Any), - 'SubDependent is_a_type_of Any'; + ok SubParameterizable->is_a_type_of(Any), + 'SubParameterizable is_a_type_of Any'; - ok SubDependent->is_subtype_of('Any'), - 'SubDependent is_subtype_of Dependent'; + ok SubParameterizable->is_subtype_of('Any'), + 'SubParameterizable is_subtype_of Parameterizable'; - ok !SubDependent->is_subtype_of(SubDependent), - 'SubDependent is not is_subtype_of SubDependent'; + ok !SubParameterizable->is_subtype_of(SubParameterizable), + 'SubParameterizable is not is_subtype_of SubParameterizable'; ok subtype( EvenInt, as Int, @@ -94,7 +94,7 @@ use Test::More tests=>79; { ok EvenInt->check(2), 'but 2 is!'; ok subtype( IntLessThan, - as Dependent[EvenInt, Maybe[Int]], + as Parameterizable[EvenInt, Maybe[Int]], where { my $value = shift @_; my $constraining = shift @_ || 200; @@ -134,8 +134,8 @@ use Test::More tests=>79; { is IntLessThan->name, 'main::IntLessThan', 'Got correct name for IntLessThan'; - is IntLessThan->parent, 'MooseX::Dependent::Types::Dependent[main::EvenInt, Maybe[Int]]', - 'IntLessThan is a Dependent'; + is IntLessThan->parent, 'MooseX::Parameterizable::Types::Parameterizable[main::EvenInt, Maybe[Int]]', + 'IntLessThan is a Parameterizable'; is IntLessThan->parent_type_constraint, EvenInt, 'Parent is an Int'; @@ -146,14 +146,14 @@ use Test::More tests=>79; { ok IntLessThan->equals(IntLessThan), 'IntLessThan equals IntLessThan'; - ok IntLessThan->is_subtype_of(Dependent), - 'IntLessThan is_subtype_of Dependent'; + ok IntLessThan->is_subtype_of(Parameterizable), + 'IntLessThan is_subtype_of Parameterizable'; ok IntLessThan->is_subtype_of(Int), 'IntLessThan is_subtype_of Int'; - ok IntLessThan->is_a_type_of(Dependent), - 'IntLessThan is_a_type_of Dependent'; + ok IntLessThan->is_a_type_of(Parameterizable), + 'IntLessThan is_a_type_of Parameterizable'; ok IntLessThan->is_a_type_of(Int), 'IntLessThan is_a_type_of Int'; @@ -277,8 +277,4 @@ use Test::More tests=>79; { qr/Validation failed for 'main::IntNot54' with value 54/, 'Got Expected Error'; } - - #die IntLessThan->validate(100); - #use Data::Dump qw/dump/; - #warn dump IntLessThan; } diff --git a/t/02-types-dependent-extended.t b/t/02-types-parameterizable-extended.t similarity index 96% rename from t/02-types-dependent-extended.t rename to t/02-types-parameterizable-extended.t index 78ea8e1..37b6151 100644 --- a/t/02-types-dependent-extended.t +++ b/t/02-types-parameterizable-extended.t @@ -15,7 +15,7 @@ use Test::More; { } use MooseX::Types::Structured qw(Tuple Dict slurpy); - use MooseX::Dependent::Types qw(Dependent); + use MooseX::Parameterizable::Types qw(Parameterizable); use MooseX::Types::Moose qw(Int Str); use Moose::Util::TypeConstraints; @@ -28,11 +28,11 @@ use Test::More; { ok subtype( Set, as "Set::Scalar"), 'Created Set subtype'; ok subtype( UniqueInt, - as Dependent[Int, Set], + as Parameterizable[Int, Set], where { my ($int, $set) = @_; return !$set->has($int); - }), 'Created UniqueInt Dependent Type'; + }), 'Created UniqueInt Parameterizable Type'; ok( (my $set_obj = Set::Scalar->new(1,2,3,4,5)), 'Create Set Object'); @@ -68,7 +68,7 @@ use Test::More; { }; subtype RangedInt, - as Dependent[Int, Range], + as Parameterizable[Int, Range], where { my ($value, $range) = @_; return ($value >= $range->{min} && @@ -169,4 +169,4 @@ use Test::More; { ok NameBetween18and35Age->check(['John',28]), 'Good NameBetween18and35Age'; ok !NameBetween18and35Age->check(['John','Napiorkowski']), 'Bad NameBetween18and35Age'; ok !NameBetween18and35Age->check(['John',99]), 'Bad NameBetween18and35Age'; -} \ No newline at end of file +} diff --git a/t/03-coercions.t b/t/03-coercions.t index 792afac..5e19ddc 100644 --- a/t/03-coercions.t +++ b/t/03-coercions.t @@ -4,7 +4,7 @@ use Test::More tests=>15; { use strict; use warnings; - use MooseX::Dependent::Types qw(Dependent); + use MooseX::Parameterizable::Types qw(Parameterizable); use MooseX::Types::Moose qw(Int Str HashRef ArrayRef); use MooseX::Types -declare=>[qw( @@ -22,7 +22,7 @@ use Test::More tests=>15; { ok !InfoHash->check({at_least=>25}), 'Bad InfoHash'; ok subtype( OlderThanAge, - as Dependent[Int, InfoHash], + as Parameterizable[Int, InfoHash], where { my ($value, $dict) = @_; return $value > $dict->{older_than} ? 1:0; @@ -75,4 +75,4 @@ use Test::More tests=>15; { is DefinedOlderThanAge->coerce([1,2,3]), 6, 'Got expected Value'; } -} \ No newline at end of file +}