Commit | Line | Data |
---|---|---|
7eaef7ad | 1 | #!/usr/bin/perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
a28e50e4 | 6 | use Test::More; |
7eaef7ad | 7 | |
7ff56534 | 8 | |
bbd2fe69 | 9 | =pod |
10 | ||
d03bd989 | 11 | This test demonstrates that Moose will respect |
12 | a metaclass previously set with the metaclass | |
13 | pragma. | |
bbd2fe69 | 14 | |
d03bd989 | 15 | It also checks an error condition where that |
bbd2fe69 | 16 | metaclass must be a Moose::Meta::Class subclass |
17 | in order to work. | |
18 | ||
19 | =cut | |
20 | ||
7eaef7ad | 21 | |
22 | { | |
23 | package Foo::Meta; | |
24 | use strict; | |
25 | use warnings; | |
26 | ||
27 | use base 'Moose::Meta::Class'; | |
d03bd989 | 28 | |
7eaef7ad | 29 | package Foo; |
30 | use strict; | |
31 | use warnings; | |
32 | use metaclass 'Foo::Meta'; | |
33 | ::use_ok('Moose'); | |
34 | } | |
35 | ||
36 | isa_ok(Foo->meta, 'Foo::Meta'); | |
37 | ||
38 | { | |
39 | package Bar::Meta; | |
40 | use strict; | |
41 | use warnings; | |
d03bd989 | 42 | |
7eaef7ad | 43 | use base 'Class::MOP::Class'; |
d03bd989 | 44 | |
7eaef7ad | 45 | package Bar; |
46 | use strict; | |
47 | use warnings; | |
48 | use metaclass 'Bar::Meta'; | |
49 | eval 'use Moose;'; | |
50 | ::ok($@, '... could not load moose without correct metaclass'); | |
d03bd989 | 51 | ::like($@, |
50d5df60 | 52 | qr/^Bar already has a metaclass, but it does not inherit Moose::Meta::Class/, |
66bcefc1 | 53 | '... got the right error too'); |
7eaef7ad | 54 | } |
a28e50e4 | 55 | |
56 | done_testing; |