add applied_attribute metarole
[gitmo/MooseX-FollowPBP.git] / t / basic.t
CommitLineData
a623c113 1use strict;
2use warnings;
3
4use Test::More;
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 package PBP;
18
19 use Moose;
20 use MooseX::FollowPBP;
21
22 has 'thing' => ( is => 'rw' );
23 has '_private' => ( is => 'rw' );
24}
25
26{
27 package PBP3;
28
29 use Moose;
30 use MooseX::FollowPBP;
31
32 has 'ro' => ( is => 'ro' );
33 has 'thing' => ( is => 'rw', reader => 'thing' );
34 has 'thing2' => ( is => 'rw', writer => 'set_it' );
35}
36
7e7ad65a 37{
38 package PBP4;
39
40 use Moose;
41 use MooseX::FollowPBP;
42
43 has 'bare' => ( is => 'bare' );
44}
45
a623c113 46
47ok( ! Standard->can('get_thing'), 'Standard->get_thing() does not exist' );
48ok( ! Standard->can('set_thing'), 'Standard->set_thing() does not exist' );
49ok( ! Standard->can('_get_private'), 'Standard->_get_private() does not exist' );
50ok( ! Standard->can('_set_private'), 'Standard->_set_private() does not exist' );
51
52ok( PBP->can('get_thing'), 'PBP->get_thing() exists' );
53ok( PBP->can('set_thing'), 'PBP->set_thing() exists' );
54ok( PBP->can('_get_private'), 'PBP->_get_private() exists' );
55ok( PBP->can('_set_private'), 'PBP->_set_private() exists' );
56
57ok( PBP3->can('get_ro'), 'PBP3->get_ro exists' );
58ok( ! PBP3->can('set_ro'), 'PBP3->set_ro does not exist' );
59ok( ! PBP3->can('get_thing'), 'PBP3->get_thing does not exist' );
60ok( ! PBP3->can('set_thing'), 'PBP3->set_thing does not exist' );
61ok( ! PBP3->can('get_thing2'), 'PBP3->get_thing2 does not exist' );
62ok( ! PBP3->can('set_thing2'), 'PBP3->set_thing2 does not exist' );
63
7e7ad65a 64ok( !PBP4->can('get_bare'), 'is => bare attribute is respected' );
65ok( !PBP4->can('set_bare'), 'is => bare attribute is respected' );
66
097c9390 67{
68 package PBP::Role;
69 use Moose::Role;
70 use MooseX::FollowPBP;
71 has foo => (is => 'rw');
72}
73
74{
75 package PBP::WithRole;
76 use Moose;
77 with 'PBP::Role';
78}
79
80ok( PBP::WithRole->can('get_foo'), "works in a role" );
81ok( PBP::WithRole->can('set_foo'), "works in a role" );
82ok( !PBP::WithRole->can('foo'), "works in a role" );
83
a623c113 84done_testing();