Subject: | Using Role::Tiny->apply_roles_to_object with too many roles makes too long package name |
If using Role::Tiny->apply_roles_to_object with too many roles,
it makes 'Identifier too long' error in string 'eval'.
And, Moo uses string eval.
I think Role::Tiny should shorten the package name if it's too long.
Here is test result:
#
Foo__WITH__R::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA__WITH__R::BBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB__WITH__R::CCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCC__WITH__R::DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
DDDDDDDDDDD__WITH__R::EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
not ok 1
# Failed test at hoge.pl line 40.
# Identifier too long at (eval 10) line 1.
1..1
# Looks like you failed 1 test of 1.
Here is a test case:
use strict;
use warnings;
use Test::More;
# using Role::Tiny->apply_roles_to_object with too many roles,
# It makes 'Identifier too long' error in string 'eval'.
# And, Moo uses string eval.
{
package R::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
use Role::Tiny;
package R::BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB;
use Role::Tiny;
package R::CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC;
use Role::Tiny;
package R::DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD;
use Role::Tiny;
package R::EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE;
use Role::Tiny;
}
{
package Foo;
sub new { bless {}, shift }
}
my $foo = Foo->new();
for (qw(
R::AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
R::BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
R::CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
R::DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
R::EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
)) {
Role::Tiny->apply_roles_to_object($foo, $_);
}
my $pkg = ref $foo;
note $pkg;
eval "package $pkg;";
ok(!$@) or diag $@;
done_testing;