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