Commit | Line | Data |
1947330a |
1 | use strictures 1; |
2 | use Test::More; |
3 | |
4 | { |
5 | package One; use Role::Tiny; |
6 | around foo => sub { my $orig = shift; (__PACKAGE__, $orig->(@_)) }; |
7 | package Two; use Role::Tiny; |
8 | around foo => sub { my $orig = shift; (__PACKAGE__, $orig->(@_)) }; |
9 | package Three; use Role::Tiny; |
10 | around foo => sub { my $orig = shift; (__PACKAGE__, $orig->(@_)) }; |
11 | package Four; use Role::Tiny; |
12 | around foo => sub { my $orig = shift; (__PACKAGE__, $orig->(@_)) }; |
13 | package Base; sub foo { __PACKAGE__ } |
14 | } |
15 | |
16 | foreach my $combo ( |
17 | [ qw(One Two Three Four) ], |
18 | [ qw(Two Four Three) ], |
19 | [ qw(One Two) ] |
20 | ) { |
21 | my $combined = Role::Tiny->create_class_with_roles('Base', @$combo); |
22 | is_deeply( |
23 | [ $combined->foo ], [ reverse(@$combo), 'Base' ], |
24 | "${combined} ok" |
25 | ); |
26 | my $object = bless({}, 'Base'); |
27 | Role::Tiny->apply_roles_to_object($object, @$combo); |
28 | is(ref($object), $combined, 'Object reblessed into correct class'); |
29 | } |
30 | |
31 | done_testing; |