123e3e6790c009ced31eae7d31bbcd2fa9e933a0
[gitmo/MooseX-SemiAffordanceAccessor.git] / t / basic.t
1 use strict;
2 use warnings;
3
4 use Test::More tests => 21;
5
6 {
7
8     package Standard;
9
10     use Moose;
11
12     has 'thing'    => ( is => 'rw' );
13     has '_private' => ( is => 'rw' );
14 }
15
16 {
17
18     package SAA;
19
20     use MooseX::SemiAffordanceAccessor;
21     use Moose;
22
23     has 'thing'    => ( is => 'rw' );
24     has '_private' => ( is => 'rw' );
25 }
26
27 {
28
29     package SAA2;
30
31     # Make sure load order doesn't matter
32     use Moose;
33     use MooseX::SemiAffordanceAccessor;
34
35     has 'thing'    => ( is => 'rw' );
36     has '_private' => ( is => 'rw' );
37 }
38
39 {
40
41     package SAA3;
42
43     use Moose;
44     use MooseX::SemiAffordanceAccessor;
45
46     has 'ro'     => ( is => 'ro' );
47     has 'thing'  => ( is => 'rw', reader => 'get_thing' );
48     has 'thing2' => ( is => 'rw', writer => 'set_it' );
49 }
50
51 {
52
53     package SAA4;
54
55     use Moose;
56     use MooseX::SemiAffordanceAccessor;
57
58     has bare => ( is => 'bare' );
59 }
60
61 ok( Standard->can('thing'),      'Standard->thing() exists' );
62 ok( !Standard->can('set_thing'), 'Standard->set_thing() does not exist' );
63 ok( Standard->can('_private'),   'Standard->_private() exists' );
64 ok( !Standard->can('_set_private'),
65     'Standard->_set_private() does not exist' );
66
67 ok( SAA->can('thing'),        'SAA->thing() exists' );
68 ok( SAA->can('set_thing'),    'SAA->set_thing() exists' );
69 ok( SAA->can('_private'),     'SAA->_private() exists' );
70 ok( SAA->can('_set_private'), 'SAA->_set_private() exists' );
71
72 ok( SAA2->can('thing'),        'SAA2->thing() exists' );
73 ok( SAA2->can('set_thing'),    'SAA2->set_thing() exists' );
74 ok( SAA2->can('_private'),     'SAA2->_private() exists' );
75 ok( SAA2->can('_set_private'), 'SAA2->_set_private() exists' );
76
77 ok( SAA3->can('ro'),          'SAA3->ro exists' );
78 ok( !SAA3->can('set_ro'),     'SAA3->set_ro does not exist' );
79 ok( SAA3->can('thing'),       'SAA3->thing exists' );
80 ok( !SAA3->can('set_thing'),  'SAA3->set_thing does not exist' );
81 ok( SAA3->can('thing2'),      'SAA3->thing2 exists' );
82 ok( !SAA3->can('set_thing2'), 'SAA3->set_thing2 does not exist' );
83 ok( SAA3->can('set_it'),      'SAA3->set_it does exist' );
84
85 ok( !SAA4->can('bare'),     'SAA4->bare does not exist' );
86 ok( !SAA4->can('set_bare'), 'SAA4->set_bare does not exist' );