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