my $target = caller;
my $class = shift;
strictures->import;
- if ($Moo::Role::INFO{$target} and $Moo::Role::INFO{$target}{is_role}) {
+ if ($Role::Tiny::INFO{$target} and $Role::Tiny::INFO{$target}{is_role}) {
die "Cannot import Moo into a role";
}
$MAKERS{$target} ||= {};
die "${role} is not a Role::Tiny" unless $INFO{$role};
}
- $Moo::MAKERS{$new_name} = {};
+ $Moo::MAKERS{$new_name} = {is_class => 1};
$me->_handle_constructor($new_name, $_) for @roles;
# Compile-time exceptions, so need stringy eval; hence not Test::Fatal.
{
local $@;
- ok not eval q { package XXX; use Moo; use Moo::Role; 1; };
- like $@, qr{Cannot import Moo::Role into a Moo class};
+ ok !eval q { package ZZZ; use Role::Tiny; use Moo; 1; },
+ "can't import Moo into a Role::Tiny role";
+ like $@, qr{Cannot import Moo into a role},
+ " ... with correct error message";
}
{
local $@;
- ok not eval q { package YYY; use Moo::Role; use Moo; 1; };
- like $@, qr{Cannot import Moo into a role};
+ ok !eval q { package XXX; use Moo; use Moo::Role; 1; },
+ "can't import Moo::Role into a Moo class";
+ like $@, qr{Cannot import Moo::Role into a Moo class},
+ " ... with correct error message";
+}
+
+{
+ local $@;
+ ok !eval q { package YYY; use Moo::Role; use Moo; 1; },
+ "can't import Moo into a Moo role";
+ like $@, qr{Cannot import Moo into a role},
+ " ... with correct error message";
}
done_testing;