2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
10 $TODO = q{Mouse is not yet completed};
14 use_ok('Mouse::Util::TypeConstraints');
15 use_ok('Mouse::Meta::TypeConstraint');
18 my $r = Mouse::Util::TypeConstraints->get_type_constraint_registry;
22 my $array_of_ints = Mouse::Meta::TypeConstraint->new(
23 name => 'ArrayRef[Int]',
24 parent => find_type_constraint('ArrayRef'),
25 type_parameter => find_type_constraint('Int'),
27 isa_ok($array_of_ints, 'Mouse::Meta::TypeConstraint');
28 isa_ok($array_of_ints, 'Mouse::Meta::TypeConstraint');
30 $r->add_type_constraint($array_of_ints);
32 is(find_type_constraint('ArrayRef[Int]'), $array_of_ints, '... found the type we just added');
36 my $hash_of_ints = Mouse::Meta::TypeConstraint->new(
37 name => 'HashRef[Int]',
38 parent => find_type_constraint('HashRef'),
39 type_parameter => find_type_constraint('Int'),
41 isa_ok($hash_of_ints, 'Mouse::Meta::TypeConstraint');
42 isa_ok($hash_of_ints, 'Mouse::Meta::TypeConstraint');
44 $r->add_type_constraint($hash_of_ints);
46 is(find_type_constraint('HashRef[Int]'), $hash_of_ints, '... found the type we just added');
48 ## now attempt a coercion
53 use Mouse::Util::TypeConstraints;
55 coerce 'ArrayRef[Int]'
56 => from 'HashRef[Int]'
57 => via { [ values %$_ ] };
61 isa => 'ArrayRef[Int]',
67 my $foo = Foo->new(bar => { one => 1, two => 2, three => 3 });
70 is_deeply([ sort @{$foo->bar} ], [ 1, 2, 3 ], '... our coercion worked!');