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