11 plan skip_all => 'Moose::Policy does not work with recent versions of Moose'
12 if Moose->VERSION >= 1.05;
16 use_ok('Moose::Policy');
22 use Moose::Policy 'Moose::Policy::FollowPBP';
25 has 'bar' => (is => 'rw', default => 'Foo::bar');
26 has 'baz' => (is => 'ro', default => 'Foo::baz');
29 isa_ok(Foo->meta, 'Moose::Meta::Class');
30 is(Foo->meta->attribute_metaclass, 'Moose::Policy::FollowPBP::Attribute', '... got our custom attr metaclass');
32 isa_ok(Foo->meta->get_attribute('bar'), 'Moose::Policy::FollowPBP::Attribute');
37 can_ok($foo, 'get_bar');
38 can_ok($foo, 'set_bar');
40 can_ok($foo, 'get_baz');
41 ok(! $foo->can('set_baz'), 'without setter');
43 is($foo->get_bar, 'Foo::bar', '... got the right default value');
44 is($foo->get_baz, 'Foo::baz', '... got the right default value');
48 use Moose::Policy 'Moose::Policy::FollowPBP';
53 has 'boing' => (is => 'rw', default => 'Bar::boing');
56 isa_ok(Bar->meta, 'Moose::Meta::Class');
57 is(Bar->meta->attribute_metaclass, 'Moose::Policy::FollowPBP::Attribute', '... got our custom attr metaclass');
59 isa_ok(Bar->meta->get_attribute('boing'), 'Moose::Policy::FollowPBP::Attribute');
65 can_ok($bar, 'get_boing');
66 can_ok($bar, 'set_boing');
68 is($bar->get_boing, 'Bar::boing', '... got the right default value');
69 $bar->set_boing('Woot!');
70 is($bar->get_boing, 'Woot!', '... got the right changed value');
78 has 'bling' => (is => 'ro', default => 'Baz::bling');
81 isa_ok(Baz->meta, 'Moose::Meta::Class');
82 is(Baz->meta->attribute_metaclass, 'Moose::Meta::Attribute', '... got our custom attr metaclass');
84 isa_ok(Baz->meta->get_attribute('bling'), 'Moose::Meta::Attribute');
91 can_ok($baz, 'bling');
93 is($baz->bling, 'Baz::bling', '... got the right default value');