6 use Test::More tests => 16;
10 use_ok('Moose::Util::TypeConstraints');
11 use_ok('Moose::Meta::TypeConstraint');
14 ## Create a subclass with a custom method
17 package Test::Moose::Meta::TypeConstraint::AnySubType;
19 extends 'Moose::Meta::TypeConstraint';
21 sub my_custom_method {
26 my $Int = Moose::Util::TypeConstraints::find_type_constraint('Int');
27 ok $Int, 'Got a good type contstraint';
29 my $parent = Test::Moose::Meta::TypeConstraint::AnySubType->new({
30 name => "Test::Moose::Meta::TypeConstraint::AnySubType" ,
34 ok $parent, 'Created type constraint';
35 ok $parent->check(1), 'Correctly passed';
36 ok ! $parent->check('a'), 'correctly failed';
37 ok $parent->my_custom_method, 'found the custom method';
39 my $subtype1 = Moose::Util::TypeConstraints::subtype 'another_subtype',
42 ok $subtype1, 'Created type constraint';
43 ok $subtype1->check(1), 'Correctly passed';
44 ok ! $subtype1->check('a'), 'correctly failed';
45 ok $subtype1->my_custom_method, 'found the custom method';
48 my $subtype2 = Moose::Util::TypeConstraints::subtype 'another_subtype',
52 ok $subtype2, 'Created type constraint';
53 ok $subtype2->check(1), 'Correctly passed';
54 ok ! $subtype2->check('a'), 'correctly failed';
55 ok ! $subtype2->check(100), 'correctly failed';
57 ok $subtype2->my_custom_method, 'found the custom method';