around foo => sub { my $orig = shift; (__PACKAGE__, $orig->(@_)) };
package Four; use Role::Tiny;
around foo => sub { my $orig = shift; (__PACKAGE__, $orig->(@_)) };
- package Base; sub foo { __PACKAGE__ }
+ package BaseClass; sub foo { __PACKAGE__ }
}
foreach my $combo (
[ qw(Two Four Three) ],
[ qw(One Two) ]
) {
- my $combined = Role::Tiny->create_class_with_roles('Base', @$combo);
+ my $combined = Role::Tiny->create_class_with_roles('BaseClass', @$combo);
is_deeply(
- [ $combined->foo ], [ reverse(@$combo), 'Base' ],
+ [ $combined->foo ], [ reverse(@$combo), 'BaseClass' ],
"${combined} ok"
);
- my $object = bless({}, 'Base');
+ my $object = bless({}, 'BaseClass');
Role::Tiny->apply_roles_to_object($object, @$combo);
is(ref($object), $combined, 'Object reblessed into correct class');
}
is eval {
package WithFive;
use Role::Tiny::With;
- use base 'Base';
+ use base 'BaseClass';
with 'Five';
}, undef,
"composing an around modifier fails when method doesn't exist";
{
package Role; use Role::Tiny;
sub foo { my $orig = shift; 1 + $orig->(@_) };
- package Base; sub foo { 1 }
+ package BaseClass; sub foo { 1 }
}
-eval { Role::Tiny->create_class_with_roles('Base', qw(Role Role)); };
+eval { Role::Tiny->create_class_with_roles('BaseClass', qw(Role Role)); };
like $@, qr/Duplicated/, 'duplicate role detected';