From: John Napiorkowski Date: Mon, 15 Sep 2008 13:30:17 +0000 (+0000) Subject: just restored some bits so that tests all pass, incase anyone wants to play with... X-Git-Tag: 0.01~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Types-Structured.git;a=commitdiff_plain;h=dbd75632f2806658a12fa8c747bf3f50a33c1057 just restored some bits so that tests all pass, incase anyone wants to play with this. --- diff --git a/lib/MooseX/Meta/TypeConstraint/Structured/Generator.pm b/lib/MooseX/Meta/TypeConstraint/Structured/Generator.pm index 8f9906c..9d65632 100755 --- a/lib/MooseX/Meta/TypeConstraint/Structured/Generator.pm +++ b/lib/MooseX/Meta/TypeConstraint/Structured/Generator.pm @@ -19,7 +19,8 @@ sub parse_parameter_str { } sub parameterize { - my ($self, @contained_tcs) = @_; + my ($self, $parameter_string) = @_; + my @contained_tcs = $self->parse_parameter_str($parameter_string); my $tc_name = $self->name .'['. join(',', map {$_->name} @contained_tcs) .']'; return $self->structured_type->new( diff --git a/lib/MooseX/Types/Structured.pm b/lib/MooseX/Types/Structured.pm index ab0a090..2bb42a0 100644 --- a/lib/MooseX/Types/Structured.pm +++ b/lib/MooseX/Types/Structured.pm @@ -5,9 +5,9 @@ use Moose::Util::TypeConstraints; use MooseX::Meta::TypeConstraint::Structured::Positional; use MooseX::Meta::TypeConstraint::Structured::Named; -use MooseX::Types -declare => [qw(Dict Tuple Optional)]; - #use Sub::Exporter - # -setup => { exports => [ qw( Optional) ] }; +#use MooseX::Types -declare => [qw(Dict Tuple Optional)]; +use Sub::Exporter + -setup => { exports => [ qw( Dict Tuple Optional) ] }; our $VERSION = '0.01'; our $AUTHORITY = 'cpan:JJNAPIORK'; @@ -113,24 +113,11 @@ This class defines the following types and subtypes. =cut -use MooseX::Meta::TypeConstraint::Structured::Positionable; - -my $tuple = MooseX::Meta::TypeConstraint::Structured::Positionable->new( - name => 'Tuple', - package_defined_in => __PACKAGE__, - parent => find_type_constraint('Ref'), - ); - -Moose::Util::TypeConstraints::register_type_constraint($tuple); - -subtype Tuple, as 'Tuple'; - - sub Optional($) { return bless {args=>shift}, 'MooseX::Types::Optional'; } -sub TupleX($) { +sub Tuple($) { my ($args, $optional) = _normalize_args(@_); my @args = @$args; my @optional = ref $optional eq 'ARRAY' ? @$optional : (); @@ -148,7 +135,7 @@ sub TupleX($) { ); } -sub DictX($) { +sub Dict($) { my ($args, $optional) = _normalize_args(@_); my %args = @$args; my %optional = ref $optional eq 'ARRAY' ? @$optional : (); diff --git a/t/01-basic.t b/t/01-basic.t index 45e7351..c3691ab 100755 --- a/t/01-basic.t +++ b/t/01-basic.t @@ -5,12 +5,12 @@ BEGIN { use Test::Exception; use_ok 'Moose::Util::TypeConstraints'; - use_ok 'MooseX::Meta::TypeConstraint::Structured::Structurable'; + use_ok 'MooseX::Meta::TypeConstraint::Structured::Generator'; use_ok 'MooseX::Meta::TypeConstraint::Structured::Positional'; use_ok 'MooseX::Meta::TypeConstraint::Structured::Named'; } -my $tuple = MooseX::Meta::TypeConstraint::Structured::Structurable->new( +my $tuple = MooseX::Meta::TypeConstraint::Structured::Generator->new( name => 'Tuple', structured_type => 'MooseX::Meta::TypeConstraint::Structured::Positional', package_defined_in => __PACKAGE__, @@ -25,7 +25,7 @@ ok Moose::Util::TypeConstraints::find_type_constraint('Tuple') => 'Found the Tuple Type'; { - package Test::MooseX::Types::Structured::Positionable; + package Test::MooseX::Types::Structured::BasicAttributes; use Moose; use Moose::Util::TypeConstraints; @@ -34,7 +34,7 @@ ok Moose::Util::TypeConstraints::find_type_constraint('Tuple') } -ok my $positioned_obj = Test::MooseX::Types::Structured::Positionable->new, +ok my $positioned_obj = Test::MooseX::Types::Structured::BasicAttributes->new, => 'Got a good object'; ok $positioned_obj->tuple([1,'hello',3])