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