Commit | Line | Data |
60ad2cb7 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More tests => 7; |
7 | use Test::Exception; |
8 | |
9 | { |
10 | package Class; |
11 | use Mouse; |
12 | |
13 | package Foo; |
14 | use Mouse::Role; |
15 | sub foo_role_applied { 1 } |
16 | |
17 | package Conflicts::With::Foo; |
18 | use Mouse::Role; |
19 | sub foo_role_applied { 0 } |
20 | |
21 | package Not::A::Role; |
22 | sub lol_wut { 42 } |
23 | } |
24 | |
25 | my $new_class; |
26 | |
27 | lives_ok { |
28 | $new_class = Mouse::Meta::Class->create( |
29 | 'Class::WithFoo', |
30 | superclasses => ['Class'], |
31 | roles => ['Foo'], |
32 | ); |
33 | } 'creating lives'; |
34 | ok $new_class; |
35 | |
36 | my $with_foo = Class::WithFoo->new; |
37 | |
38 | ok $with_foo->foo_role_applied; |
39 | isa_ok $with_foo, 'Class', '$with_foo'; |
40 | |
41 | throws_ok { |
42 | Mouse::Meta::Class->create( |
43 | 'Made::Of::Fail', |
44 | superclasses => ['Class'], |
45 | roles => 'Foo', # "oops" |
46 | ); |
47 | } qr/You must pass an ARRAY ref of roles/; |
48 | |
8447b3b1 |
49 | ok !Mouse::Util::is_class_loaded('Made::Of::Fail'), "did not create Made::Of::Fail"; |
60ad2cb7 |
50 | |
51 | dies_ok { |
52 | Mouse::Meta::Class->create( |
53 | 'Continuing::To::Fail', |
54 | superclasses => ['Class'], |
55 | roles => ['Foo', 'Conflicts::With::Foo'], |
56 | ); |
57 | } 'conflicting roles == death'; |
58 | |
59 | # XXX: Continuing::To::Fail gets created anyway |
60 | |