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 .']',
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 {
use strict;
use warnings;
-use Test::More tests => 39;
+use Test::More tests => 37;
use Test::Exception;
BEGIN {
["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