9 use Moose::Util::TypeConstraints;
13 This tests demonstrates that Moose will not override
14 a preexisting type constraint of the same name when
15 making constraints for a Moose-class.
17 It also tests that an attribute which uses a 'Foo' for
18 its isa option will get the subtype Foo, and not a
19 type representing the Foo moose class.
24 # create this subtype first (in BEGIN)
27 => where { $_ eq 'Foo' };
30 { # now seee if Moose will override it
35 my $foo_constraint = find_type_constraint('Foo');
36 isa_ok($foo_constraint, 'Moose::Meta::TypeConstraint');
38 is($foo_constraint->parent->name, 'Value', '... got the Value subtype for Foo');
40 ok($foo_constraint->check('Foo'), '... my constraint passed correctly');
41 ok(!$foo_constraint->check('Bar'), '... my constraint failed correctly');
47 has 'foo' => (is => 'rw', isa => 'Foo');
55 }, undef, '... checked the type constraint correctly' );
59 }, undef, '... checked the type constraint correctly' );