}
else {
# otherwise assume it is a constraint
- my $constraint = Moose::Util::TypeConstraints::find_type_constraint($options{isa});
+ my $constraint = Moose::Util::TypeConstraints::find_type_constraint($options{isa})->constraint_code;
# if the constraing it not found ....
unless (defined $constraint) {
# assume it is a foreign class, and make
my %TYPES;
sub find_type_constraint {
my $type_name = shift;
- $TYPES{$type_name}->constraint_code;
+ $TYPES{$type_name};
}
sub register_type_constraint {
my ($name, $parent, $check) = @_;
if (defined $check) {
my $full_name = caller() . "::${name}";
- $parent = find_type_constraint($parent)
+ $parent = find_type_constraint($parent)->constraint_code
unless $parent && ref($parent) eq 'CODE';
register_type_constraint($name => subname $full_name => sub {
local $_ = $_[0];
}
else {
($parent, $check) = ($name, $parent);
- $parent = find_type_constraint($parent)
+ $parent = find_type_constraint($parent)->constraint_code
unless $parent && ref($parent) eq 'CODE';
return subname '__anon_subtype__' => sub {
local $_ = $_[0];
my @coercions;
while (@coercion_map) {
my ($constraint_name, $action) = splice(@coercion_map, 0, 2);
- my $constraint = find_type_constraint($constraint_name);
+ my $constraint = find_type_constraint($constraint_name)->constraint_code;
(defined $constraint)
|| confess "Could not find the type constraint ($constraint_name)";
push @coercions => [ $constraint, $action ];
use strict;
use warnings;
-use Test::More tests => 1;
+use Test::More tests => 12;
use Test::Exception;
BEGIN {
use_ok('Moose::Util::TypeConstraints', (':no_export'));
}
-#diag Moose::Util::TypeConstraints::dump_type_constraints();
\ No newline at end of file
+*find_type_constraint = \&Moose::Util::TypeConstraints::find_type_constraint;
+
+foreach my $type_name (qw(
+ Any
+ Value
+ Int
+ Str
+ Ref
+ ScalarRef
+ ArrayRef
+ HashRef
+ CodeRef
+ RegexpRef
+ Object
+ )) {
+ is(find_type_constraint($type_name)->name, $type_name, '... got the right name for ' . $type_name);
+}
\ No newline at end of file