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;
42 use Mouse::Util::TypeConstraints;
44 duck_type 'DuckType' => qw(quack);
45 duck_type 'SwanType' => [qw(honk)];
53 sub _build_duck { Duck->new }
56 isa => duck_type( [qw(honk)] ),
67 # try giving it a duck
68 lives_ok { DucktypeTest->new( duck => Duck->new ) } 'the Duck lives okay';
70 # try giving it a swan which is like a duck, but not close enough
71 throws_ok { DucktypeTest->new( duck => Swan->new ) }
72 qr/Swan is missing methods 'quack'/,
73 "the Swan doesn't quack";
75 # try giving it a rubber RubberDuckey
76 lives_ok { DucktypeTest->new( swan => Swan->new ) } 'but a Swan can honk';
78 # try giving it a rubber RubberDuckey
79 lives_ok { DucktypeTest->new( duck => RubberDuck->new ) }
80 'the RubberDuck lives okay';
82 # try with the other constraint form
83 lives_ok { DucktypeTest->new( other_swan => Swan->new ) } 'but a Swan can honk';