{
package Baz;
- use metaclass;
+ use metaclass no_meta => 1;
sub foo {}
- Baz->meta->add_attribute('bar');
+ Class::MOP::class_of('Baz')->add_attribute('bar');
}
-$meta = Baz->meta;
+$meta = Class::MOP::class_of('Baz');
check_meta_sanity($meta, 'Baz');
-ok(!Baz->meta->get_method('foo')->isa('Baz::Meta::Method'));
-ok(!Baz->meta->get_attribute('bar')->isa('Baz::Meta::Attribute'));
+ok(!$meta->get_method('foo')->isa('Baz::Meta::Method'));
+ok(!$meta->get_attribute('bar')->isa('Baz::Meta::Attribute'));
lives_ok {
$meta = $meta->reinitialize(
'Baz',
);
};
check_meta_sanity($meta, 'Baz');
-isa_ok(Baz->meta->get_method('foo'), 'Baz::Meta::Method');
-isa_ok(Baz->meta->get_attribute('bar'), 'Baz::Meta::Attribute');
+isa_ok($meta->get_method('foo'), 'Baz::Meta::Method');
+isa_ok($meta->get_attribute('bar'), 'Baz::Meta::Attribute');
{
package Quux;
{
package Blah;
- use metaclass;
+ use metaclass no_meta => 1;
sub foo {}
- __PACKAGE__->meta->add_attribute('bar');
+ Class::MOP::class_of('Blah')->add_attribute('bar');
}
-$meta = Blah->meta;
+$meta = Class::MOP::class_of('Blah');
check_meta_sanity($meta, 'Blah');
-Class::MOP::Class->reinitialize(
- 'Blah',
- attribute_metaclass => 'Blah::Meta::Attribute',
- method_metaclass => 'Blah::Meta::Method',
-);
+lives_ok {
+ $meta = Class::MOP::Class->reinitialize(
+ 'Blah',
+ attribute_metaclass => 'Blah::Meta::Attribute',
+ method_metaclass => 'Blah::Meta::Method',
+ );
+};
check_meta_sanity($meta, 'Blah');
-can_ok(Blah->meta->get_method('foo'), 'foo');
-is(Blah->meta->get_method('foo')->foo, 'TEST');
-can_ok(Blah->meta->get_attribute('bar'), 'oof');
-is(Blah->meta->get_attribute('bar')->oof, 'TSET');
+can_ok($meta->get_method('foo'), 'foo');
+is($meta->get_method('foo')->foo, 'TEST');
+can_ok($meta->get_attribute('bar'), 'oof');
+is($meta->get_attribute('bar')->oof, 'TSET');
done_testing;