todo test for satisfying a requires() assertion via composing another role
[gitmo/Moose.git] / t / 600_todo_tests / 009_requirement_satisfaction_via_role.t
1
2 # as discussed on irc between ether and t0m
3 # <@ether> t0m: it's known. I asked doy about this a day or two ago as well
4 # <@ether> the problem is that the requires() is evaluated immediately, but
5 #          the attributes are not added until the final composition into
6 #          the class
7 # <@ether> I suppose the solution would be to compose the attributes into
8 #          the "thing" that results from TesT::Role::ProvidesThing
9 #          composing RequiresThing, rather than it being delayed until the
10 #          final composition, but I suspect that requires a lot of heavy
11 #          work in the core
12 # <@ether> it's frustrating because it pretty much means you can't put a
13 #          'requires' statement in anything but a class
14 # <@ether> so you can't compose a role built from other roles in order to
15 #          build an interface, and guarantee that interface was built
16 #          correctly with the requires() assertions
17
18 use strict;
19 use warnings;
20
21 use Test::More tests => 2;
22 use Test::Exception;
23 use Test::NoWarnings;
24
25 {
26     package Test::Role::RequiresThing;
27     use Moose::Role;
28
29     requires 'thing';
30 }
31 {
32     package Test::Role::ProvidesThing;
33     use Moose::Role;
34
35     has thing => ( is => 'ro' );
36
37     with 'Test::Role::RequiresThing';
38 }
39
40 {
41     package Test::Class;
42     use Moose;
43
44     lives_ok { with 'Test::Role::ProvidesThing' } 'can compose role that imposes a requirement that a composed role satisfies';
45 }
46