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');
39 lives_ok { role_type('Boop', message { "${_} is not a Boop" }) }
40 'role_type keywork works with message';
42 my $type = find_type_constraint("Foo");
44 is( $type->role, "Foo", "role attribute" );
46 ok( $type->is_subtype_of("Gorch"), "subtype of gorch" );
48 ok( $type->is_subtype_of("Bar"), "subtype of bar" );
50 ok( $type->is_subtype_of("Object"), "subtype of Object" );
52 ok( !$type->is_subtype_of("ThisTypeDoesNotExist"), "not subtype of unknown type name" );
53 ok( !$type->is_a_type_of("ThisTypeDoesNotExist"), "not type of unknown type name" );
55 ok( find_type_constraint("Bar")->check(FooC->new), "Foo passes Bar" );
56 ok( find_type_constraint("Bar")->check(BarC->new), "Bar passes Bar" );
57 ok( !find_type_constraint("Gorch")->check(BarC->new), "but Bar doesn't pass Gorch");
59 my $boop = find_type_constraint("Boop");
60 ok( $boop->has_message, 'Boop has a message');
61 my $error = $boop->get_message(FooC->new);
62 like( $error, qr/is not a Boop/, 'boop gives correct error message');
65 ok( $type->equals($type), "equals self" );
66 ok( $type->equals(Mouse::Meta::TypeConstraint->new( name => "__ANON__", role => "Foo" )), "equals anon constraint of same value" );
67 ok( $type->equals(Mouse::Meta::TypeConstraint->new( name => "Oink", role => "Foo" )), "equals differently named constraint of same value" );
68 ok( !$type->equals(Mouse::Meta::TypeConstraint->new( name => "__ANON__", role => "Bar" )), "doesn't equal other anon constraint" );
69 ok( $type->is_subtype_of(Mouse::Meta::TypeConstraint->new( name => "__ANON__", role => "Bar" )), "subtype of other anon constraint" );