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