6 use Test::More tests => 9;
11 use_ok('Moose::Util::TypeConstraints');
16 This tests demonstrates that Moose will not override
17 a pre-existing type constraint of the same name when
18 making constraints for a Moose-class.
20 It also tests that an attribute which uses a 'Foo' for
21 it's isa option will get the subtype Foo, and not a
22 type representing the Foo moose class.
27 # create this subtype first (in BEGIN)
30 => where { $_ eq 'Foo' };
33 { # now seee if Moose will override it
38 my $foo_constraint = find_type_constraint('Foo');
39 isa_ok($foo_constraint, 'Moose::Meta::TypeConstraint');
41 is($foo_constraint->parent->name, 'Value', '... got the Value subtype for Foo');
43 ok($foo_constraint->check('Foo'), '... my constraint passed correctly');
44 ok(!$foo_constraint->check('Bar'), '... my constraint failed correctly');
50 has 'foo' => (is => 'rw', isa => 'Foo');
58 } '... checked the type constraint correctly';
62 } '... checked the type constraint correctly';