bump version
[gitmo/Role-Tiny.git] / t / compose-modifiers.t
CommitLineData
c49b0f72 1use strictures 1;
2use Test::More;
3
4BEGIN {
5 plan skip_all => "Class::Method::Modifiers not installed"
6 unless eval "use Class::Method::Modifiers; 1";
7}
8
9{
10 package One; use Role::Tiny;
11 around foo => sub { my $orig = shift; (__PACKAGE__, $orig->(@_)) };
12 package Two; use Role::Tiny;
13 around foo => sub { my $orig = shift; (__PACKAGE__, $orig->(@_)) };
14 package Three; use Role::Tiny;
15 around foo => sub { my $orig = shift; (__PACKAGE__, $orig->(@_)) };
16 package Four; use Role::Tiny;
17 around foo => sub { my $orig = shift; (__PACKAGE__, $orig->(@_)) };
18 package Base; sub foo { __PACKAGE__ }
19}
20
21foreach my $combo (
22 [ qw(One Two Three Four) ],
23 [ qw(Two Four Three) ],
24 [ qw(One Two) ]
25) {
26 my $combined = Role::Tiny->create_class_with_roles('Base', @$combo);
27 is_deeply(
28 [ $combined->foo ], [ reverse(@$combo), 'Base' ],
29 "${combined} ok"
30 );
31 my $object = bless({}, 'Base');
32 Role::Tiny->apply_roles_to_object($object, @$combo);
33 is(ref($object), $combined, 'Object reblessed into correct class');
34}
35
36done_testing;