|| Carp::confess("The $name constraint cannot be used, because $param doesn't subtype from a parameterizable type");
return Mouse::Meta::TypeConstraint->new(
- name => $name,
- parent => $self,
- parameter => $param,
- constraint => $generator->($param), # must be 'constraint', not 'optimized'
+ name => $name,
+ parent => $self,
+ type_parameter => $param,
+ constraint => $generator->($param), # must be 'constraint', not 'optimized'
- type => 'Parameterized',
+ type => 'Parameterized',
);
}
sub parent { $_[0]->{parent} }
sub message { $_[0]->{message} }
+sub type_parameter { $_[0]->{type_parameter} }
+sub __is_parameterized { exists $_[0]->{type_parameter} }
+
sub _compiled_type_constraint{ $_[0]->{compiled_type_constraint} }
sub _compiled_type_coercion { $_[0]->{_compiled_type_coercion} }
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 51;
+use Test::More tests => 54;
use Test::Exception;
use Tie::Hash;
$th_clone{$k} = $v;
}
+is( $hash_of_int->type_parameter, 'Int' );
+
+if('Mouse' eq ('Mo' . 'use')){ # under Mouse
+ ok $hash_of_int->__is_parameterized();
+ ok!$hash_of_int->type_parameter->__is_parameterized();
+}
+else{ # under Moose
+ ok $hash_of_int->can('type_parameter');
+ ok!$hash_of_int->type_parameter->can('type_parameter');
+}
+
is_deeply \%th_clone, \%th, 'the hash iterator is initialized';
INSTALL_SIMPLE_READER(TypeConstraint, parent);
INSTALL_SIMPLE_READER(TypeConstraint, message);
+ INSTALL_SIMPLE_READER(TypeConstraint, type_parameter);
+
INSTALL_SIMPLE_READER_WITH_KEY(TypeConstraint, _compiled_type_constraint, compiled_type_constraint);
INSTALL_SIMPLE_READER(TypeConstraint, _compiled_type_coercion); /* Mouse specific */
INSTALL_SIMPLE_PREDICATE_WITH_KEY(TypeConstraint, has_coercion, _compiled_type_coercion);
+ INSTALL_SIMPLE_PREDICATE_WITH_KEY(TypeConstraint, __is_parameterized, type_parameter); /* Mouse specific */
void
compile_type_constraint(SV* self)