Ignore all .git.*
[gitmo/Class-MOP.git] / t / 040_metaclass.t
CommitLineData
550d56db 1use strict;
2use warnings;
3
efd3d14c 4use Test::More tests => 11;
550d56db 5
efd3d14c 6BEGIN {use metaclass;
550d56db 7}
8
9{
10 package FooMeta;
11 use base 'Class::MOP::Class';
12
13 package Foo;
14 use metaclass 'FooMeta';
15}
16
17can_ok('Foo', 'meta');
18isa_ok(Foo->meta, 'FooMeta');
19isa_ok(Foo->meta, 'Class::MOP::Class');
20
21{
22 package BarMeta;
23 use base 'Class::MOP::Class';
24
25 package BarMeta::Attribute;
26 use base 'Class::MOP::Attribute';
27
28 package BarMeta::Method;
29 use base 'Class::MOP::Method';
30
31 package Bar;
32 use metaclass 'BarMeta' => (
c23184fc 33 'attribute_metaclass' => 'BarMeta::Attribute',
34 'method_metaclass' => 'BarMeta::Method',
550d56db 35 );
36}
37
38can_ok('Bar', 'meta');
39isa_ok(Bar->meta, 'BarMeta');
40isa_ok(Bar->meta, 'Class::MOP::Class');
41
42is(Bar->meta->attribute_metaclass, 'BarMeta::Attribute', '... got the right attribute metaobject');
43is(Bar->meta->method_metaclass, 'BarMeta::Method', '... got the right method metaobject');
44
45{
46 package Baz;
47 use metaclass;
48}
49
50can_ok('Baz', 'meta');
51isa_ok(Baz->meta, 'Class::MOP::Class');
52
53eval {
54 package Boom;
55 metaclass->import('Foo');
56};
57ok($@, '... metaclasses must be subclass of Class::MOP::Class');
58