2 use warnings FATAL => 'all';
6 plan skip_all => "Class::Method::Modifiers not installed or too old"
7 unless eval "use Class::Method::Modifiers 1.05; 1";
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 BaseClass; sub foo { __PACKAGE__ }
23 [ qw(One Two Three Four) ],
24 [ qw(Two Four Three) ],
27 my $combined = Role::Tiny->create_class_with_roles('BaseClass', @$combo);
29 [ $combined->foo ], [ reverse(@$combo), 'BaseClass' ],
32 my $object = bless({}, 'BaseClass');
33 Role::Tiny->apply_roles_to_object($object, @$combo);
34 is(ref($object), $combined, 'Object reblessed into correct class');
38 package Five; use Role::Tiny;
40 around bar => sub { my $orig = shift; $orig->(@_) };
49 "composing an around modifier fails when method doesn't exist";
50 like $@, qr/Can't apply Five to WithFive - missing bar/,
51 ' ... with correct error message';
55 Role::Tiny->create_class_with_roles('BaseClass', 'Five');
57 "composing an around modifier fails when method doesn't exist";
58 like $@, qr/Can't apply Five to .* - missing bar/,
59 ' ... with correct error message';