basic-test
[gitmo/Moose-Policy.git] / t / 001_basic.t
CommitLineData
82cfc049 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 1;
7
8BEGIN {
b14c8df5 9 use_ok('Moose::Policy');
10}
11
12{
13 package My::Moose::Meta::Attribute;
14 use Moose;
15
16 extends 'Moose::Meta::Attribute';
17
18 before '_process_options' => sub {
19 my ($class, $name, $options) = @_;
20 if (exists $options->{is}) {
21 if ($options->{is} eq 'ro') {
22 $options->{reader} = 'get_' . $name;
23 }
24 elsif ($options->{is} eq 'rw') {
25 $options->{reader} = 'get_' . $name;
26 $options->{writer} = 'set_' . $name;
27 }
28 delete $options->{is};
29 }
30 };
31}
32
33
34{
35 package My::Moose::Policy;
5d1afb58 36 use constant attribute_metaclass => 'My::Moose::Meta::Attribute';
37}
38
39{
40 package Foo;
b14c8df5 41
5d1afb58 42 use Moose::Policy 'My::Moose::Policy';
43 use Moose;
b14c8df5 44
5d1afb58 45 has 'bar' => (default => 'Foo::bar');
46}
47
48
49my $foo = Foo->new;
50isa_ok($foo, 'Foo');
51
52can_ok($foo, 'get_bar');
53can_ok($foo, 'set_bar');
54
55is($foo->get_bar, 'Foo::bar', '... got the right default value');
56
57
58
59
60