Begin writing excludes.. seeing some weird errors, but.. heading to bed
[gitmo/MooseX-Role-Parameterized.git] / t / 007-excludes.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Test::More tests => 1;
5 use Test::Exception;
6
7 do {
8     package MyRole::Excluder;
9     use MooseX::Role::Parameterized;
10
11     parameter exclude => (
12         is  => 'rw',
13         isa => 'Str',
14     );
15
16     role {
17         my $p = shift;
18         excludes $p->exclude;
19     };
20 };
21
22 Moose::Meta::Role->create("Role::A");
23 Moose::Meta::Role->create("Role::B");
24
25 sub excludes_roles {
26     map {
27         MyRole::Excluder->meta->generate_role(exclude => $_)->name
28     } @_
29 }
30
31 throws_ok {
32     Moose::Meta::Class->create_anon_class(
33         roles => [ 'Role::A', excludes_roles('Role::A') ],
34     );
35 } qr/^Conflict detected: Role::A excludes role 'Role::A'/;
36
37 #lives_ok {
38 #    Moose::Meta::Class->create_anon_class(
39 #        methods => {
40 #            alpha => sub {},
41 #        },
42 #        roles => [ requires_names('alpha') ],
43 #    );
44 #};
45 #
46 #throws_ok {
47 #    Moose::Meta::Class->create_anon_class(
48 #        methods => {
49 #            alpha => sub {},
50 #        },
51 #        roles => [ requires_names('alpha', 'beta') ],
52 #    );
53 #} qr/'Moose::Meta::Role::__ANON__::SERIAL::\d+\|Moose::Meta::Role::__ANON__::SERIAL::\d+' requires the method 'beta' to be implemented by 'Class::MOP::Class::__ANON__::SERIAL::\d+'/;
54 #
55 #throws_ok {
56 #    Moose::Meta::Class->create_anon_class(
57 #        methods => {
58 #            beta => sub {},
59 #        },
60 #        roles => [ requires_names('alpha', 'beta') ],
61 #    );
62 #} qr/'Moose::Meta::Role::__ANON__::SERIAL::\d+\|Moose::Meta::Role::__ANON__::SERIAL::\d+' requires the method 'alpha' to be implemented by 'Class::MOP::Class::__ANON__::SERIAL::\d+'/;
63 #
64 #lives_ok {
65 #    Moose::Meta::Class->create_anon_class(
66 #        methods => {
67 #            alpha => sub {},
68 #            beta => sub {},
69 #        },
70 #        roles => [ requires_names('alpha', 'beta') ],
71 #    );
72 #};
73 #