4 BEGIN { require "t/moo-accessors.t"; }
8 my $meta = Class::MOP::get_metaclass_by_name('Foo');
12 ok($attr = $meta->get_attribute('one'), 'Meta-attribute exists');
13 is($attr->get_read_method, 'one', 'Method name');
14 is($attr->get_read_method_ref->body, Foo->can('one'), 'Right method');
16 is(Foo->new(one => 1, THREE => 3)->one, 1, 'Accessor still works');
19 Foo->meta->get_attribute('one')->get_read_method, 'one',
20 'Method name via ->meta'
23 $meta = Moose::Meta::Class->initialize('Spoon');
25 $meta->superclasses('Moose::Object');
27 Moose::Util::apply_all_roles($meta, 'Bar');
29 my $spoon = Spoon->new(four => 4);
31 is($spoon->four, 4, 'Role application ok');
34 package MooRequiresFour;
40 package MooRequiresGunDog;
48 Moose::Util::apply_all_roles($meta, 'MooRequiresFour');
49 }, undef, 'apply role with satisified requirement';
52 Moose::Util::apply_all_roles($meta, 'MooRequiresGunDog');
53 }, 'apply role with unsatisified requirement';