Subject: | breaking test case |
For parameterized roles, I ran into a problem. I downloaded the latest
git repository (as of yesterday, Dec 10) and was trying to modify the
parameterized roles test case to distill my possible error/bug. But I
got more basic failures, and I don't know why, so maybe this is another
bug??
What you have right now in t/lib/ParameterizedRole.pm is:
use MooseX::Declare;
role Counter (Str :$name, Int :$charges = 1) {
has $name => (is => 'rw', isa => 'Int', default => $charges);
method "increment_${name}" {
$self->$name($self->$name + 1);
}
method "reset_${name}" {
$self->$name(0);
}
}
(the rest is the same)
The compiler dies if just one more parameterized method is added. For
example:
use MooseX::Declare;
role Counter (Str :$name, Int :$charges = 1) {
has $name => (is => 'rw', isa => 'Int', default => $charges);
method "increment_${name}" {
$self->$name($self->$name + 1);
}
method "decrement_${name}" {
$self->$name($self->$name - 1);
}
method "reset_${name}" {
$self->$name(0);
}
}
(the rest is the same)
the test fails with:
<code><pre>
failure:
t/role_parameterized.t ................ syntax error at
/home/james/repos/moosex-declare/t/lib/ParameterizedRole.pm line 14,
near ""reset_${name}" {"
Global symbol "$self" requires explicit package name at
/home/james/repos/moosex-declare/t/lib/ParameterizedRole.pm line 15.
BEGIN not safe after errors--compilation aborted at
/home/james/repos/moosex-declare/t/lib/ParameterizedRole.pm line 16.
Compilation failed in require at t/role_parameterized.t line 8.
BEGIN failed--compilation aborted at t/role_parameterized.t line 8.
</pre></code>
Variations on that also fail. Actually, putting any other parameterized
method name in there, even with a body of just return; will make the
compiler choke. Making all the method bodies just 'return;' also fails,
if there are three methods. All is fine if there are two.
I'm happy to answer any clarification questions, etc etc.
git log:
commit 58259e5edff280fce77d5b0c88ebf12d86259306
Author: Florian Ragwitz <rafl@debian.org>
Date: Tue Nov 10 22:36:05 2009 +0100
perl -v
This is perl, v5.10.1 (*) built for x86_64-linux
uname -a
Linux emma64 2.6.30-gentoo-r5 #5 SMP Wed Nov 18 15:08:19 PST 2009 x86_64
AMD Phenom(tm) II X4 905e Processor AuthenticAMD GNU/Linux
perl -V
Summary of my perl5 (revision 5 version 10 subversion 1) configuration:
Platform:
osname=linux, osvers=2.6.30-gentoo-r5, archname=x86_64-linux
uname='linux emma64 2.6.30-gentoo-r5 #3 smp tue nov 17 13:09:43 pst
2009 x86_64 amd phenom(tm) ii x4 905e processor authenticamd gnulinux '
...