adding in some basic policies and some tests
[gitmo/Moose-Policy.git] / t / 010_FollowPBP_test.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More 'no_plan';
7
8 BEGIN {
9     use_ok('Moose::Policy');
10 }
11
12 {
13     package Foo;
14
15     use Moose::Policy 'Moose::Policy::FollowPBP';
16     use Moose;
17
18     has 'bar' => (is => 'rw', default => 'Foo::bar');
19     has 'baz' => (is => 'ro', default => 'Foo::baz');
20 }
21
22 isa_ok(Foo->meta, 'Moose::Meta::Class');
23 is(Foo->meta->attribute_metaclass, 'Moose::Policy::FollowPBP::Attribute', '... got our custom attr metaclass');
24
25 isa_ok(Foo->meta->get_attribute('bar'), 'Moose::Policy::FollowPBP::Attribute');
26
27 my $foo = Foo->new;
28 isa_ok($foo, 'Foo');
29
30 can_ok($foo, 'get_bar');
31 can_ok($foo, 'set_bar');
32
33 can_ok($foo, 'get_baz');
34 ok(! $foo->can('set_baz'), 'without setter');
35
36 is($foo->get_bar, 'Foo::bar', '... got the right default value');
37 is($foo->get_baz, 'Foo::baz', '... got the right default value');
38