5 use Test::More qw(no_plan);
39 use Moose::Util::TypeConstraints;
41 duck_type 'DuckType' => qw(quack);
49 sub _build_duck { Duck->new }
52 isa => duck_type( [qw(honk)] ),
58 # try giving it a duck
59 lives_ok { DucktypeTest->new( duck => Duck->new ) } 'the Duck lives okay';
61 # try giving it a swan which is like a duck, but not close enough
62 throws_ok { DucktypeTest->new( duck => Swan->new ) }
63 qr/Swan is missing methods 'quack'/,
64 "the Swan doesn't quack";
66 # try giving it a rubber RubberDuckey
67 lives_ok { DucktypeTest->new( swan => Swan->new ) } 'but a Swan can honk';
69 # try giving it a rubber RubberDuckey
70 lives_ok { DucktypeTest->new( duck => RubberDuck->new ) }
71 'the RubberDuck lives okay';