Commit | Line | Data |
550d56db |
1 | use strict; |
2 | use warnings; |
3 | |
efd3d14c |
4 | use Test::More tests => 11; |
550d56db |
5 | |
efd3d14c |
6 | BEGIN {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 | |
17 | can_ok('Foo', 'meta'); |
18 | isa_ok(Foo->meta, 'FooMeta'); |
19 | isa_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 | |
38 | can_ok('Bar', 'meta'); |
39 | isa_ok(Bar->meta, 'BarMeta'); |
40 | isa_ok(Bar->meta, 'Class::MOP::Class'); |
41 | |
42 | is(Bar->meta->attribute_metaclass, 'BarMeta::Attribute', '... got the right attribute metaobject'); |
43 | is(Bar->meta->method_metaclass, 'BarMeta::Method', '... got the right method metaobject'); |
44 | |
45 | { |
46 | package Baz; |
47 | use metaclass; |
48 | } |
49 | |
50 | can_ok('Baz', 'meta'); |
51 | isa_ok(Baz->meta, 'Class::MOP::Class'); |
52 | |
53 | eval { |
54 | package Boom; |
55 | metaclass->import('Foo'); |
56 | }; |
57 | ok($@, '... metaclasses must be subclass of Class::MOP::Class'); |
58 | |