3 use Test::More tests => 9;
5 require_ok("MooseX::Adopt::Class::Accessor::Fast");
7 @Foo::ISA = qw(Class::Accessor::Fast);
8 Foo->mk_accessors(qw( foo ));
9 my $test = Foo->new({ foo => 49 });
10 is( $test->get('foo'), 49, "get initial foo");
11 $test->set('foo', 42);
12 is($test->get('foo'), 42, "get new foo");
16 @Bar::ISA = qw(Class::Accessor::Fast);
17 my $get_ref = Bar->make_ro_accessor('read');
18 my $set_ref = Bar->make_wo_accessor('write');
19 my $getset_ref = Bar->make_accessor('read_write');
21 ok(Bar->meta->has_attribute("read"),"has read");
22 ok(Bar->meta->has_attribute("write"),"has write");
23 ok(Bar->meta->has_attribute("read_write"),"has read_write");
25 my $obj = Bar->new({read => 1, write => 2, read_write => 3});
26 is($get_ref->($obj), 1, "read get works");
27 is($getset_ref->($obj), 3, "read_write get works");
28 $getset_ref->($obj,2);
29 is($getset_ref->($obj), 2, "read_write set works");