5 use Test::More tests => 3;
10 use MooseX::ClassAttribute;
11 use MooseX::AlwaysCoerce;
12 use Moose::Util::TypeConstraints;
14 subtype 'MyType', as 'Int';
15 coerce 'MyType', from 'Str', via { length $_ };
17 has foo => (is => 'rw', isa => 'MyType');
19 class_has bar => (is => 'rw', isa => 'MyType');
22 ok( (my $instance = MyClass->new), 'instance' );
24 eval { $instance->foo('bar') };
25 ok( (!$@), 'attribute coercion ran' );
27 eval { $instance->bar('baz') };
28 ok( (!$@), 'class attribute coercion ran' );