bump version
[gitmo/Role-Tiny.git] / t / compose-modifiers.t
1 use strictures 1;
2 use Test::More;
3
4 BEGIN {
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
21 foreach 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
36 done_testing;