) {
push @mod_base, "sub ${modified} { shift->next::method(\@_) }";
}
+ my $e;
{
local $@;
eval(my $code = join "\n", "package ${base_name};", @mod_base);
- die "Evaling failed: $@\nTrying to eval:\n${code}" if $@;
+ $e = "Evaling failed: $@\nTrying to eval:\n${code}" if $@;
}
+ die $e if $e;
$me->_install_modifiers($composed_name, $modifiers);
$COMPOSED{role}{$composed_name} = 1;
return $composed_name;
sub extra1 { 'role extra' }
}
+BEGIN {
+ package BrokenRole;
+ use Role::Tiny;
+
+ around 'broken modifier' => sub { my $orig = shift; $orig->(@_) };
+}
+
sub try_apply_to {
my $to = shift;
exception { Role::Tiny->apply_role_to_package($to, 'MyRole') }
isa_ok($new_class, 'MyClass');
is($new_class->extra1, 'role extra', 'method from role');
+ok(exception {
+ $new_class = Role::Tiny->create_class_with_roles('MyClass', 'BrokenRole');
+}, 'exception caught creating class with broken modifier in a role');
+
done_testing;