From: John Napiorkowski Date: Sun, 14 Sep 2008 05:32:43 +0000 (+0000) Subject: changed made sure I properly delegate parsing the type constraint parameter string... X-Git-Tag: 0.58~37^2~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a4becd2bb335108a51b16c637720f10aae70d63d;p=gitmo%2FMoose.git changed made sure I properly delegate parsing the type constraint parameter string to the actual type constraint, instead of try to shove everything into the utils package --- diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index 0888884..918380e 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -136,8 +136,8 @@ sub create_parameterized_type_constraint ($) { sub _create_parameterized_type_constraint { my ($base_type_tc, $type_parameter_str) = @_; if($base_type_tc->can('parameterize')) { - my @type_parameters_tc = $base_type_tc->parse_parameter_str($type_parameter_str); - return $base_type_tc->parameterize( @type_parameters_tc); + my @type_parameters_tc = $base_type_tc->parse_parameter_str($type_parameter_str); + return $base_type_tc->parameterize( @type_parameters_tc); } else { return Moose::Meta::TypeConstraint::Parameterized->new( name => $base_type_tc->name .'['. $type_parameter_str .']', @@ -472,7 +472,7 @@ sub _install_type_coercions ($$) { sub _parse_parameterized_type_constraint { { no warnings 'void'; $any; } # force capture of interpolated lexical my($base, $elements) = ($_[0] =~ m{ $type_capture_parts }x); - return ($base, split($structure_divider, $elements)); + return ($base,$elements); } sub _detect_parameterized_type_constraint { diff --git a/t/040_type_constraints/026_normalize_type_name.t b/t/040_type_constraints/026_normalize_type_name.t index 1f458ee..547bdd2 100644 --- a/t/040_type_constraints/026_normalize_type_name.t +++ b/t/040_type_constraints/026_normalize_type_name.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 39; +use Test::More tests => 37; use Test::Exception; BEGIN { @@ -60,29 +60,21 @@ is_deeply ["ArrayRef", "HashRef[Int ]"] => 'Correctly parsed ArrayRef[ HashRef[Int ] ]'; -ok Moose::Util::TypeConstraints::_detect_parameterized_type_constraint('ArrayRef[Int,Str]') +ok Moose::Util::TypeConstraints::_detect_parameterized_type_constraint('ArrayRef[Int|Str]') => 'detected correctly'; is_deeply - [Moose::Util::TypeConstraints::_parse_parameterized_type_constraint('ArrayRef[Int,Str]')], - ["ArrayRef", "Int", "Str"] - => 'Correctly parsed ArrayRef[Int,Str]'; + [Moose::Util::TypeConstraints::_parse_parameterized_type_constraint('ArrayRef[Int|Str]')], + ["ArrayRef", "Int|Str"] + => 'Correctly parsed ArrayRef[Int|Str]'; -ok Moose::Util::TypeConstraints::_detect_parameterized_type_constraint('ArrayRef[ArrayRef[Int],Str]') +ok Moose::Util::TypeConstraints::_detect_parameterized_type_constraint('ArrayRef[ArrayRef[Int]|Str]') => 'detected correctly'; is_deeply - [Moose::Util::TypeConstraints::_parse_parameterized_type_constraint('ArrayRef[ArrayRef[Int],Str]')], - ["ArrayRef", "ArrayRef[Int]", "Str"] - => 'Correctly parsed ArrayRef[ArrayRef[Int],Str]'; - -ok Moose::Util::TypeConstraints::_detect_parameterized_type_constraint('HashRef[key1 => Int, key2=>Int, key3=>ArrayRef[Int]]') - => 'detected correctly'; - -is_deeply - [Moose::Util::TypeConstraints::_parse_parameterized_type_constraint('HashRef[key1 => Int, key2=>Int, key3=>ArrayRef[Int]]')], - ["HashRef", "key1", "Int", "key2", "Int", "key3", "ArrayRef[Int]"] - => 'Correctly parsed HashRef[key1 => Int, key2=>Int, key3=>ArrayRef[Int]]'; + [Moose::Util::TypeConstraints::_parse_parameterized_type_constraint('ArrayRef[ArrayRef[Int]|Str]')], + ["ArrayRef", "ArrayRef[Int]|Str"] + => 'Correctly parsed ArrayRef[ArrayRef[Int]|Str]'; ## creating names via subtype