9 'MooseX::Role::Parameterized' => 0.01,
14 use MooseX::Role::Parameterized;
15 use MooseX::AlwaysCoerce;
16 use Moose::Util::TypeConstraints;
21 subtype 'MyType', as 'Int';
22 coerce 'MyType', from 'Str', via { length $_ };
24 subtype 'Uncoerced', as 'Int';
26 has foo => (is => 'rw', isa => 'MyType');
28 class_has bar => (is => 'rw', isa => 'MyType');
30 class_has baz => (is => 'rw', isa => 'MyType', coerce => 0);
32 has quux => (is => 'rw', isa => 'MyType', coerce => 0);
34 has uncoerced_attr => (is => 'rw', isa => 'Uncoerced');
36 class_has uncoerced_class_attr => (is => 'rw', isa => 'Uncoerced');
38 has untyped_attr => (is => 'rw');
40 class_has untyped_class_attr => (is => 'rw');
49 'MooseX::ClassAttribute is currently incompatible with MooseX::Role::Parameterized';
54 eval 'use Test::NoWarnings';
56 ok( (my $instance = MyClass->new), 'instance' );
59 local $TODO = 'waiting on Moose changes for role support, and ClassAttribute changes for paramterized role support';
62 $instance->foo('bar');
64 } 'attribute coercion ran';
68 $instance->bar('baz');
70 } 'class attribute coercion ran';
72 dies_ok { $instance->baz('quux') }
73 'class attribute coercion did not run with coerce => 0';
75 dies_ok { $instance->quux('mtfnpy') }
76 'attribute coercion did not run with coerce => 0';
79 $instance->uncoerced_attr(10);
80 is $instance->uncoerced_attr(10), 10;
81 } 'set attribute having type with no coercion and no coerce=0';
84 $instance->uncoerced_class_attr(10);
85 is $instance->uncoerced_class_attr(10), 10;
86 } 'set class attribute having type with no coercion and no coerce=0';
89 $instance->untyped_attr(10);
90 is $instance->untyped_attr, 10;
91 } 'set untyped attribute';
94 $instance->untyped_class_attr(10);
95 is $instance->untyped_class_attr, 10;
96 } 'set untyped class attribute';