use strict;
use warnings;
-use Test::More no_plan => 1;
+use Test::More;
use Test::Exception;
BEGIN {
- use_ok('Moose');
- use_ok('Moose::Util::TypeConstraints');
- use_ok('Moose::Meta::TypeConstraint::Container');
+ use_ok('Moose::Util::TypeConstraints');
+ use_ok('Moose::Meta::TypeConstraint::Parameterized');
}
# Array of Ints
-my $array_of_ints = Moose::Meta::TypeConstraint::Container->new(
+my $array_of_ints = Moose::Meta::TypeConstraint::Parameterized->new(
name => 'ArrayRef[Int]',
parent => find_type_constraint('ArrayRef'),
- container_type => find_type_constraint('Int'),
+ type_parameter => find_type_constraint('Int'),
);
-isa_ok($array_of_ints, 'Moose::Meta::TypeConstraint::Container');
+isa_ok($array_of_ints, 'Moose::Meta::TypeConstraint::Parameterized');
isa_ok($array_of_ints, 'Moose::Meta::TypeConstraint');
ok($array_of_ints->check([ 1, 2, 3, 4 ]), '... [ 1, 2, 3, 4 ] passed successfully');
# Hash of Ints
-my $hash_of_ints = Moose::Meta::TypeConstraint::Container->new(
+my $hash_of_ints = Moose::Meta::TypeConstraint::Parameterized->new(
name => 'HashRef[Int]',
parent => find_type_constraint('HashRef'),
- container_type => find_type_constraint('Int'),
+ type_parameter => find_type_constraint('Int'),
);
-isa_ok($hash_of_ints, 'Moose::Meta::TypeConstraint::Container');
+isa_ok($hash_of_ints, 'Moose::Meta::TypeConstraint::Parameterized');
isa_ok($hash_of_ints, 'Moose::Meta::TypeConstraint');
ok($hash_of_ints->check({ one => 1, two => 2, three => 3 }), '... { one => 1, two => 2, three => 3 } passed successfully');
# Array of Array of Ints
-my $array_of_array_of_ints = Moose::Meta::TypeConstraint::Container->new(
+my $array_of_array_of_ints = Moose::Meta::TypeConstraint::Parameterized->new(
name => 'ArrayRef[ArrayRef[Int]]',
parent => find_type_constraint('ArrayRef'),
- container_type => $array_of_ints,
+ type_parameter => $array_of_ints,
);
-isa_ok($array_of_array_of_ints, 'Moose::Meta::TypeConstraint::Container');
+isa_ok($array_of_array_of_ints, 'Moose::Meta::TypeConstraint::Parameterized');
isa_ok($array_of_array_of_ints, 'Moose::Meta::TypeConstraint');
ok($array_of_array_of_ints->check(
[[ 1, 2, 3 ], [ qw/foo bar/ ]]
), '... [[ 1, 2, 3 ], [ qw/foo bar/ ]] failed successfully');
+{
+ my $anon_type = Moose::Util::TypeConstraints::find_or_parse_type_constraint('ArrayRef[Foo]');
+ isa_ok( $anon_type, 'Moose::Meta::TypeConstraint::Parameterized' );
+
+ my $param_type = $anon_type->type_parameter;
+ isa_ok( $param_type, 'Moose::Meta::TypeConstraint::Class' );
+}
+
+done_testing;